rspec-mocks 2.11.3 → 2.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog.md +16 -0
- data/README.md +26 -1
- data/features/argument_matchers/explicit.feature +2 -2
- data/features/argument_matchers/general_matchers.feature +4 -4
- data/features/argument_matchers/type_matchers.feature +1 -1
- data/features/message_expectations/README.md +4 -0
- data/features/message_expectations/any_instance.feature +1 -1
- data/features/message_expectations/call_original.feature +24 -0
- data/features/message_expectations/expect_message.feature +5 -5
- data/features/message_expectations/receive_counts.feature +7 -7
- data/features/message_expectations/warn_when_expectation_is_set_on_nil.feature +3 -3
- data/features/method_stubs/any_instance.feature +6 -7
- data/features/method_stubs/as_null_object.feature +1 -1
- data/features/method_stubs/simple_return_value.feature +2 -2
- data/features/method_stubs/stub_chain.feature +1 -1
- data/features/method_stubs/stub_implementation.feature +1 -1
- data/features/method_stubs/to_ary.feature +1 -1
- data/features/{stubbing_constants → mutating_constants}/README.md +21 -1
- data/features/mutating_constants/hiding_defined_constant.feature +64 -0
- data/features/{stubbing_constants → mutating_constants}/stub_defined_constant.feature +0 -0
- data/features/{stubbing_constants → mutating_constants}/stub_undefined_constant.feature +0 -0
- data/features/outside_rspec/configuration.feature +3 -3
- data/features/outside_rspec/standalone.feature +6 -5
- data/lib/rspec/mocks.rb +17 -1
- data/lib/rspec/mocks/any_instance.rb +12 -12
- data/lib/rspec/mocks/configuration.rb +28 -0
- data/lib/rspec/mocks/error_generator.rb +6 -0
- data/lib/rspec/mocks/example_methods.rb +34 -9
- data/lib/rspec/mocks/framework.rb +3 -2
- data/lib/rspec/mocks/instance_method_stasher.rb +70 -0
- data/lib/rspec/mocks/message_expectation.rb +49 -29
- data/lib/rspec/mocks/method_double.rb +84 -7
- data/lib/rspec/mocks/{stub_const.rb → mutate_const.rb} +117 -40
- data/lib/rspec/mocks/proxy.rb +16 -5
- data/lib/rspec/mocks/version.rb +1 -1
- data/spec/rspec/mocks/and_call_original_spec.rb +162 -0
- data/spec/rspec/mocks/any_instance_spec.rb +18 -7
- data/spec/rspec/mocks/configuration_spec.rb +26 -0
- data/spec/rspec/mocks/failing_argument_matchers_spec.rb +9 -10
- data/spec/rspec/mocks/instance_method_stasher_spec.rb +58 -0
- data/spec/rspec/mocks/mock_spec.rb +35 -35
- data/spec/rspec/mocks/{stub_const_spec.rb → mutate_const_spec.rb} +142 -13
- data/spec/rspec/mocks/null_object_mock_spec.rb +3 -2
- data/spec/rspec/mocks/partial_mock_spec.rb +102 -77
- data/spec/rspec/mocks/serialization_spec.rb +1 -2
- data/spec/rspec/mocks/stub_implementation_spec.rb +6 -6
- data/spec/rspec/mocks_spec.rb +7 -0
- data/spec/spec_helper.rb +11 -0
- metadata +79 -80
- data/lib/rspec/mocks/stashed_instance_method.rb +0 -60
- data/spec/rspec/mocks/stashed_instance_method_spec.rb +0 -53
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe StashedInstanceMethod do
|
4
|
-
class ExampleClass
|
5
|
-
def hello
|
6
|
-
:hello_defined_on_class
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def singleton_class_for(obj)
|
11
|
-
class << obj; self; end
|
12
|
-
end
|
13
|
-
|
14
|
-
it "stashes the current implementation of an instance method so it can be temporarily replaced" do
|
15
|
-
obj = Object.new
|
16
|
-
def obj.hello; :hello_defined_on_singleton_class; end;
|
17
|
-
|
18
|
-
stashed_method = StashedInstanceMethod.new(singleton_class_for(obj), :hello)
|
19
|
-
stashed_method.stash
|
20
|
-
|
21
|
-
def obj.hello; :overridden_hello; end
|
22
|
-
expect(obj.hello).to eql :overridden_hello
|
23
|
-
|
24
|
-
stashed_method.restore
|
25
|
-
expect(obj.hello).to eql :hello_defined_on_singleton_class
|
26
|
-
end
|
27
|
-
|
28
|
-
it "stashes private instance methods" do
|
29
|
-
obj = Object.new
|
30
|
-
def obj.hello; :hello_defined_on_singleton_class; end;
|
31
|
-
singleton_class_for(obj).__send__(:private, :hello)
|
32
|
-
|
33
|
-
stashed_method = StashedInstanceMethod.new(singleton_class_for(obj), :hello)
|
34
|
-
stashed_method.stash
|
35
|
-
|
36
|
-
def obj.hello; :overridden_hello; end
|
37
|
-
stashed_method.restore
|
38
|
-
expect(obj.send(:hello)).to eql :hello_defined_on_singleton_class
|
39
|
-
end
|
40
|
-
|
41
|
-
it "only stashes methods directly defined on the given class, not its ancestors" do
|
42
|
-
obj = ExampleClass.new
|
43
|
-
|
44
|
-
stashed_method = StashedInstanceMethod.new(singleton_class_for(obj), :hello)
|
45
|
-
stashed_method.stash
|
46
|
-
|
47
|
-
def obj.hello; :overridden_hello; end;
|
48
|
-
expect(obj.hello).to eql :overridden_hello
|
49
|
-
|
50
|
-
stashed_method.restore
|
51
|
-
expect(obj.hello).to eql :overridden_hello
|
52
|
-
end
|
53
|
-
end
|