/
mocks_spec.rb
58 lines (51 loc) · 1.4 KB
/
mocks_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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