spec/lib/prosperity/extractors/base_spec.rb in prosperity-0.0.1 vs spec/lib/prosperity/extractors/base_spec.rb in prosperity-0.0.2
- old
+ new
@@ -1,8 +1,33 @@
require 'spec_helper'
module Prosperity
describe Extractors::Base do
+ let(:metric) { UsersMetric.new }
+ subject { Extractors::Change.new(metric, 'default', start_time, end_time, period) }
+ let(:data) { subject.to_a }
- end
-end
+ let(:start_time) { Time.new(1981, 7, 10) }
+ let(:end_time) { Time.new(2012, 7, 10) }
+ context "Month period" do
+ let(:period) { Periods::MONTH }
+
+ it { subject.start_time.to_i.should == Time.new(1981, 7, 1).to_i }
+ it { subject.end_time.to_i.should == Time.new(2012, 7, 31, 23, 59, 59).to_i }
+ end
+
+ context "Week period" do
+ let(:period) { Periods::WEEK }
+
+ it { subject.start_time.to_i.should == Time.new(1981, 7, 6).to_i }
+ it { subject.end_time.to_i.should == Time.new(2012, 7, 15, 23, 59, 59).to_i }
+ end
+
+ context "Day period" do
+ let(:period) { Periods::DAY }
+
+ it { subject.start_time.to_i.should == Time.new(1981, 7, 10, 0, 0, 0).to_i }
+ it { subject.end_time.to_i.should == Time.new(2012, 7, 10, 23, 59, 59).to_i }
+ end
+ end
+end
\ No newline at end of file