mocha 1.12.0 → 2.1.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 (82) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -13
  3. data/.yardopts +0 -1
  4. data/CONTRIBUTING.md +1 -1
  5. data/COPYING.md +2 -2
  6. data/Gemfile +27 -0
  7. data/MIT-LICENSE.md +1 -1
  8. data/README.md +12 -8
  9. data/RELEASE.md +169 -0
  10. data/Rakefile +22 -29
  11. data/gemfiles/Gemfile.minitest.latest +1 -0
  12. data/gemfiles/Gemfile.test-unit.latest +2 -5
  13. data/lib/mocha/any_instance_method.rb +0 -5
  14. data/lib/mocha/api.rb +29 -78
  15. data/lib/mocha/backtrace_filter.rb +2 -2
  16. data/lib/mocha/class_methods.rb +2 -2
  17. data/lib/mocha/configuration.rb +36 -114
  18. data/lib/mocha/debug.rb +2 -5
  19. data/lib/mocha/expectation.rb +63 -8
  20. data/lib/mocha/inspect.rb +6 -4
  21. data/lib/mocha/instance_method.rb +0 -4
  22. data/lib/mocha/integration/mini_test/adapter.rb +1 -1
  23. data/lib/mocha/integration/mini_test.rb +10 -38
  24. data/lib/mocha/integration/test_unit/adapter.rb +4 -4
  25. data/lib/mocha/integration/test_unit.rb +10 -33
  26. data/lib/mocha/invocation.rb +12 -16
  27. data/lib/mocha/minitest.rb +2 -4
  28. data/lib/mocha/mock.rb +32 -32
  29. data/lib/mocha/mockery.rb +1 -3
  30. data/lib/mocha/names.rb +1 -1
  31. data/lib/mocha/parameter_matchers/base.rb +1 -1
  32. data/lib/mocha/parameter_matchers/equivalent_uri.rb +1 -2
  33. data/lib/mocha/parameter_matchers/has_entry.rb +22 -13
  34. data/lib/mocha/parameter_matchers/has_keys.rb +53 -0
  35. data/lib/mocha/parameter_matchers/instance_methods.rb +10 -1
  36. data/lib/mocha/parameter_matchers/positional_or_keyword_hash.rb +64 -0
  37. data/lib/mocha/parameter_matchers.rb +1 -0
  38. data/lib/mocha/parameters_matcher.rb +3 -3
  39. data/lib/mocha/ruby_version.rb +1 -2
  40. data/lib/mocha/stubbed_method.rb +5 -42
  41. data/lib/mocha/test_unit.rb +2 -4
  42. data/lib/mocha/version.rb +1 -1
  43. data/lib/mocha.rb +0 -8
  44. data/mocha.gemspec +4 -29
  45. metadata +10 -87
  46. data/bin/build-matrix +0 -82
  47. data/gemfiles/Gemfile.minitest.1.3.0 +0 -7
  48. data/gemfiles/Gemfile.minitest.1.4.0 +0 -7
  49. data/gemfiles/Gemfile.minitest.1.4.1 +0 -7
  50. data/gemfiles/Gemfile.minitest.1.4.2 +0 -7
  51. data/gemfiles/Gemfile.minitest.2.0.0 +0 -7
  52. data/gemfiles/Gemfile.minitest.2.0.1 +0 -7
  53. data/gemfiles/Gemfile.minitest.2.11.0 +0 -7
  54. data/gemfiles/Gemfile.minitest.2.11.2 +0 -7
  55. data/gemfiles/Gemfile.minitest.2.3.0 +0 -7
  56. data/gemfiles/Gemfile.minitest.5.11.3 +0 -7
  57. data/gemfiles/Gemfile.test-unit.2.0.0 +0 -7
  58. data/gemfiles/Gemfile.test-unit.2.0.1 +0 -7
  59. data/gemfiles/Gemfile.test-unit.2.0.3 +0 -7
  60. data/init.rb +0 -1
  61. data/lib/mocha/integration/mini_test/nothing.rb +0 -19
  62. data/lib/mocha/integration/mini_test/version_13.rb +0 -54
  63. data/lib/mocha/integration/mini_test/version_140.rb +0 -54
  64. data/lib/mocha/integration/mini_test/version_141.rb +0 -65
  65. data/lib/mocha/integration/mini_test/version_142_to_172.rb +0 -65
  66. data/lib/mocha/integration/mini_test/version_200.rb +0 -66
  67. data/lib/mocha/integration/mini_test/version_201_to_222.rb +0 -66
  68. data/lib/mocha/integration/mini_test/version_2110_to_2111.rb +0 -70
  69. data/lib/mocha/integration/mini_test/version_2112_to_320.rb +0 -73
  70. data/lib/mocha/integration/mini_test/version_230_to_2101.rb +0 -68
  71. data/lib/mocha/integration/test_unit/gem_version_200.rb +0 -62
  72. data/lib/mocha/integration/test_unit/gem_version_201_to_202.rb +0 -62
  73. data/lib/mocha/integration/test_unit/gem_version_203_to_220.rb +0 -62
  74. data/lib/mocha/integration/test_unit/gem_version_230_to_250.rb +0 -68
  75. data/lib/mocha/integration/test_unit/nothing.rb +0 -19
  76. data/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb +0 -61
  77. data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +0 -63
  78. data/lib/mocha/integration.rb +0 -11
  79. data/lib/mocha/setup.rb +0 -14
  80. data/lib/mocha/singleton_class.rb +0 -9
  81. data/yard-templates/default/layout/html/google_analytics.erb +0 -8
  82. data/yard-templates/default/layout/html/setup.rb +0 -5
@@ -1,62 +0,0 @@
1
- require 'mocha/integration/assertion_counter'
2
- require 'mocha/integration/monkey_patcher'
3
- require 'mocha/expectation_error'
4
-
5
- module Mocha
6
- module Integration
7
- module TestUnit
8
- module GemVersion203To220
9
- def self.applicable_to?(test_unit_version, _ruby_version = nil)
10
- Gem::Requirement.new('>= 2.0.3', '<= 2.2.0').satisfied_by?(test_unit_version)
11
- end
12
-
13
- def self.description
14
- 'monkey patch for Test::Unit gem >= v2.0.3 and <= v2.2.0'
15
- end
16
-
17
- def self.included(mod)
18
- MonkeyPatcher.apply(mod, RunMethodPatch)
19
- end
20
-
21
- module RunMethodPatch
22
- # rubocop:disable all
23
- def run(result)
24
- assertion_counter = AssertionCounter.new(self)
25
- begin
26
- @_result = result
27
- yield(Test::Unit::TestCase::STARTED, name)
28
- begin
29
- begin
30
- mocha_setup
31
- run_setup
32
- run_test
33
- mocha_verify(assertion_counter)
34
- rescue Mocha::ExpectationError => e
35
- add_failure(e.message, e.backtrace)
36
- rescue Exception
37
- @interrupted = true
38
- raise unless handle_exception($!)
39
- ensure
40
- begin
41
- run_teardown
42
- rescue Mocha::ExpectationError => e
43
- add_failure(e.message, e.backtrace)
44
- rescue Exception
45
- raise unless handle_exception($!)
46
- end
47
- end
48
- ensure
49
- mocha_teardown
50
- end
51
- result.add_run
52
- yield(Test::Unit::TestCase::FINISHED, name)
53
- ensure
54
- # @_result = nil # For test-spec's after_all :<
55
- end
56
- end
57
- # rubocop:enable all
58
- end
59
- end
60
- end
61
- end
62
- end
@@ -1,68 +0,0 @@
1
- require 'mocha/integration/assertion_counter'
2
- require 'mocha/integration/monkey_patcher'
3
- require 'mocha/expectation_error'
4
-
5
- module Mocha
6
- module Integration
7
- module TestUnit
8
- module GemVersion230To250
9
- def self.applicable_to?(test_unit_version, _ruby_version = nil)
10
- Gem::Requirement.new('>= 2.3.0', '<= 2.5.0').satisfied_by?(test_unit_version)
11
- end
12
-
13
- def self.description
14
- 'monkey patch for Test::Unit gem >= v2.3.0 and <= v2.5.0'
15
- end
16
-
17
- def self.included(mod)
18
- MonkeyPatcher.apply(mod, RunMethodPatch)
19
- end
20
-
21
- module RunMethodPatch
22
- # rubocop:disable all
23
- def run(result)
24
- assertion_counter = AssertionCounter.new(self)
25
- begin
26
- @internal_data.test_started
27
- @_result = result
28
- yield(Test::Unit::TestCase::STARTED, name)
29
- yield(Test::Unit::TestCase::STARTED_OBJECT, self)
30
- begin
31
- begin
32
- mocha_setup
33
- run_setup
34
- run_test
35
- run_cleanup
36
- mocha_verify(assertion_counter)
37
- add_pass
38
- rescue Mocha::ExpectationError => e
39
- add_failure(e.message, e.backtrace)
40
- rescue Exception
41
- @internal_data.interrupted
42
- raise unless handle_exception($!)
43
- ensure
44
- begin
45
- run_teardown
46
- rescue Mocha::ExpectationError => e
47
- add_failure(e.message, e.backtrace)
48
- rescue Exception
49
- raise unless handle_exception($!)
50
- end
51
- end
52
- ensure
53
- mocha_teardown
54
- end
55
- @internal_data.test_finished
56
- result.add_run
57
- yield(Test::Unit::TestCase::FINISHED, name)
58
- yield(Test::Unit::TestCase::FINISHED_OBJECT, self)
59
- ensure
60
- # @_result = nil # For test-spec's after_all :<
61
- end
62
- end
63
- # rubocop:enable all
64
- end
65
- end
66
- end
67
- end
68
- end
@@ -1,19 +0,0 @@
1
- module Mocha
2
- module Integration
3
- module TestUnit
4
- module Nothing
5
- def self.applicable_to?(_test_unit_version, _ruby_version = nil)
6
- true
7
- end
8
-
9
- def self.description
10
- 'nothing (no Test::Unit integration available)'
11
- end
12
-
13
- def self.included(_mod)
14
- raise 'No Test::Unit integration available'
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,61 +0,0 @@
1
- require 'mocha/integration/assertion_counter'
2
- require 'mocha/integration/monkey_patcher'
3
- require 'mocha/expectation_error'
4
-
5
- module Mocha
6
- module Integration
7
- module TestUnit
8
- module RubyVersion185AndBelow
9
- def self.applicable_to?(test_unit_version, ruby_version)
10
- Gem::Requirement.new('<= 1.2.3').satisfied_by?(test_unit_version) && Gem::Requirement.new('<= 1.8.5').satisfied_by?(ruby_version)
11
- end
12
-
13
- def self.description
14
- 'monkey patch for standard library in Ruby <= v1.8.5'
15
- end
16
-
17
- def self.included(mod)
18
- MonkeyPatcher.apply(mod, RunMethodPatch)
19
- end
20
-
21
- module RunMethodPatch
22
- # rubocop:disable all
23
- def run(result)
24
- assertion_counter = AssertionCounter.new(self)
25
- yield(Test::Unit::TestCase::STARTED, name)
26
- @_result = result
27
- begin
28
- begin
29
- mocha_setup
30
- setup
31
- __send__(@method_name)
32
- mocha_verify(assertion_counter)
33
- rescue Mocha::ExpectationError => e
34
- add_failure(e.message, e.backtrace)
35
- rescue Test::Unit::AssertionFailedError => e
36
- add_failure(e.message, e.backtrace)
37
- rescue StandardError, ScriptError
38
- add_error($!)
39
- ensure
40
- begin
41
- teardown
42
- rescue Mocha::ExpectationError => e
43
- add_failure(e.message, e.backtrace)
44
- rescue Test::Unit::AssertionFailedError => e
45
- add_failure(e.message, e.backtrace)
46
- rescue StandardError, ScriptError
47
- add_error($!)
48
- end
49
- end
50
- ensure
51
- mocha_teardown
52
- end
53
- result.add_run
54
- yield(Test::Unit::TestCase::FINISHED, name)
55
- end
56
- # rubocop:enable all
57
- end
58
- end
59
- end
60
- end
61
- end
@@ -1,63 +0,0 @@
1
- require 'mocha/integration/assertion_counter'
2
- require 'mocha/integration/monkey_patcher'
3
- require 'mocha/expectation_error'
4
-
5
- module Mocha
6
- module Integration
7
- module TestUnit
8
- module RubyVersion186AndAbove
9
- def self.applicable_to?(test_unit_version, ruby_version)
10
- Gem::Requirement.new('<= 1.2.3').satisfied_by?(test_unit_version) && Gem::Requirement.new('>= 1.8.6').satisfied_by?(ruby_version)
11
- end
12
-
13
- def self.description
14
- 'monkey patch for standard library Test::Unit in Ruby >= v1.8.6'
15
- end
16
-
17
- def self.included(mod)
18
- MonkeyPatcher.apply(mod, RunMethodPatch)
19
- end
20
-
21
- module RunMethodPatch
22
- # rubocop:disable all
23
- def run(result)
24
- assertion_counter = AssertionCounter.new(self)
25
- yield(Test::Unit::TestCase::STARTED, name)
26
- @_result = result
27
- begin
28
- begin
29
- mocha_setup
30
- setup
31
- __send__(@method_name)
32
- mocha_verify(assertion_counter)
33
- rescue Mocha::ExpectationError => e
34
- add_failure(e.message, e.backtrace)
35
- rescue Test::Unit::AssertionFailedError => e
36
- add_failure(e.message, e.backtrace)
37
- rescue Exception
38
- raise if Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS.include? $!.class
39
- add_error($!)
40
- ensure
41
- begin
42
- teardown
43
- rescue Mocha::ExpectationError => e
44
- add_failure(e.message, e.backtrace)
45
- rescue Test::Unit::AssertionFailedError => e
46
- add_failure(e.message, e.backtrace)
47
- rescue Exception
48
- raise if Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS.include? $!.class
49
- add_error($!)
50
- end
51
- end
52
- ensure
53
- mocha_teardown
54
- end
55
- result.add_run
56
- yield(Test::Unit::TestCase::FINISHED, name)
57
- end
58
- # rubocop:enable all
59
- end
60
- end
61
- end
62
- end
63
- end
@@ -1,11 +0,0 @@
1
- require 'mocha/integration/test_unit'
2
- require 'mocha/integration/mini_test'
3
-
4
- module Mocha
5
- module Integration
6
- def self.activate
7
- return unless [Integration::TestUnit, Integration::MiniTest].map(&:activate).none?
8
- raise "Test::Unit or Minitest must be loaded *before* `require 'mocha/setup'`."
9
- end
10
- end
11
- end
data/lib/mocha/setup.rb DELETED
@@ -1,14 +0,0 @@
1
- require 'mocha/integration'
2
- require 'mocha/deprecation'
3
-
4
- Mocha::Deprecation.warning(
5
- "Require 'mocha/test_unit', 'mocha/minitest' or 'mocha/api' instead of 'mocha/setup'."
6
- )
7
-
8
- module Mocha
9
- def self.activate
10
- Integration.activate
11
- end
12
- end
13
-
14
- Mocha.activate
@@ -1,9 +0,0 @@
1
- if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('1.9.2')
2
- unless Kernel.method_defined?(:singleton_class)
3
- module Kernel
4
- def singleton_class
5
- class << self; self; end
6
- end
7
- end
8
- end
9
- end
@@ -1,8 +0,0 @@
1
- <script async src="https://www.googletagmanager.com/gtag/js?id=<%= ENV['GOOGLE_ANALYTICS_WEB_PROPERTY_ID'] %>"></script>
2
- <script>
3
- window.dataLayer = window.dataLayer || [];
4
- function gtag(){dataLayer.push(arguments);}
5
- gtag('js', new Date());
6
-
7
- gtag('config', '<%= ENV['GOOGLE_ANALYTICS_WEB_PROPERTY_ID'] %>');
8
- </script>
@@ -1,5 +0,0 @@
1
- def init
2
- super
3
- return unless ENV['GOOGLE_ANALYTICS_WEB_PROPERTY_ID']
4
- sections[:layout] << :google_analytics
5
- end