From 8c847a682109e8305ff1ac14cd493255884d8675 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Tue, 14 Mar 2023 20:19:13 -0600 Subject: AƱade specs faltantes de CompaniesController MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../index_companies_controller_spec.rb | 16 ++++++++++++++++ .../show_companies_controller_spec.rb | 13 +++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 spec/requests/companies_controller/index_companies_controller_spec.rb create mode 100644 spec/requests/companies_controller/show_companies_controller_spec.rb (limited to 'spec/requests') 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 -- cgit v1.2.3