spec/lib/quandl/client/dataset/validation_spec.rb in quandl_client-2.5.3 vs spec/lib/quandl/client/dataset/validation_spec.rb in quandl_client-2.6.0
- old
+ new
@@ -4,10 +4,19 @@
describe Dataset do
let(:dataset){ build(:dataset, source_code: "QUANDL_CLIENT_TEST_SOURCE" ) }
subject{ dataset }
+ context "data='1980,10,20\nASDF,10,30'" do
+ before(:each){
+ dataset.data = '1980,10,20\nASDF,10,30'
+ dataset.valid?
+ }
+ its(:valid?){ should be_false }
+ its('errors.messages'){ should eq({ data: ["Invalid date 'ASDF'"] }) }
+ end
+
context "given ambiguous code" do
before(:each){
dataset.source_code = nil
dataset.code = '12345'
dataset.valid?
@@ -20,20 +29,24 @@
before(:each){
dataset.data = [[2012, 1,2],[2011, 1,2,3]]
dataset.valid?
}
its(:valid?){ should be_false }
- its('errors.messages'){ should eq({ data: ["Unexpected number of points in this row:\n2011-12-31,1.0,2.0,3.0\nFound 3 but expected 2 based on precedent from the first row (2012-12-31,1.0,2.0)"]}) }
+ its('errors.messages'){ should eq({ data:
+ ["Unexpected number of points in this row:\n2011-12-31,1.0,2.0,3.0\nFound 3 but expected 2 based on precedent from the first row (2012-12-31,1.0,2.0)"]
+ })}
end
context "mismatch column_names count" do
before(:each){
dataset.column_names = ['Date','Value']
dataset.data = [[2012, 18,21],[2011, 1,2]]
dataset.valid?
}
its(:valid?){ should be_false }
- its('errors.messages'){ should eq({ data: ["Unexpected number of points in this row:\n2012-12-31,18.0,21.0\nFound 2 but expected 1 based on precedent from the header row (Date,Value)"]}) }
+ its('errors.messages'){ should eq({ data:
+ ["Unexpected number of points in this row:\n2012-12-31,18.0,21.0\nFound 2 but expected 1 based on precedent from the header row (Date,Value)"]
+ })}
end
describe "#code" do
before(:all){ Quandl::Client.token = ENV['QUANDL_AUTH_TOKEN'] }
\ No newline at end of file