mocha 1.15.0 → 2.0.0.alpha.1

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 (45) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -1
  3. data/Gemfile +3 -3
  4. data/RELEASE.md +42 -0
  5. data/Rakefile +12 -7
  6. data/lib/mocha/api.rb +5 -65
  7. data/lib/mocha/configuration.rb +30 -108
  8. data/lib/mocha/expectation.rb +62 -7
  9. data/lib/mocha/inspect.rb +2 -2
  10. data/lib/mocha/integration/mini_test.rb +10 -38
  11. data/lib/mocha/integration/test_unit/adapter.rb +1 -1
  12. data/lib/mocha/integration/test_unit.rb +10 -31
  13. data/lib/mocha/invocation.rb +2 -15
  14. data/lib/mocha/minitest.rb +1 -4
  15. data/lib/mocha/mock.rb +13 -9
  16. data/lib/mocha/parameter_matchers/base.rb +1 -1
  17. data/lib/mocha/parameter_matchers/equivalent_uri.rb +0 -1
  18. data/lib/mocha/parameter_matchers/instance_methods.rb +10 -1
  19. data/lib/mocha/parameter_matchers/positional_or_keyword_hash.rb +64 -0
  20. data/lib/mocha/parameters_matcher.rb +3 -3
  21. data/lib/mocha/ruby_version.rb +1 -9
  22. data/lib/mocha/stubbed_method.rb +3 -39
  23. data/lib/mocha/test_unit.rb +1 -4
  24. data/lib/mocha/version.rb +1 -1
  25. data/mocha.gemspec +1 -1
  26. metadata +10 -28
  27. data/init.rb +0 -1
  28. data/lib/mocha/integration/mini_test/nothing.rb +0 -19
  29. data/lib/mocha/integration/mini_test/version_13.rb +0 -54
  30. data/lib/mocha/integration/mini_test/version_140.rb +0 -54
  31. data/lib/mocha/integration/mini_test/version_141.rb +0 -65
  32. data/lib/mocha/integration/mini_test/version_142_to_172.rb +0 -65
  33. data/lib/mocha/integration/mini_test/version_200.rb +0 -66
  34. data/lib/mocha/integration/mini_test/version_201_to_222.rb +0 -66
  35. data/lib/mocha/integration/mini_test/version_2110_to_2111.rb +0 -70
  36. data/lib/mocha/integration/mini_test/version_2112_to_320.rb +0 -73
  37. data/lib/mocha/integration/mini_test/version_230_to_2101.rb +0 -68
  38. data/lib/mocha/integration/test_unit/gem_version_200.rb +0 -62
  39. data/lib/mocha/integration/test_unit/gem_version_201_to_202.rb +0 -62
  40. data/lib/mocha/integration/test_unit/gem_version_203_to_220.rb +0 -62
  41. data/lib/mocha/integration/test_unit/gem_version_230_to_250.rb +0 -68
  42. data/lib/mocha/integration/test_unit/nothing.rb +0 -19
  43. data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +0 -63
  44. data/lib/mocha/integration.rb +0 -11
  45. data/lib/mocha/setup.rb +0 -14
@@ -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,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