Sha256: f761cd9b1770b714671ce0b7371787c329d19729fb3857fe0af7a68aa9556352

Contents?: true

Size: 1.25 KB

Versions: 18

Compression:

Stored size: 1.25 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'
require 'mspec/runner/actions/timer'
require 'mspec/runner/mspec'
require 'time'

describe TimerAction do
  before :each do
    @timer = TimerAction.new
  end

  it "responds to #start by recording the current time" do
    Time.should_receive(:now)
    @timer.start
  end

  it "responds to #finish by recording the current time" do
    Time.should_receive(:now)
    @timer.finish
  end

  it "responds to #elapsed by returning the difference between stop and start" do
    Time.stub!(:now).and_return(Time.parse('10/18/2007 5:43:18'))
    @timer.start
    Time.stub!(:now).and_return(Time.parse('10/18/2007 5:43:51'))
    @timer.finish
    @timer.elapsed.should == 33
  end

  it "responds to #format by returning a readable string of elapsed time" do
    Time.stub!(:now).and_return(Time.parse('10/18/2007 5:43:18'))
    @timer.start
    Time.stub!(:now).and_return(Time.parse('10/18/2007 5:43:51'))
    @timer.finish
    @timer.format.should == "Finished in 33.000000 seconds"
  end

  it "responds to #register by registering itself with MSpec for appropriate actions" do
    MSpec.should_receive(:register).with(:start, @timer)
    MSpec.should_receive(:register).with(:finish, @timer)
    @timer.register
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
mspec-1.0.0 spec/runner/actions/timer_spec.rb
mspec-1.5.10 spec/runner/actions/timer_spec.rb
mspec-1.5.1 spec/runner/actions/timer_spec.rb
mspec-1.5.2 spec/runner/actions/timer_spec.rb
mspec-1.5.0 spec/runner/actions/timer_spec.rb
mspec-1.3.1 spec/runner/actions/timer_spec.rb
mspec-1.5.3 spec/runner/actions/timer_spec.rb
mspec-1.1.0 spec/runner/actions/timer_spec.rb
mspec-1.1.1 spec/runner/actions/timer_spec.rb
mspec-1.3.0 spec/runner/actions/timer_spec.rb
mspec-1.4.0 spec/runner/actions/timer_spec.rb
mspec-1.5.4 spec/runner/actions/timer_spec.rb
mspec-1.2.0 spec/runner/actions/timer_spec.rb
mspec-1.5.5 spec/runner/actions/timer_spec.rb
mspec-1.5.6 spec/runner/actions/timer_spec.rb
mspec-1.5.7 spec/runner/actions/timer_spec.rb
mspec-1.5.8 spec/runner/actions/timer_spec.rb
mspec-1.5.9 spec/runner/actions/timer_spec.rb