summaryrefslogtreecommitdiff
path: root/spec/requests/products_controller/show_spec.rb
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-03-30 17:29:40 -0600
committerHombreLaser <sebastian-440@live.com>2023-03-30 17:29:40 -0600
commit2ae0cd8a8dc6d630ee1a7a84ddf6111609dbdeb7 (patch)
treebbcaadbea3da32ee974d28cfb37c1af4be018215 /spec/requests/products_controller/show_spec.rb
parentefc5eb10894fc95487c55628b94024e97cd60139 (diff)
Mejora la estructura de los specs
Diffstat (limited to 'spec/requests/products_controller/show_spec.rb')
-rw-r--r--spec/requests/products_controller/show_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/requests/products_controller/show_spec.rb b/spec/requests/products_controller/show_spec.rb
new file mode 100644
index 0000000..9b2461c
--- /dev/null
+++ b/spec/requests/products_controller/show_spec.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+RSpec.describe 'GET /api/products/:public_id', type: :request do
+ it_behaves_like 'a GET resource request' do
+ let(:headers) { {} }
+ let(:product) { create(:product, public_id: SecureRandom.hex(12)) }
+ let(:route) { "/api/products/#{product.public_id}" }
+ let(:invalid_route) { "/api/products/#{Faker::Lorem.word}" }
+ let(:expected_text) do
+ product.categories.concat([product.name, product.id.to_s, product.unitary_price.to_i.to_s,
+ product.bulk_price.to_i.to_s, product.available_quantity.to_s, product.company.name,
+ product.company.short_name])
+ end
+ end
+end