Sha256: 83c31863fd200c58d276007fa2af3aaa68cee7c691f5cf9d6bf1b9ab73756c5a

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'
require 'mspec/guards'

describe Object, "#process_is_foreground" do
  before :each do
    MSpec.clear_modes
    ScratchPad.clear

    @guard = BackgroundGuard.new
    BackgroundGuard.stub(:new).and_return(@guard)
  end

  it "yields if MSpec.mode?(:background) is false" do
    MSpec.mode?(:background).should be_falsey
    process_is_foreground { ScratchPad.record :yield }
    ScratchPad.recorded.should == :yield
  end

  it "does not yield if MSpec.mode?(:background) is true" do
    MSpec.register_mode :background
    process_is_foreground { ScratchPad.record :yield }
    ScratchPad.recorded.should_not == :yield
  end

  it "sets the name of the guard to :process_is_foreground" do
    process_is_foreground { ScratchPad.record :yield }
    @guard.name.should == :process_is_foreground
  end

  it "calls #unregister even when an exception is raised in the guard block" do
    @guard.should_receive(:unregister)
    lambda do
      process_is_foreground { raise Exception }
    end.should raise_error(Exception)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mspec-1.9.1 spec/guards/background_spec.rb
mspec-1.9.0 spec/guards/background_spec.rb