Sha256: 4831389122576fed4dc2f6b967659f8e824e66771bfc04a505eebe9707c62c00

Contents?: true

Size: 908 Bytes

Versions: 2

Compression:

Stored size: 908 Bytes

Contents

# encoding: utf-8
require 'spec_helper'

describe Dataset do
  
  let(:source){ create(:source) }
  subject{ build(:dataset, source_code: source.code, data: Quandl::Data::Random.table(rows: 20, columns: 2) ) }
  
  describe "#from_date" do
    context "before_save" do
      it "should be nil" do
        subject.from_date.should be_nil
      end
    end
    context "after_save" do
      before(:each){ subject.save }
      it "should equal the last date" do
        subject.from_date.should eq subject.data_table.to_date[-1][0].to_s
      end
    end
  end
  
  describe "#to_date" do
    context "before_save" do
      it "should be nil" do
        subject.to_date.should be_nil
      end
    end
    context "after_save" do
      before(:each){ subject.save }
      it "should equal the first date" do
        subject.to_date.should eq subject.data_table.to_date[0][0].to_s
      end
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
quandl_client-0.1.16 spec/quandl/client/dataset/trim_spec.rb
quandl_client-0.1.15 spec/quandl/client/dataset/trim_spec.rb