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.
Files changed (51) hide show
  1. data/Changelog.md +16 -0
  2. data/README.md +26 -1
  3. data/features/argument_matchers/explicit.feature +2 -2
  4. data/features/argument_matchers/general_matchers.feature +4 -4
  5. data/features/argument_matchers/type_matchers.feature +1 -1
  6. data/features/message_expectations/README.md +4 -0
  7. data/features/message_expectations/any_instance.feature +1 -1
  8. data/features/message_expectations/call_original.feature +24 -0
  9. data/features/message_expectations/expect_message.feature +5 -5
  10. data/features/message_expectations/receive_counts.feature +7 -7
  11. data/features/message_expectations/warn_when_expectation_is_set_on_nil.feature +3 -3
  12. data/features/method_stubs/any_instance.feature +6 -7
  13. data/features/method_stubs/as_null_object.feature +1 -1
  14. data/features/method_stubs/simple_return_value.feature +2 -2
  15. data/features/method_stubs/stub_chain.feature +1 -1
  16. data/features/method_stubs/stub_implementation.feature +1 -1
  17. data/features/method_stubs/to_ary.feature +1 -1
  18. data/features/{stubbing_constants → mutating_constants}/README.md +21 -1
  19. data/features/mutating_constants/hiding_defined_constant.feature +64 -0
  20. data/features/{stubbing_constants → mutating_constants}/stub_defined_constant.feature +0 -0
  21. data/features/{stubbing_constants → mutating_constants}/stub_undefined_constant.feature +0 -0
  22. data/features/outside_rspec/configuration.feature +3 -3
  23. data/features/outside_rspec/standalone.feature +6 -5
  24. data/lib/rspec/mocks.rb +17 -1
  25. data/lib/rspec/mocks/any_instance.rb +12 -12
  26. data/lib/rspec/mocks/configuration.rb +28 -0
  27. data/lib/rspec/mocks/error_generator.rb +6 -0
  28. data/lib/rspec/mocks/example_methods.rb +34 -9
  29. data/lib/rspec/mocks/framework.rb +3 -2
  30. data/lib/rspec/mocks/instance_method_stasher.rb +70 -0
  31. data/lib/rspec/mocks/message_expectation.rb +49 -29
  32. data/lib/rspec/mocks/method_double.rb +84 -7
  33. data/lib/rspec/mocks/{stub_const.rb → mutate_const.rb} +117 -40
  34. data/lib/rspec/mocks/proxy.rb +16 -5
  35. data/lib/rspec/mocks/version.rb +1 -1
  36. data/spec/rspec/mocks/and_call_original_spec.rb +162 -0
  37. data/spec/rspec/mocks/any_instance_spec.rb +18 -7
  38. data/spec/rspec/mocks/configuration_spec.rb +26 -0
  39. data/spec/rspec/mocks/failing_argument_matchers_spec.rb +9 -10
  40. data/spec/rspec/mocks/instance_method_stasher_spec.rb +58 -0
  41. data/spec/rspec/mocks/mock_spec.rb +35 -35
  42. data/spec/rspec/mocks/{stub_const_spec.rb → mutate_const_spec.rb} +142 -13
  43. data/spec/rspec/mocks/null_object_mock_spec.rb +3 -2
  44. data/spec/rspec/mocks/partial_mock_spec.rb +102 -77
  45. data/spec/rspec/mocks/serialization_spec.rb +1 -2
  46. data/spec/rspec/mocks/stub_implementation_spec.rb +6 -6
  47. data/spec/rspec/mocks_spec.rb +7 -0
  48. data/spec/spec_helper.rb +11 -0
  49. metadata +79 -80
  50. data/lib/rspec/mocks/stashed_instance_method.rb +0 -60
  51. 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