# encoding: utf-8
require 'spec_helper'

describe Dataset do
  
  subject{ build(:dataset) }
  
  describe "#trim_start" do
    context "before_save" do
      it "should be nil" do
        subject.trim_start.should be_nil
      end
    end
    context "after_save" do
      before(:each){ subject.save }
      it "should equal the last date" do
        subject.trim_start.should eq subject.data.to_date[-1][0]
      end
    end
  end
  
  describe "#trim_end" do
    context "before_save" do
      it "should be nil" do
        subject.trim_end.should be_nil
      end
    end
    context "after_save" do
      before(:each){ subject.save }
      it "should equal the first date" do
        subject.trim_end.should eq subject.data.to_date[0][0]
      end
    end
  end
  
end