Sha256: ea0192482e7b511f58e36ad6ee0a17d7eed73544042e5b20f9ff30ed10db91c4

Contents?: true

Size: 1.4 KB

Versions: 2

Compression:

Stored size: 1.4 KB

Contents

require "spec_helper"

describe RSpec::Mocks do
  describe "::setup" do
    context "with an existing Mock::Space" do
      before do
        @orig_space = RSpec::Mocks::space
      end

      after do
        RSpec::Mocks::space = @orig_space
      end

      it "memoizes the space" do
        RSpec::Mocks::setup(Object.new)
        space = RSpec::Mocks::space
        RSpec::Mocks::setup(Object.new)
        RSpec::Mocks::space.should equal(space)
      end
    end

    context "with no pre-existing Mock::Space" do
      it "initializes a Mock::Space" do
        RSpec::Mocks::space = nil
        RSpec::Mocks::setup(Object.new)
        RSpec::Mocks::space.should_not be_nil
      end
    end
  end

  describe "::verify" do
    it "delegates to the space" do
      foo = double
      foo.should_receive(:bar)
      expect do
        RSpec::Mocks::verify
      end.to raise_error(RSpec::Mocks::MockExpectationError)
    end
  end

  describe "::teardown" do
    it "delegates to the space" do
      foo = double
      foo.should_receive(:bar)
      RSpec::Mocks::teardown
      expect do
        foo.bar
      end.to raise_error(/received unexpected message/)
    end
  end

  describe ".configuration" do
    it 'returns a memoized configuration instance' do
      RSpec::Mocks.configuration.should be_a(RSpec::Mocks::Configuration)
      RSpec::Mocks.configuration.should be(RSpec::Mocks.configuration)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspec-mocks-2.12.1 spec/rspec/mocks_spec.rb
rspec-mocks-2.12.0 spec/rspec/mocks_spec.rb