Sha256: 54edfdaf8bb0455fe48448095542fd2b3603551870ed7f8c18dd0d2e2acb415e

Contents?: true

Size: 1.25 KB

Versions: 13

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

describe IEX::Resources::Earnings do
  include_context 'client'

  context 'known symbol' do
    context 'with defaults', vcr: { cassette_name: 'earnings/msft' } do
      subject do
        client.earnings('MSFT')
      end
      let(:earnings) { subject.first }
      it 'retrieves earnings' do
        expect(subject.size).to eq 1
        expect(earnings.actual_eps).to eq 1.1
        expect(earnings.consensus_eps).to eq 1.09
        expect(earnings.announce_time).to eq 'AMC'
        expect(earnings.number_of_estimates).to eq 29
        expect(earnings.eps_surprise_dollar).to eq 0.01
        expect(earnings.eps_report_date).to eq '2019-01-30'
        expect(earnings.fiscal_period).to eq 'Q4 2018'
        expect(earnings.fiscal_end_date).to eq '2018-12-31'
        expect(earnings.year_ago).to eq 0.96
        expect(earnings.year_ago_change_percent).to eq 0.1458
        expect(earnings.year_ago_change_percent_s).to eq '+14.58%'
      end
    end
  end
  context 'invalid symbol', vcr: { cassette_name: 'earnings/invalid' } do
    subject do
      client.earnings('INVALID')
    end
    it 'fails with SymbolNotFoundError' do
      expect { subject }.to raise_error IEX::Errors::SymbolNotFoundError, 'Symbol INVALID Not Found'
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
iex-ruby-client-2.1.0 spec/iex/endpoints/earnings_spec.rb
iex-ruby-client-2.0.0 spec/iex/endpoints/earnings_spec.rb
iex-ruby-client-1.6.0 spec/iex/endpoints/earnings_spec.rb
iex-ruby-client-1.5.0 spec/iex/endpoints/earnings_spec.rb
iex-ruby-client-1.4.1 spec/iex/endpoints/earnings_spec.rb
iex-ruby-client-1.4.0 spec/iex/endpoints/earnings_spec.rb
iex-ruby-client-1.3.0 spec/iex/endpoints/earnings_spec.rb
iex-ruby-client-1.2.0 spec/iex/endpoints/earnings_spec.rb
iex-ruby-client-1.1.2 spec/iex/endpoints/earnings_spec.rb
iex-ruby-client-1.1.1 spec/iex/endpoints/earnings_spec.rb
iex-ruby-client-1.1.0 spec/iex/endpoints/earnings_spec.rb
iex-ruby-client-1.0.1 spec/iex/endpoints/earnings_spec.rb
iex-ruby-client-1.0.0 spec/iex/endpoints/earnings_spec.rb