rspec-mocks 2.13.1 → 2.14.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Changelog.md +45 -4
- data/README.md +1 -1
- data/features/argument_matchers/README.md +2 -2
- data/features/argument_matchers/explicit.feature +2 -3
- data/features/argument_matchers/general_matchers.feature +2 -2
- data/features/argument_matchers/type_matchers.feature +3 -4
- data/features/message_expectations/README.md +2 -2
- data/features/message_expectations/any_instance.feature +2 -2
- data/features/message_expectations/block_local_expectations.feature.pending +3 -3
- data/features/message_expectations/expect_message_using_expect.feature +103 -0
- data/features/message_expectations/expect_message_using_should_receive.feature +118 -0
- data/features/message_expectations/receive_counts.feature +1 -1
- data/features/method_stubs/README.md +1 -1
- data/features/method_stubs/any_instance.feature +11 -11
- data/features/method_stubs/as_null_object.feature +1 -1
- data/features/method_stubs/stub_implementation.feature +2 -2
- data/features/outside_rspec/configuration.feature +0 -20
- data/features/spies/spy_partial_mock_method.feature +34 -0
- data/features/spies/spy_pure_mock_method.feature +76 -0
- data/features/spies/spy_unstubbed_method.feature +18 -0
- data/features/step_definitions/additional_cli_steps.rb +7 -0
- data/features/test_frameworks/test_unit.feature +43 -0
- data/lib/rspec/mocks.rb +9 -34
- data/lib/rspec/mocks/any_instance/chain.rb +8 -2
- data/lib/rspec/mocks/any_instance/expectation_chain.rb +19 -16
- data/lib/rspec/mocks/any_instance/recorder.rb +6 -3
- data/lib/rspec/mocks/any_instance/stub_chain.rb +11 -11
- data/lib/rspec/mocks/any_instance/stub_chain_chain.rb +8 -10
- data/lib/rspec/mocks/argument_list_matcher.rb +7 -3
- data/lib/rspec/mocks/configuration.rb +28 -1
- data/lib/rspec/mocks/deprecation.rb +18 -0
- data/lib/rspec/mocks/error_generator.rb +60 -8
- data/lib/rspec/mocks/errors.rb +1 -1
- data/lib/rspec/mocks/example_methods.rb +39 -3
- data/lib/rspec/mocks/extensions/marshal.rb +4 -10
- data/lib/rspec/mocks/framework.rb +16 -4
- data/lib/rspec/mocks/instance_method_stasher.rb +3 -0
- data/lib/rspec/mocks/matchers/have_received.rb +93 -0
- data/lib/rspec/mocks/matchers/receive.rb +92 -0
- data/lib/rspec/mocks/message_expectation.rb +66 -129
- data/lib/rspec/mocks/method_double.rb +50 -43
- data/lib/rspec/mocks/mutate_const.rb +8 -20
- data/lib/rspec/mocks/proxy.rb +41 -25
- data/lib/rspec/mocks/proxy_for_nil.rb +36 -0
- data/lib/rspec/mocks/space.rb +64 -11
- data/lib/rspec/mocks/stub_chain.rb +51 -0
- data/lib/rspec/mocks/syntax.rb +329 -0
- data/lib/rspec/mocks/targets.rb +69 -0
- data/lib/rspec/mocks/test_double.rb +25 -4
- data/lib/rspec/mocks/version.rb +1 -1
- data/lib/spec/mocks.rb +1 -3
- data/spec/rspec/mocks/and_call_original_spec.rb +8 -0
- data/spec/rspec/mocks/and_yield_spec.rb +6 -6
- data/spec/rspec/mocks/any_instance_spec.rb +43 -31
- data/spec/rspec/mocks/any_number_of_times_spec.rb +6 -0
- data/spec/rspec/mocks/argument_expectation_spec.rb +12 -14
- data/spec/rspec/mocks/at_least_spec.rb +46 -37
- data/spec/rspec/mocks/at_most_spec.rb +12 -12
- data/spec/rspec/mocks/block_return_value_spec.rb +18 -1
- data/spec/rspec/mocks/bug_report_10260_spec.rb +1 -1
- data/spec/rspec/mocks/bug_report_10263_spec.rb +1 -1
- data/spec/rspec/mocks/bug_report_11545_spec.rb +4 -4
- data/spec/rspec/mocks/bug_report_600_spec.rb +1 -1
- data/spec/rspec/mocks/bug_report_7611_spec.rb +1 -1
- data/spec/rspec/mocks/configuration_spec.rb +124 -0
- data/spec/rspec/mocks/double_spec.rb +13 -1
- data/spec/rspec/mocks/failing_argument_matchers_spec.rb +17 -1
- data/spec/rspec/mocks/hash_excluding_matcher_spec.rb +13 -13
- data/spec/rspec/mocks/matchers/have_received_spec.rb +266 -0
- data/spec/rspec/mocks/matchers/receive_spec.rb +318 -0
- data/spec/rspec/mocks/methods_spec.rb +27 -0
- data/spec/rspec/mocks/mock_ordering_spec.rb +4 -4
- data/spec/rspec/mocks/mock_space_spec.rb +94 -39
- data/spec/rspec/mocks/mock_spec.rb +65 -50
- data/spec/rspec/mocks/multiple_return_value_spec.rb +10 -10
- data/spec/rspec/mocks/mutate_const_spec.rb +21 -1
- data/spec/rspec/mocks/nil_expectation_warning_spec.rb +10 -4
- data/spec/rspec/mocks/null_object_mock_spec.rb +11 -2
- data/spec/rspec/mocks/once_counts_spec.rb +5 -5
- data/spec/rspec/mocks/options_hash_spec.rb +4 -4
- data/spec/rspec/mocks/partial_mock_spec.rb +20 -11
- data/spec/rspec/mocks/partial_mock_using_mocks_directly_spec.rb +7 -7
- data/spec/rspec/mocks/passing_argument_matchers_spec.rb +2 -2
- data/spec/rspec/mocks/precise_counts_spec.rb +6 -6
- data/spec/rspec/mocks/serialization_spec.rb +1 -22
- data/spec/rspec/mocks/stash_spec.rb +4 -12
- data/spec/rspec/mocks/stub_implementation_spec.rb +3 -3
- data/spec/rspec/mocks/stub_spec.rb +44 -20
- data/spec/rspec/mocks/stubbed_message_expectations_spec.rb +6 -6
- data/spec/rspec/mocks/twice_counts_spec.rb +6 -6
- data/spec/rspec/mocks_spec.rb +1 -3
- data/spec/spec_helper.rb +25 -1
- metadata +86 -81
- data/features/message_expectations/expect_message.feature +0 -94
- data/lib/rspec/mocks/any_instance.rb +0 -81
- data/lib/rspec/mocks/extensions/psych.rb +0 -23
- data/lib/rspec/mocks/methods.rb +0 -155
- data/lib/rspec/mocks/serialization.rb +0 -34
- data/spec/rspec/mocks/combining_implementation_instructions_spec.rb +0 -197
@@ -8,8 +8,8 @@ module RSpec
|
|
8
8
|
it "fails if method is never called" do
|
9
9
|
@double.should_receive(:do_something).at_least(4).times
|
10
10
|
expect {
|
11
|
-
@double
|
12
|
-
}.to raise_error(
|
11
|
+
verify @double
|
12
|
+
}.to raise_error(/expected: at least 4 times.*received: 0 times/m)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "fails when called less than n times" do
|
@@ -18,30 +18,30 @@ module RSpec
|
|
18
18
|
@double.do_something
|
19
19
|
@double.do_something
|
20
20
|
expect {
|
21
|
-
@double
|
22
|
-
}.to raise_error(
|
21
|
+
verify @double
|
22
|
+
}.to raise_error(/expected: at least 4 times.*received: 3 times/m)
|
23
23
|
end
|
24
24
|
|
25
25
|
it "fails when at least once method is never called" do
|
26
26
|
@double.should_receive(:do_something).at_least(:once)
|
27
27
|
expect {
|
28
|
-
@double
|
29
|
-
}.to raise_error(
|
28
|
+
verify @double
|
29
|
+
}.to raise_error(/expected: at least 1 time.*received: 0 times/m)
|
30
30
|
end
|
31
31
|
|
32
32
|
it "fails when at least twice method is called once" do
|
33
33
|
@double.should_receive(:do_something).at_least(:twice)
|
34
34
|
@double.do_something
|
35
35
|
expect {
|
36
|
-
@double
|
37
|
-
}.to raise_error(
|
36
|
+
verify @double
|
37
|
+
}.to raise_error(/expected: at least 2 times.*received: 1 time/m)
|
38
38
|
end
|
39
39
|
|
40
40
|
it "fails when at least twice method is never called" do
|
41
41
|
@double.should_receive(:do_something).at_least(:twice)
|
42
42
|
expect {
|
43
|
-
@double
|
44
|
-
}.to raise_error(
|
43
|
+
verify @double
|
44
|
+
}.to raise_error(/expected: at least 2 times.*received: 0 times/m)
|
45
45
|
end
|
46
46
|
|
47
47
|
it "passes when at least n times method is called exactly n times" do
|
@@ -50,7 +50,7 @@ module RSpec
|
|
50
50
|
@double.do_something
|
51
51
|
@double.do_something
|
52
52
|
@double.do_something
|
53
|
-
@double
|
53
|
+
verify @double
|
54
54
|
end
|
55
55
|
|
56
56
|
it "passes when at least n times method is called n plus 1 times" do
|
@@ -60,20 +60,20 @@ module RSpec
|
|
60
60
|
@double.do_something
|
61
61
|
@double.do_something
|
62
62
|
@double.do_something
|
63
|
-
@double
|
63
|
+
verify @double
|
64
64
|
end
|
65
65
|
|
66
66
|
it "passes when at least once method is called once" do
|
67
67
|
@double.should_receive(:do_something).at_least(:once)
|
68
68
|
@double.do_something
|
69
|
-
@double
|
69
|
+
verify @double
|
70
70
|
end
|
71
71
|
|
72
72
|
it "passes when at least once method is called twice" do
|
73
73
|
@double.should_receive(:do_something).at_least(:once)
|
74
74
|
@double.do_something
|
75
75
|
@double.do_something
|
76
|
-
@double
|
76
|
+
verify @double
|
77
77
|
end
|
78
78
|
|
79
79
|
it "passes when at least twice method is called three times" do
|
@@ -81,47 +81,56 @@ module RSpec
|
|
81
81
|
@double.do_something
|
82
82
|
@double.do_something
|
83
83
|
@double.do_something
|
84
|
-
@double
|
84
|
+
verify @double
|
85
85
|
end
|
86
86
|
|
87
87
|
it "passes when at least twice method is called twice" do
|
88
88
|
@double.should_receive(:do_something).at_least(:twice)
|
89
89
|
@double.do_something
|
90
90
|
@double.do_something
|
91
|
-
@double
|
91
|
+
verify @double
|
92
92
|
end
|
93
93
|
|
94
94
|
it "returns the value given by a block when the at least once method is called" do
|
95
95
|
@double.should_receive(:to_s).at_least(:once) { "testing" }
|
96
96
|
expect(@double.to_s).to eq "testing"
|
97
|
-
@double
|
97
|
+
verify @double
|
98
98
|
end
|
99
99
|
|
100
|
-
|
101
|
-
|
102
|
-
@double.do_something
|
103
|
-
end
|
100
|
+
context "when sent with 0" do
|
101
|
+
before { RSpec.stub(:deprecate) }
|
104
102
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
103
|
+
it "outputs a deprecation warning" do
|
104
|
+
expect(RSpec).to receive(:deprecate).with("at_least\(0\) with should_receive", :replacement => "stub")
|
105
|
+
expect(@double).to receive(:do_something).at_least(0).times
|
106
|
+
end
|
109
107
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
108
|
+
it "passes with no return if called once" do
|
109
|
+
@double.should_receive(:do_something).at_least(0).times
|
110
|
+
@double.do_something
|
111
|
+
end
|
114
112
|
|
115
|
-
|
116
|
-
|
117
|
-
|
113
|
+
it "passes with return block if called once" do
|
114
|
+
@double.should_receive(:do_something).at_least(0).times { true }
|
115
|
+
@double.do_something
|
116
|
+
end
|
118
117
|
|
119
|
-
|
120
|
-
|
121
|
-
|
118
|
+
it "passes with and_return if called once" do
|
119
|
+
@double.should_receive(:do_something).at_least(0).times.and_return true
|
120
|
+
@double.do_something
|
121
|
+
end
|
122
|
+
|
123
|
+
it "passes with no return if never called" do
|
124
|
+
@double.should_receive(:do_something).at_least(0).times
|
125
|
+
end
|
126
|
+
|
127
|
+
it "passes with return block if never called" do
|
128
|
+
@double.should_receive(:do_something).at_least(0).times { true }
|
129
|
+
end
|
122
130
|
|
123
|
-
|
124
|
-
|
131
|
+
it "passes with and_return if never called" do
|
132
|
+
@double.should_receive(:do_something).at_least(0).times.and_return true
|
133
|
+
end
|
125
134
|
end
|
126
135
|
|
127
136
|
it "uses a stub value if no value set" do
|
@@ -11,53 +11,53 @@ module RSpec
|
|
11
11
|
@double.should_receive(:do_something).at_most(2).times
|
12
12
|
@double.do_something
|
13
13
|
@double.do_something
|
14
|
-
@double
|
14
|
+
verify @double
|
15
15
|
end
|
16
16
|
|
17
17
|
it "passes when at_most(n) is called less than n times" do
|
18
18
|
@double.should_receive(:do_something).at_most(2).times
|
19
19
|
@double.do_something
|
20
|
-
@double
|
20
|
+
verify @double
|
21
21
|
end
|
22
22
|
|
23
23
|
it "passes when at_most(n) is never called" do
|
24
24
|
@double.should_receive(:do_something).at_most(2).times
|
25
|
-
@double
|
25
|
+
verify @double
|
26
26
|
end
|
27
27
|
|
28
28
|
it "passes when at_most(:once) is called once" do
|
29
29
|
@double.should_receive(:do_something).at_most(:once)
|
30
30
|
@double.do_something
|
31
|
-
@double
|
31
|
+
verify @double
|
32
32
|
end
|
33
33
|
|
34
34
|
it "passes when at_most(:once) is never called" do
|
35
35
|
@double.should_receive(:do_something).at_most(:once)
|
36
|
-
@double
|
36
|
+
verify @double
|
37
37
|
end
|
38
38
|
|
39
39
|
it "passes when at_most(:twice) is called once" do
|
40
40
|
@double.should_receive(:do_something).at_most(:twice)
|
41
41
|
@double.do_something
|
42
|
-
@double
|
42
|
+
verify @double
|
43
43
|
end
|
44
44
|
|
45
45
|
it "passes when at_most(:twice) is called twice" do
|
46
46
|
@double.should_receive(:do_something).at_most(:twice)
|
47
47
|
@double.do_something
|
48
48
|
@double.do_something
|
49
|
-
@double
|
49
|
+
verify @double
|
50
50
|
end
|
51
51
|
|
52
52
|
it "passes when at_most(:twice) is never called" do
|
53
53
|
@double.should_receive(:do_something).at_most(:twice)
|
54
|
-
@double
|
54
|
+
verify @double
|
55
55
|
end
|
56
56
|
|
57
57
|
it "returns the value given by a block when at_most(:once) method is called" do
|
58
58
|
@double.should_receive(:to_s).at_most(:once) { "testing" }
|
59
59
|
expect(@double.to_s).to eq "testing"
|
60
|
-
@double
|
60
|
+
verify @double
|
61
61
|
end
|
62
62
|
|
63
63
|
it "fails fast when at_most(n) times method is called n plus 1 times" do
|
@@ -66,7 +66,7 @@ module RSpec
|
|
66
66
|
@double.do_something
|
67
67
|
expect {
|
68
68
|
@double.do_something
|
69
|
-
}.to raise_error(
|
69
|
+
}.to raise_error(/expected: at most 2 times.*received: 3 times/m)
|
70
70
|
end
|
71
71
|
|
72
72
|
it "fails fast when at_most(:once) and is called twice" do
|
@@ -74,7 +74,7 @@ module RSpec
|
|
74
74
|
@double.do_something
|
75
75
|
expect {
|
76
76
|
@double.do_something
|
77
|
-
}.to raise_error(
|
77
|
+
}.to raise_error(/expected: at most 1 time.*received: 2 times/m)
|
78
78
|
end
|
79
79
|
|
80
80
|
it "fails fast when at_most(:twice) and is called three times" do
|
@@ -83,7 +83,7 @@ module RSpec
|
|
83
83
|
@double.do_something
|
84
84
|
expect {
|
85
85
|
@double.do_something
|
86
|
-
}.to raise_error(
|
86
|
+
}.to raise_error(/expected: at most 2 times.*received: 3 times/m)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
end
|
@@ -33,7 +33,7 @@ describe "a double declaration with a block handed to:" do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
%w[once twice
|
36
|
+
%w[once twice ordered and_return].each do |method|
|
37
37
|
describe method do
|
38
38
|
it "returns the value of executing the block" do
|
39
39
|
obj = Object.new
|
@@ -43,6 +43,23 @@ describe "a double declaration with a block handed to:" do
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
describe 'any_number_of_times' do
|
47
|
+
before do
|
48
|
+
RSpec.stub(:deprecate)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "warns about deprecation" do
|
52
|
+
expect(RSpec).to receive(:deprecate).with("any_number_of_times", :replacement => "stub")
|
53
|
+
Object.new.stub(:foo).any_number_of_times { 'bar' }
|
54
|
+
end
|
55
|
+
|
56
|
+
it "returns the value of executing the block" do
|
57
|
+
obj = Object.new
|
58
|
+
obj.stub(:foo).any_number_of_times { 'bar' }
|
59
|
+
expect(obj.foo).to eq('bar')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
46
63
|
describe "times" do
|
47
64
|
it "returns the value of executing the block" do
|
48
65
|
obj = Object.new
|
@@ -3,6 +3,6 @@ require 'spec_helper'
|
|
3
3
|
describe "An RSpec Mock" do
|
4
4
|
it "hides internals in its inspect representation" do
|
5
5
|
m = double('cup')
|
6
|
-
expect(m.inspect).to match
|
6
|
+
expect(m.inspect).to match(/#<RSpec::Mocks::Mock:0x[a-f0-9.]+ @name="cup">/)
|
7
7
|
end
|
8
8
|
end
|
@@ -16,7 +16,7 @@ describe "Double" do
|
|
16
16
|
specify "then the next example should behave as expected instead of saying" do
|
17
17
|
test_double.should_receive(:foobar)
|
18
18
|
test_double.foobar
|
19
|
-
test_double
|
19
|
+
verify test_double
|
20
20
|
begin
|
21
21
|
test_double.foobar
|
22
22
|
rescue Exception => e
|
@@ -4,17 +4,17 @@ class LiarLiarPantsOnFire
|
|
4
4
|
def respond_to?(message, incl_private=false)
|
5
5
|
true
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
def self.respond_to?(message, incl_private=false)
|
9
9
|
true
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
describe 'should_receive' do
|
14
14
|
before(:each) do
|
15
15
|
@liar = LiarLiarPantsOnFire.new
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "works when object lies about responding to a method" do
|
19
19
|
@liar.should_receive(:something)
|
20
20
|
@liar.something
|
@@ -24,7 +24,7 @@ describe 'should_receive' do
|
|
24
24
|
LiarLiarPantsOnFire.should_receive(:something)
|
25
25
|
LiarLiarPantsOnFire.something
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
it 'cleans up after itself' do
|
29
29
|
expect((class << LiarLiarPantsOnFire; self; end).instance_methods).not_to include("something")
|
30
30
|
end
|
@@ -20,6 +20,130 @@ module RSpec
|
|
20
20
|
expect(instance_methods_of(mod_1)).to include(:stub, :should_receive)
|
21
21
|
expect(instance_methods_of(mod_2)).to include(:stub, :should_receive)
|
22
22
|
end
|
23
|
+
|
24
|
+
shared_examples_for "configuring the syntax" do
|
25
|
+
def sandboxed
|
26
|
+
orig_syntax = RSpec::Mocks.configuration.syntax
|
27
|
+
yield
|
28
|
+
ensure
|
29
|
+
configure_syntax(orig_syntax)
|
30
|
+
end
|
31
|
+
|
32
|
+
around(:each) { |ex| sandboxed(&ex) }
|
33
|
+
let(:dbl) { double }
|
34
|
+
let(:should_methods) { [:should_receive, :stub, :should_not_receive] }
|
35
|
+
let(:should_class_methods) { [:any_instance] }
|
36
|
+
let(:expect_methods) { [:receive, :allow, :expect_any_instance_of, :allow_any_instance_of] }
|
37
|
+
|
38
|
+
it 'defaults to enabling both the :should and :expect syntaxes' do
|
39
|
+
expect(dbl).to respond_to(*should_methods)
|
40
|
+
expect(self).to respond_to(*expect_methods)
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'when configured to :expect' do
|
44
|
+
before { configure_syntax :expect }
|
45
|
+
|
46
|
+
it 'removes the should methods from every object' do
|
47
|
+
expect(dbl).not_to respond_to(*should_methods)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'removes `any_instance` from every class' do
|
51
|
+
expect(Class.new).not_to respond_to(*should_class_methods)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'adds the expect methods to the example group context' do
|
55
|
+
expect(self).to respond_to(*expect_methods)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'reports that the syntax is :expect' do
|
59
|
+
expect(configured_syntax).to eq([:expect])
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'is a no-op when configured a second time' do
|
63
|
+
expect(Syntax.default_should_syntax_host).not_to receive(:method_undefined)
|
64
|
+
expect(::RSpec::Mocks::ExampleMethods).not_to receive(:method_added)
|
65
|
+
configure_syntax :expect
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'when configured to :should' do
|
70
|
+
before { configure_syntax :should }
|
71
|
+
|
72
|
+
it 'adds the should methods to every object' do
|
73
|
+
expect(dbl).to respond_to(*should_methods)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'adds `any_instance` to every class' do
|
77
|
+
expect(Class.new).to respond_to(*should_class_methods)
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'removes the expect methods from the example group context' do
|
81
|
+
expect(self).not_to respond_to(*expect_methods)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'reports that the syntax is :should' do
|
85
|
+
expect(configured_syntax).to eq([:should])
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'is a no-op when configured a second time' do
|
89
|
+
Syntax.default_should_syntax_host.should_not_receive(:method_added)
|
90
|
+
::RSpec::Mocks::ExampleMethods.should_not_receive(:method_undefined)
|
91
|
+
configure_syntax :should
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'when configured to [:should, :expect]' do
|
96
|
+
before { configure_syntax [:should, :expect] }
|
97
|
+
|
98
|
+
it 'adds the should methods to every object' do
|
99
|
+
expect(dbl).to respond_to(*should_methods)
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'adds `any_instance` to every class' do
|
103
|
+
expect(Class.new).to respond_to(*should_class_methods)
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'adds the expect methods to the example group context' do
|
107
|
+
expect(self).to respond_to(*expect_methods)
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'reports that both syntaxes are enabled' do
|
111
|
+
expect(configured_syntax).to eq([:should, :expect])
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "configuring rspec-mocks directly" do
|
117
|
+
it_behaves_like "configuring the syntax" do
|
118
|
+
def configure_syntax(syntax)
|
119
|
+
RSpec::Mocks.configuration.syntax = syntax
|
120
|
+
end
|
121
|
+
|
122
|
+
def configured_syntax
|
123
|
+
RSpec::Mocks.configuration.syntax
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe "configuring using the rspec-core config API" do
|
129
|
+
it_behaves_like "configuring the syntax" do
|
130
|
+
def configure_syntax(syntax)
|
131
|
+
RSpec.configure do |rspec|
|
132
|
+
rspec.mock_with :rspec do |c|
|
133
|
+
c.syntax = syntax
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def configured_syntax
|
139
|
+
RSpec.configure do |rspec|
|
140
|
+
rspec.mock_with :rspec do |c|
|
141
|
+
return c.syntax
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
23
147
|
end
|
24
148
|
end
|
25
149
|
end
|