Sha256: 06855ed2793bdabd5cab7149f6cd3b6631414bca4eabb0a3164e56a124293850

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

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 }

    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 { expect(subject.start_time.to_i).to eq(Time.new(1981, 7, 1).to_i) }
      it { expect(subject.end_time.to_i).to eq(Time.new(2012, 7, 31, 23, 59, 59).to_i) }
    end

    context "Week period" do
      let(:period) { Periods::WEEK }

      it { expect(subject.start_time.to_i).to eq(Time.new(1981, 7, 6).to_i) }
      it { expect(subject.end_time.to_i).to eq(Time.new(2012, 7, 15, 23, 59, 59).to_i) }
    end

    context "Day period" do
      let(:period) { Periods::DAY }

      it { expect(subject.start_time.to_i).to eq(Time.new(1981, 7, 10, 0, 0, 0).to_i) }
      it { expect(subject.end_time.to_i).to eq(Time.new(2012, 7, 10, 23, 59, 59).to_i) }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
prosperity-0.0.11 spec/lib/prosperity/extractors/base_spec.rb
prosperity-0.0.10 spec/lib/prosperity/extractors/base_spec.rb