mocha 1.8.0 → 1.9.0
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.
- checksums.yaml +4 -4
- data/README.md +11 -3
- data/RELEASE.md +10 -0
- data/bin/build-matrix +1 -2
- data/docs/Mocha.html +3 -3
- data/docs/Mocha/API.html +3 -3
- data/docs/Mocha/ClassMethods.html +3 -3
- data/docs/Mocha/Configuration.html +3 -3
- data/docs/Mocha/Expectation.html +3 -3
- data/docs/Mocha/ExpectationError.html +3 -3
- data/docs/Mocha/ExpectationErrorFactory.html +3 -3
- data/docs/Mocha/Hooks.html +3 -3
- data/docs/Mocha/Integration.html +3 -3
- data/docs/Mocha/Integration/MiniTest.html +3 -3
- data/docs/Mocha/Integration/MiniTest/Adapter.html +3 -3
- data/docs/Mocha/Integration/TestUnit.html +3 -3
- data/docs/Mocha/Integration/TestUnit/Adapter.html +3 -3
- data/docs/Mocha/Mock.html +3 -3
- data/docs/Mocha/ObjectMethods.html +3 -3
- data/docs/Mocha/ParameterMatchers.html +3 -3
- data/docs/Mocha/ParameterMatchers/AllOf.html +3 -3
- data/docs/Mocha/ParameterMatchers/AnyOf.html +3 -3
- data/docs/Mocha/ParameterMatchers/AnyParameters.html +3 -3
- data/docs/Mocha/ParameterMatchers/Anything.html +3 -3
- data/docs/Mocha/ParameterMatchers/Base.html +3 -3
- data/docs/Mocha/ParameterMatchers/Equals.html +3 -3
- data/docs/Mocha/ParameterMatchers/EquivalentUri.html +3 -3
- data/docs/Mocha/ParameterMatchers/HasEntries.html +3 -3
- data/docs/Mocha/ParameterMatchers/HasEntry.html +3 -3
- data/docs/Mocha/ParameterMatchers/HasKey.html +3 -3
- data/docs/Mocha/ParameterMatchers/HasValue.html +3 -3
- data/docs/Mocha/ParameterMatchers/Includes.html +3 -3
- data/docs/Mocha/ParameterMatchers/InstanceOf.html +3 -3
- data/docs/Mocha/ParameterMatchers/IsA.html +3 -3
- data/docs/Mocha/ParameterMatchers/KindOf.html +3 -3
- data/docs/Mocha/ParameterMatchers/Not.html +3 -3
- data/docs/Mocha/ParameterMatchers/Optionally.html +3 -3
- data/docs/Mocha/ParameterMatchers/RegexpMatches.html +3 -3
- data/docs/Mocha/ParameterMatchers/RespondsWith.html +3 -3
- data/docs/Mocha/ParameterMatchers/YamlEquivalent.html +3 -3
- data/docs/Mocha/Sequence.html +3 -3
- data/docs/Mocha/StateMachine.html +3 -3
- data/docs/Mocha/StateMachine/State.html +3 -3
- data/docs/Mocha/StateMachine/StatePredicate.html +3 -3
- data/docs/Mocha/StubbingError.html +3 -3
- data/docs/Mocha/UnexpectedInvocation.html +3 -3
- data/docs/_index.html +4 -4
- data/docs/file.COPYING.html +3 -3
- data/docs/file.MIT-LICENSE.html +3 -3
- data/docs/file.README.html +14 -6
- data/docs/file.RELEASE.html +15 -3
- data/docs/frames.html +1 -1
- data/docs/index.html +14 -6
- data/docs/js/app.js +11 -0
- data/docs/top-level-namespace.html +3 -3
- data/lib/mocha/any_instance_method.rb +17 -43
- data/lib/mocha/class_method.rb +79 -45
- data/lib/mocha/version.rb +1 -1
- data/test/unit/any_instance_method_test.rb +24 -0
- data/test/unit/class_method_test.rb +22 -0
- metadata +3 -5
- data/docs/CNAME +0 -1
data/lib/mocha/version.rb
CHANGED
@@ -43,6 +43,30 @@ class AnyInstanceMethodTest < Mocha::TestCase
|
|
43
43
|
assert mocha.__verified__?
|
44
44
|
end
|
45
45
|
|
46
|
+
def test_should_include_the_filename_and_line_number_in_exceptions
|
47
|
+
klass = Class.new { def method_x; end }
|
48
|
+
method = AnyInstanceMethod.new(klass, :method_x)
|
49
|
+
mocha = build_mock
|
50
|
+
mocha.stubs(:method_x).raises(Exception)
|
51
|
+
any_instance = Object.new
|
52
|
+
any_instance.define_instance_method(:mocha) { mocha }
|
53
|
+
klass.define_instance_method(:any_instance) { any_instance }
|
54
|
+
|
55
|
+
method.hide_original_method
|
56
|
+
method.define_new_method
|
57
|
+
|
58
|
+
expected_filename = 'any_instance_method.rb'
|
59
|
+
expected_line_number = 30
|
60
|
+
|
61
|
+
exception = assert_raises(Exception) { klass.new.method_x }
|
62
|
+
matching_line = exception.backtrace.find do |line|
|
63
|
+
filename, line_number, _context = line.split(':')
|
64
|
+
filename.include?(expected_filename) && line_number.to_i == expected_line_number
|
65
|
+
end
|
66
|
+
|
67
|
+
assert_not_nil matching_line, "Expected to find #{expected_filename}:#{expected_line_number} in the backtrace:\n #{exception.backtrace.join("\n")}"
|
68
|
+
end
|
69
|
+
|
46
70
|
def test_should_restore_original_method
|
47
71
|
klass = Class.new do
|
48
72
|
def method_x
|
@@ -48,6 +48,28 @@ class ClassMethodTest < Mocha::TestCase
|
|
48
48
|
assert mocha.__verified__?
|
49
49
|
end
|
50
50
|
|
51
|
+
def test_should_include_the_filename_and_line_number_in_exceptions
|
52
|
+
klass = Class.new { def self.method_x; end }
|
53
|
+
mocha = build_mock
|
54
|
+
klass.define_instance_method(:mocha) { mocha }
|
55
|
+
mocha.stubs(:method_x).raises(Exception)
|
56
|
+
method = ClassMethod.new(klass, :method_x)
|
57
|
+
|
58
|
+
method.hide_original_method
|
59
|
+
method.define_new_method
|
60
|
+
|
61
|
+
expected_filename = 'class_method.rb'
|
62
|
+
expected_line_number = 133
|
63
|
+
|
64
|
+
exception = assert_raises(Exception) { klass.method_x }
|
65
|
+
matching_line = exception.backtrace.find do |line|
|
66
|
+
filename, line_number, _context = line.split(':')
|
67
|
+
filename.include?(expected_filename) && line_number.to_i == expected_line_number
|
68
|
+
end
|
69
|
+
|
70
|
+
assert_not_nil matching_line, "Expected to find #{expected_filename}:#{expected_line_number} in the backtrace:\n #{exception.backtrace.join("\n")}"
|
71
|
+
end
|
72
|
+
|
51
73
|
def test_should_remove_new_method
|
52
74
|
klass = Class.new { def self.method_x; end }
|
53
75
|
method = ClassMethod.new(klass, :method_x)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mocha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Mead
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: metaclass
|
@@ -99,7 +99,6 @@ files:
|
|
99
99
|
- RELEASE.md
|
100
100
|
- Rakefile
|
101
101
|
- bin/build-matrix
|
102
|
-
- docs/CNAME
|
103
102
|
- docs/Mocha.html
|
104
103
|
- docs/Mocha/API.html
|
105
104
|
- docs/Mocha/ClassMethods.html
|
@@ -428,8 +427,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
428
427
|
- !ruby/object:Gem::Version
|
429
428
|
version: '0'
|
430
429
|
requirements: []
|
431
|
-
|
432
|
-
rubygems_version: 2.7.6
|
430
|
+
rubygems_version: 3.0.4
|
433
431
|
signing_key:
|
434
432
|
specification_version: 4
|
435
433
|
summary: Mocking and stubbing library
|
data/docs/CNAME
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
mocha.jamesmead.org
|