spec/rest/portfolios_consumers_spec.rb in finapps-5.0.3 vs spec/rest/portfolios_consumers_spec.rb in finapps-5.0.4

- old
+ new

@@ -29,26 +29,31 @@ let(:portfolio_id) { 'valid_id' } let(:params) { nil } it { expect { list }.not_to raise_error } it('returns an array') { expect(list).to be_a(Array) } - it('performs a get and returns the response') { expect(results).to respond_to(:records) } + it('performs a get and returns the response') do + expect(results).to have_key(:records) + end it('returns no error messages') { expect(errors).to be_empty } end context 'when valid id is provided w/ valid params' do let(:portfolio_id) { 'valid_id' } let(:params) { { page: 2, sort: '-created_date', requested: 25 } } it { expect { list }.not_to raise_error } it('returns an array') { expect(list).to be_a(Array) } - it('performs a get and returns the response') { expect(results).to respond_to(:records) } + it('performs a get and returns the response') do + expect(results).to have_key(:records) + end it('returns no error messages') { expect(errors).to be_empty } it 'builds query and sends proper request' do list - url = "#{versioned_api_path}/portfolios/#{portfolio_id}/consumers?page=2&" \ - 'requested=25&sort=-created_date' + url = + "#{versioned_api_path}/portfolios/#{portfolio_id}/consumers?page=2&" \ + 'requested=25&sort=-created_date' expect(WebMock).to have_requested(:get, url) end end context 'when invalid id is provided' do @@ -70,18 +75,22 @@ context 'when missing portfolio_id' do let(:portfolio_id) { nil } let(:params) { 'valid_id' } - it { expect { create }.to raise_error(FinAppsCore::MissingArgumentsError) } + it do + expect { create }.to raise_error(FinAppsCore::MissingArgumentsError) + end end context 'when missing params' do let(:portfolio_id) { 'valid_id' } let(:params) { nil } - it { expect { create }.to raise_error(FinAppsCore::MissingArgumentsError) } + it do + expect { create }.to raise_error(FinAppsCore::MissingArgumentsError) + end end context 'for bulk subscribe' do context 'when valid id and params are provided' do let(:portfolio_id) { 'valid_id' } @@ -104,11 +113,13 @@ it { expect { create }.not_to raise_error } it('results is nil') { expect(results).to be_nil } it('error messages array is populated') do # this will break when client is fixed to expect new array error response - expect(errors.first.downcase).to eq('the server responded with status 400') + expect(errors.first.downcase).to eq( + 'the server responded with status 400' + ) end end end context 'for single subscribe' do @@ -120,11 +131,12 @@ it('returns an array') { expect(create).to be_a(Array) } it('results is nil') { expect(results).to be_nil } it('returns no error messages') { expect(errors).to be_empty } it('builds correct url') do create - url = "#{versioned_api_path}/portfolios/#{portfolio_id}/consumers/#{params}" + url = + "#{versioned_api_path}/portfolios/#{portfolio_id}/consumers/#{params}" expect(WebMock).to have_requested(:post, url) end end context 'when invalid ids are provided' do @@ -132,11 +144,13 @@ let(:params) { portfolio_id } it { expect { create }.not_to raise_error } it('results is nil') { expect(results).to be_nil } it('error messages array is populated') do - expect(errors.first.downcase).to eq('consumer not eligible, no completed orders.') + expect(errors.first.downcase).to eq( + 'consumer not eligible, no completed orders.' + ) end end end end @@ -147,17 +161,21 @@ context 'when missing portfolio_id' do let(:portfolio_id) { nil } let(:consumer_id) { 'valid_id' } - it { expect { destroy }.to raise_error(FinAppsCore::MissingArgumentsError) } + it do + expect { destroy }.to raise_error(FinAppsCore::MissingArgumentsError) + end end context 'when missing consumer_id' do let(:portfolio_id) { 'valid_id' } let(:consumer_id) { nil } - it { expect { destroy }.to raise_error(FinAppsCore::MissingArgumentsError) } + it do + expect { destroy }.to raise_error(FinAppsCore::MissingArgumentsError) + end end context 'when valid ids are provided' do let(:portfolio_id) { 'valid_id' } let(:consumer_id) { portfolio_id }