diff options
Diffstat (limited to 'spec/requests/companies_controller')
-rw-r--r-- | spec/requests/companies_controller/index_companies_controller_spec.rb | 16 | ||||
-rw-r--r-- | spec/requests/companies_controller/show_companies_controller_spec.rb | 13 |
2 files changed, 29 insertions, 0 deletions
diff --git a/spec/requests/companies_controller/index_companies_controller_spec.rb b/spec/requests/companies_controller/index_companies_controller_spec.rb new file mode 100644 index 0000000..c8fb439 --- /dev/null +++ b/spec/requests/companies_controller/index_companies_controller_spec.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe 'GET /api/companies', type: :request do + before(:each) do + create_list(:company, 12) + end + + it_behaves_like 'a GET index request' do + let(:headers) { {} } + let(:companies) { create_list(:company, 12) } + let(:route) { '/api/companies' } + let(:pagination_size) { 10 } + end +end diff --git a/spec/requests/companies_controller/show_companies_controller_spec.rb b/spec/requests/companies_controller/show_companies_controller_spec.rb new file mode 100644 index 0000000..fc5bbd0 --- /dev/null +++ b/spec/requests/companies_controller/show_companies_controller_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe 'GET /api/companies/:short_name', type: :request do + it_behaves_like 'a GET resource request' do + let(:headers) { {} } + let(:company) { create(:company) } + let(:route) { "/api/companies/#{company.short_name}" } + let(:invalid_route) { "/api/companies/#{Faker::Lorem.word}" } + let(:expected_text) { [company.name, company.id.to_s, company.short_name, company.country] } + end +end |