Sha256: 5eeb3fac57f72d277d0e16bbab290d0a9a0b6dd3514017193f0d4cfcd6ff2275
Contents?: true
Size: 1.28 KB
Versions: 5
Compression:
Stored size: 1.28 KB
Contents
require 'spec_helper' describe IEX::Resources::Quote do include_context 'client' context 'known symbol', vcr: { cassette_name: 'quote/msft' } do subject do client.quote('MSFT') end it 'retrieves a quote' do expect(subject.symbol).to eq 'MSFT' expect(subject.company_name).to eq 'Microsoft Corp.' expect(subject.market_cap).to eq 915_754_985_600 end it 'coerces numbers' do expect(subject.latest_price).to eq 119.36 expect(subject.change).to eq(-0.61) expect(subject.week_52_high).to eq 120.82 expect(subject.week_52_low).to eq 87.73 expect(subject.change_percent).to eq(-0.00508) expect(subject.change_percent_s).to eq '-0.51%' end it 'coerces times' do expect(subject.latest_update).to eq 1_554_408_000_193 expect(subject.latest_update_t).to eq Time.at(1_554_408_000) expect(subject.iex_last_updated).to eq 1_554_407_999_529 expect(subject.iex_last_updated_t).to eq Time.at(1_554_407_999) end end context 'invalid symbol', vcr: { cassette_name: 'quote/invalid' } do subject do client.quote('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
5 entries across 5 versions & 1 rubygems