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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -3
  3. data/RELEASE.md +10 -0
  4. data/bin/build-matrix +1 -2
  5. data/docs/Mocha.html +3 -3
  6. data/docs/Mocha/API.html +3 -3
  7. data/docs/Mocha/ClassMethods.html +3 -3
  8. data/docs/Mocha/Configuration.html +3 -3
  9. data/docs/Mocha/Expectation.html +3 -3
  10. data/docs/Mocha/ExpectationError.html +3 -3
  11. data/docs/Mocha/ExpectationErrorFactory.html +3 -3
  12. data/docs/Mocha/Hooks.html +3 -3
  13. data/docs/Mocha/Integration.html +3 -3
  14. data/docs/Mocha/Integration/MiniTest.html +3 -3
  15. data/docs/Mocha/Integration/MiniTest/Adapter.html +3 -3
  16. data/docs/Mocha/Integration/TestUnit.html +3 -3
  17. data/docs/Mocha/Integration/TestUnit/Adapter.html +3 -3
  18. data/docs/Mocha/Mock.html +3 -3
  19. data/docs/Mocha/ObjectMethods.html +3 -3
  20. data/docs/Mocha/ParameterMatchers.html +3 -3
  21. data/docs/Mocha/ParameterMatchers/AllOf.html +3 -3
  22. data/docs/Mocha/ParameterMatchers/AnyOf.html +3 -3
  23. data/docs/Mocha/ParameterMatchers/AnyParameters.html +3 -3
  24. data/docs/Mocha/ParameterMatchers/Anything.html +3 -3
  25. data/docs/Mocha/ParameterMatchers/Base.html +3 -3
  26. data/docs/Mocha/ParameterMatchers/Equals.html +3 -3
  27. data/docs/Mocha/ParameterMatchers/EquivalentUri.html +3 -3
  28. data/docs/Mocha/ParameterMatchers/HasEntries.html +3 -3
  29. data/docs/Mocha/ParameterMatchers/HasEntry.html +3 -3
  30. data/docs/Mocha/ParameterMatchers/HasKey.html +3 -3
  31. data/docs/Mocha/ParameterMatchers/HasValue.html +3 -3
  32. data/docs/Mocha/ParameterMatchers/Includes.html +3 -3
  33. data/docs/Mocha/ParameterMatchers/InstanceOf.html +3 -3
  34. data/docs/Mocha/ParameterMatchers/IsA.html +3 -3
  35. data/docs/Mocha/ParameterMatchers/KindOf.html +3 -3
  36. data/docs/Mocha/ParameterMatchers/Not.html +3 -3
  37. data/docs/Mocha/ParameterMatchers/Optionally.html +3 -3
  38. data/docs/Mocha/ParameterMatchers/RegexpMatches.html +3 -3
  39. data/docs/Mocha/ParameterMatchers/RespondsWith.html +3 -3
  40. data/docs/Mocha/ParameterMatchers/YamlEquivalent.html +3 -3
  41. data/docs/Mocha/Sequence.html +3 -3
  42. data/docs/Mocha/StateMachine.html +3 -3
  43. data/docs/Mocha/StateMachine/State.html +3 -3
  44. data/docs/Mocha/StateMachine/StatePredicate.html +3 -3
  45. data/docs/Mocha/StubbingError.html +3 -3
  46. data/docs/Mocha/UnexpectedInvocation.html +3 -3
  47. data/docs/_index.html +4 -4
  48. data/docs/file.COPYING.html +3 -3
  49. data/docs/file.MIT-LICENSE.html +3 -3
  50. data/docs/file.README.html +14 -6
  51. data/docs/file.RELEASE.html +15 -3
  52. data/docs/frames.html +1 -1
  53. data/docs/index.html +14 -6
  54. data/docs/js/app.js +11 -0
  55. data/docs/top-level-namespace.html +3 -3
  56. data/lib/mocha/any_instance_method.rb +17 -43
  57. data/lib/mocha/class_method.rb +79 -45
  58. data/lib/mocha/version.rb +1 -1
  59. data/test/unit/any_instance_method_test.rb +24 -0
  60. data/test/unit/class_method_test.rb +22 -0
  61. metadata +3 -5
  62. data/docs/CNAME +0 -1
@@ -1,3 +1,3 @@
1
1
  module Mocha
2
- VERSION = '1.8.0'.freeze
2
+ VERSION = '1.9.0'.freeze
3
3
  end
@@ -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.8.0
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-01-15 00:00:00.000000000 Z
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
- rubyforge_project:
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