spec/historical_spec.rb in yahoo_finance-0.0.1 vs spec/historical_spec.rb in yahoo_finance-0.0.2
- old
+ new
@@ -31,10 +31,12 @@
end
describe "#each" do
subject { described_class.daily ticker, :from => start_date, :to => end_date }
+ use_vcr_cassette "AAPL-each"
+
it "iterates by ascending date order" do
subject.to_a.first.date.should < subject.to_a.last.date
end
context "when a period is specified" do
@@ -43,8 +45,22 @@
end
it "returns only records until the end date" do
subject.all? { |data| data.date <= end_date }.should be_true
end
+ end
+ end
+
+ describe "#to_csv" do
+ subject { described_class.daily(ticker, :from => Date.new(2011, 11, 11), :to => Date.new(2011, 11, 11)).to_csv }
+
+ use_vcr_cassette "AAPL-to_csv", :record => :once
+
+ it "returns the raw csv data" do
+ should match "2011-11-11,386.61,388.70,380.26,384.62,23349500,384.62"
+ end
+
+ it "doesn't show the header row" do
+ should_not match "Date,Open,High,Low,Close,Volume,Adj Close"
end
end
end