Sha256: d584a55fd224701f758c29f1ff5fc5ba8e8762896ff96cb6f11c1f4dcfe69bb4

Contents?: true

Size: 1.41 KB

Versions: 5

Compression:

Stored size: 1.41 KB

Contents

shared_examples_for Massive::TimingSupport do
  include_context "frozen time"

  context "when it has not been started" do
    its(:elapsed_time) { should be_zero }
  end

  context "when it has been started" do
    let(:started_at) { 1.minute.ago }
    before { subject.started_at = started_at }

    context "1 minute ago" do
      context "and it has not been finished yet" do
        its(:elapsed_time) { should eq(now - started_at) }

        it { should_not be_completed }
      end

      context "and it has been finished 10 seconds ago" do
        let(:finished_at) { 10.seconds.ago }
        before { subject.finished_at = finished_at }

        its(:elapsed_time) { should eq(finished_at - started_at) }

        it { should be_completed }
      end
    end

    context "2 hours ago" do
      let(:started_at) { 2.hours.ago }

      context "and it has not been finished yet" do
        its(:elapsed_time) { should eq(now - started_at) }

        it { should_not be_completed }
      end

      context "and has been finished 30 minutes ago" do
        let(:finished_at) { 30.minutes.ago }
        before { subject.finished_at = finished_at }

        its(:elapsed_time) { should eq(finished_at - started_at) }
        it { should be_completed }
      end
    end
  end
end

describe Massive::Step do
  it_should_behave_like Massive::TimingSupport
end

describe Massive::Job do
  it_should_behave_like Massive::TimingSupport
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
massive-0.4.0 spec/models/massive/timing_support_spec.rb
massive-0.3.0 spec/models/massive/timing_support_spec.rb
massive-0.2.0 spec/models/massive/timing_support_spec.rb
massive-0.1.1 spec/models/massive/timing_support_spec.rb
massive-0.1.0 spec/models/massive/timing_support_spec.rb