Sha256: b847dd4f4ac68332667a1d3dbc5d690f3f68af17f237c4c6ff5b61160fb0e119
Contents?: true
Size: 1.64 KB
Versions: 9
Compression:
Stored size: 1.64 KB
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/yaml/DJI.yaml', 'w') {|f| f.write StockIndex.new('^DJI').components.map{ |e| e[:symbol]}.to_yaml } # File.open('spec/fixtures/yaml/GSPC.yaml', 'w') {|f| f.write StockIndex.new('^GSPC').components.map{ |e| e[:symbol]}.to_yaml } # File.open('spec/fixtures/yaml/NDX.yaml', 'w') {|f| f.write StockIndex.new('^NDX').components.map{ |e| e[:symbol]}.to_yaml } # File.open('spec/fixtures/yaml/N225.yaml', 'w') {|f| f.write StockIndex.new('^N225').components.map{ |e| e[:symbol]}.to_yaml } # File.open('spec/fixtures/yaml/FTSE.yaml', 'w') {|f| f.write StockIndex.new('^FTSE').components.map{ |e| e[:symbol]}.to_yaml } it 'returns components for ^DJI' do expect(StockIndex.new('^DJI').components.map{ |e| e[:symbol] }).to match_array(components_from_fixture('^DJI')) end it 'returns components for ^GSPC' do expect(StockIndex.new('^GSPC').components.map{ |e| e[:symbol] }).to match_array(components_from_fixture('^GSPC')) end it 'returns components for ^NDX' do expect(StockIndex.new('^NDX').components.map{ |e| e[:symbol] }).to match_array(components_from_fixture('^NDX')) end it 'returns components for ^N225' do expect(StockIndex.new('^N225').components.map{ |e| e[:symbol] }).to match_array(components_from_fixture('^N225')) end it 'returns components for ^FTSE' do expect(StockIndex.new('^FTSE').components.map{ |e| e[:symbol] }).to match_array(components_from_fixture('^FTSE')) end end
Version data entries
9 entries across 9 versions & 1 rubygems