Sha256: 9ee7199dae84904d012a615cf10cd7f494a8715bb22ef9618cc90f93f838332b

Contents?: true

Size: 848 Bytes

Versions: 1

Compression:

Stored size: 848 Bytes

Contents

require 'spec_helper.rb'

describe Quotr do
  let(:symbol) { :abcd }
  let(:result) { { Date.new(2012, 4, 27) => BigDecimal('5.12'),
                   Date.new(2012, 4, 26) => BigDecimal('4.95'),
                   Date.new(2012, 4, 25) => BigDecimal('5.64')  } }
  before do
    Quotr::Yahoo.should_receive(:fetch).and_return("<CSV>")
    Quotr::YahooParser.should_receive(:parse).and_return(result)
  end

  describe '.close' do
    subject { Quotr.close(symbol, date) }  

    context 'on a trade date' do
      let(:date) { Date.new(2012, 4, 25) }

      it 'gets the close on that date' do
        should == result[date]
      end
    end

    context 'on a non-trade date' do
      let(:date) { Date.new(2012, 4, 28) }

      it 'gets the most recent close' do
        should == result[Date.new(2012, 4, 27)]    
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quotr-0.0.1 spec/quotr_spec.rb