spec/rest/portfolios_alerts_spec.rb in finapps-5.0.32 vs spec/rest/portfolios_alerts_spec.rb in finapps-5.0.33

- old
+ new

@@ -2,11 +2,11 @@ require 'spec_helpers/client' RSpec.describe FinApps::REST::PortfoliosAlerts do include SpecHelpers::Client - subject { FinApps::REST::PortfoliosAlerts.new(client) } + subject { described_class.new(client) } describe '#list' do let(:list) { subject.list(id) } let(:results) { list[RESULTS] } let(:errors) { list[ERROR_MESSAGES] } @@ -20,23 +20,26 @@ context 'when valid id is provided' do let(:id) { 'valid_id' } it { expect { list }.not_to raise_error } it('returns an array') { expect(list).to be_a(Array) } + it('performs a get and returns array of alert definitions') do expect(results).to be_a(Array) expect(results.first).to have_key(:_id) expect(results.first).to have_key(:rule_name) end + it('returns no error messages') { expect(errors).to be_empty } end context 'when invalid id is provided' do let(:id) { 'invalid_id' } it { expect { list }.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('resource not found') end end end @@ -78,10 +81,11 @@ let(:portfolio_id) { 'invalid_id' } let(:alert_id) { 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('resource not found') end end end @@ -123,9 +127,10 @@ let(:portfolio_id) { 'invalid_id' } let(:alert_id) { portfolio_id } it { expect { destroy }.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('resource not found') end end end