Sha256: 0f0c97f5a7648c22672bfedf6c8a371583dd7ec5e62b380972fd0981f067ae20
Contents?: true
Size: 1.58 KB
Versions: 3
Compression:
Stored size: 1.58 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Dataset do context "when built" do subject{ build(:dataset) } its(:saved?){ should be_false } its(:valid?){ should be_true } end context "when created" do context "without token" do before(:all){ Quandl::Client.token = '' } let(:dataset){ create(:dataset) } subject{ dataset } its(:saved?){ should be_false } its(:status){ should eq 401 } end context "with token" do before(:all){ Quandl::Client.token = ENV['QUANDL_AUTH_TOKEN'] } let(:source){ create(:source) } let(:dataset){ create(:dataset, source_code: source.code ) } subject{ dataset } its(:saved?){ should be_true } its(:status){ should eq 201 } end end context "when updated" do let(:source){ create(:source) } let(:dataset){ create(:dataset, source_code: source.code, data: Quandl::Data::Random.table(rows: 20, columns: 2).to_csv ) } it "should change data" do # update the dataset subject = Dataset.find(dataset.id) new_row = [ subject.data_table[0][0], 1.0, 2.0] subject.data = [ new_row ] subject.save # check the data Dataset.find(dataset.id).data_table.sort_descending[0].should eq new_row end it "should change column_spec" do subject = Dataset.find(dataset.id) subject.column_spec = "[0,[\"Date \\n\",{}],[\"Column 1 \",{}],[\"New Column Name \",{}]]" subject.save Dataset.find(dataset.id).column_spec.should eq subject.column_spec end end end
Version data entries
3 entries across 3 versions & 1 rubygems