Sha256: 450cc5edec5ff91bacea36a5eccebebb408dde73743b9e7820b29ed969bf1e5f

Contents?: true

Size: 875 Bytes

Versions: 1

Compression:

Stored size: 875 Bytes

Contents

require 'helper'

describe StockIndex do

  it 'returns a blank array for a not known index' do
    expect(StockIndex.new('ZZZZ').components).to eq([])
  end

  # How to generate a fixture file
  #
  # require 'yaml'
  # File.open('spec/fixtures/NDX.yaml', 'w') {|f| f.write StockIndex.new('^NDX').components.to_yaml }

  it 'returns components for ^DJI' do
    expect(StockIndex.new('^DJI').components.map{ |e| e[:symbol] }).to match_array(components_from_fixture('^DJI').map{ |e| e[:symbol] })
  end

  it 'returns components for ^GSPC' do
    expect(StockIndex.new('^GSPC').components.map{ |e| e[:symbol] }).to match_array(components_from_fixture('^GSPC').map{ |e| e[:symbol] })
  end

  it 'returns components for ^NDX' do
    expect(StockIndex.new('^NDX').components.map{ |e| e[:symbol] }).to match_array(components_from_fixture('^NDX').map{ |e| e[:symbol] })
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stock_index-0.6.0 spec/stock_index/stock_index_spec.rb