Sha256: acdd22c4412e5d33b290130b8f8c4e08c74432c7df9592017c9abfd9caa012f8

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

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

  context 'known symbol' do
    context 'with defaults', vcr: { cassette_name: 'news/msft' } do
      subject do
        client.news('MSFT')
      end
      let(:news) { subject.first }
      it 'retrieves news' do
        expect(subject.size).to eq 10
        expect(news.datetime.to_f).to eq 1_554_412_248.0
        expect(news.headline).to eq "Spotify joins Microsoft's Xbox Game Bar"
        expect(news.related).to eq(['MSFT'])
      end
    end
    context 'with range', vcr: { cassette_name: 'news/msft_7' } do
      subject do
        client.news('MSFT', 7)
      end
      it 'retrieves news' do
        expect(subject.size).to eq 7
      end
    end
  end
  context 'invalid symbol', vcr: { cassette_name: 'news/invalid' } do
    subject do
      client.news('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

8 entries across 8 versions & 1 rubygems

Version Path
iex-ruby-client-1.4.0 spec/iex/endpoints/news_spec.rb
iex-ruby-client-1.3.0 spec/iex/endpoints/news_spec.rb
iex-ruby-client-1.2.0 spec/iex/endpoints/news_spec.rb
iex-ruby-client-1.1.2 spec/iex/endpoints/news_spec.rb
iex-ruby-client-1.1.1 spec/iex/endpoints/news_spec.rb
iex-ruby-client-1.1.0 spec/iex/endpoints/news_spec.rb
iex-ruby-client-1.0.1 spec/iex/endpoints/news_spec.rb
iex-ruby-client-1.0.0 spec/iex/endpoints/news_spec.rb