mocha 0.12.1 → 0.12.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/RELEASE.rdoc +3 -0
  2. data/lib/mocha.rb +1 -1
  3. data/lib/mocha/expectation_error.rb +1 -13
  4. data/lib/mocha/expectation_error_factory.rb +17 -0
  5. data/lib/mocha/mock.rb +2 -1
  6. data/lib/mocha/mockery.rb +2 -1
  7. data/lib/mocha/{integration.rb → monkey_patching.rb} +5 -5
  8. data/lib/mocha/monkey_patching/mini_test.rb +62 -0
  9. data/lib/mocha/{integration → monkey_patching}/mini_test/assertion_counter.rb +2 -2
  10. data/lib/mocha/{integration → monkey_patching}/mini_test/exception_translation.rb +1 -1
  11. data/lib/mocha/{integration → monkey_patching}/mini_test/version_13.rb +4 -4
  12. data/lib/mocha/{integration → monkey_patching}/mini_test/version_140.rb +4 -4
  13. data/lib/mocha/{integration → monkey_patching}/mini_test/version_141.rb +4 -4
  14. data/lib/mocha/{integration → monkey_patching}/mini_test/version_142_to_172.rb +4 -4
  15. data/lib/mocha/{integration → monkey_patching}/mini_test/version_200.rb +4 -4
  16. data/lib/mocha/{integration → monkey_patching}/mini_test/version_201_to_222.rb +4 -4
  17. data/lib/mocha/{integration → monkey_patching}/mini_test/version_2110_to_2111.rb +4 -4
  18. data/lib/mocha/{integration → monkey_patching}/mini_test/version_2112_to_320.rb +4 -4
  19. data/lib/mocha/{integration → monkey_patching}/mini_test/version_230_to_2101.rb +4 -4
  20. data/lib/mocha/monkey_patching/mini_test/version_330.rb +65 -0
  21. data/lib/mocha/{integration → monkey_patching}/test_unit.rb +13 -13
  22. data/lib/mocha/{integration → monkey_patching}/test_unit/assertion_counter.rb +1 -1
  23. data/lib/mocha/{integration → monkey_patching}/test_unit/gem_version_200.rb +2 -2
  24. data/lib/mocha/{integration → monkey_patching}/test_unit/gem_version_201_to_202.rb +2 -2
  25. data/lib/mocha/{integration → monkey_patching}/test_unit/gem_version_203_to_220.rb +2 -2
  26. data/lib/mocha/{integration → monkey_patching}/test_unit/gem_version_230_to_251.rb +2 -2
  27. data/lib/mocha/{integration → monkey_patching}/test_unit/ruby_version_185_and_below.rb +2 -2
  28. data/lib/mocha/{integration → monkey_patching}/test_unit/ruby_version_186_and_above.rb +2 -2
  29. data/lib/mocha/object.rb +2 -1
  30. data/lib/mocha/version.rb +1 -1
  31. data/test/acceptance/minitest_test.rb +1 -1
  32. data/test/test_runner.rb +1 -1
  33. metadata +34 -32
  34. data/lib/mocha/integration/mini_test.rb +0 -59
@@ -1,3 +1,6 @@
1
+ = 0.12.2
2
+ * Officially support minitest v3.3.0 (still monkey-patching)
3
+
1
4
  = 0.12.1
2
5
  * Deprecation warning (instead of fail fast) if neither Test::Unit nor MiniTest is loaded. Fixes #88.
3
6
  * Remove deprecated access to `Mocha::Standalone`.
@@ -1,4 +1,4 @@
1
1
  require 'mocha/version'
2
- require 'mocha/integration'
2
+ require 'mocha/monkey_patching'
3
3
  require 'mocha_standalone'
4
4
  require 'mocha/configuration'
@@ -1,15 +1,3 @@
1
- require 'mocha/backtrace_filter'
2
-
3
1
  module Mocha
4
-
5
- class ExpectationError < Exception
6
-
7
- def initialize(message = nil, backtrace = [])
8
- super(message)
9
- filter = BacktraceFilter.new
10
- set_backtrace(filter.filtered(backtrace))
11
- end
12
-
13
- end
14
-
2
+ class ExpectationError < Exception; end
15
3
  end
@@ -0,0 +1,17 @@
1
+ require 'mocha/backtrace_filter'
2
+ require 'mocha/expectation_error'
3
+
4
+ module Mocha
5
+ class ExpectationErrorFactory
6
+ class << self
7
+ attr_accessor :exception_class
8
+ def build(message = nil, backtrace = [])
9
+ self.exception_class ||= ExpectationError
10
+ exception = exception_class.new(message)
11
+ filter = BacktraceFilter.new
12
+ exception.set_backtrace(filter.filtered(backtrace))
13
+ exception
14
+ end
15
+ end
16
+ end
17
+ end
@@ -6,6 +6,7 @@ require 'mocha/method_matcher'
6
6
  require 'mocha/parameters_matcher'
7
7
  require 'mocha/unexpected_invocation'
8
8
  require 'mocha/argument_iterator'
9
+ require 'mocha/expectation_error_factory'
9
10
 
10
11
  module Mocha
11
12
 
@@ -202,7 +203,7 @@ module Mocha
202
203
  matching_expectation.invoke(&block) if matching_expectation
203
204
  message = UnexpectedInvocation.new(self, symbol, *arguments).to_s
204
205
  message << @mockery.mocha_inspect
205
- raise ExpectationError.new(message, caller)
206
+ raise ExpectationErrorFactory.build(message, caller)
206
207
  end
207
208
  end
208
209
  end
@@ -5,6 +5,7 @@ require 'mocha/state_machine'
5
5
  require 'mocha/logger'
6
6
  require 'mocha/configuration'
7
7
  require 'mocha/stubbing_error'
8
+ require 'mocha/expectation_error_factory'
8
9
 
9
10
  module Mocha
10
11
 
@@ -50,7 +51,7 @@ module Mocha
50
51
  else
51
52
  backtrace = unsatisfied_expectations[0].backtrace
52
53
  end
53
- raise ExpectationError.new(message, backtrace)
54
+ raise ExpectationErrorFactory.build(message, backtrace)
54
55
  end
55
56
  expectations.each do |e|
56
57
  unless Mocha::Configuration.allow?(:stubbing_method_unnecessarily)
@@ -3,17 +3,17 @@ require 'mocha/deprecation'
3
3
 
4
4
  module Mocha
5
5
 
6
- module Integration
6
+ module MonkeyPatching
7
7
 
8
8
  class << self
9
9
 
10
10
  def monkey_patches
11
11
  patches = []
12
12
  if test_unit_testcase_defined? && !test_unit_testcase_inherits_from_miniunit_testcase?
13
- patches << 'mocha/integration/test_unit'
13
+ patches << 'mocha/monkey_patching/test_unit'
14
14
  end
15
15
  if mini_test_testcase_defined?
16
- patches << 'mocha/integration/mini_test'
16
+ patches << 'mocha/monkey_patching/mini_test'
17
17
  end
18
18
  patches
19
19
  end
@@ -36,11 +36,11 @@ module Mocha
36
36
 
37
37
  end
38
38
 
39
- unless Mocha::Integration.monkey_patches.any?
39
+ unless Mocha::MonkeyPatching.monkey_patches.any?
40
40
  Mocha::Deprecation.warning("Test::Unit or MiniTest must be loaded *before* Mocha.")
41
41
  Mocha::Deprecation.warning("If you're integrating with another test library, you should probably require 'mocha_standalone' instead of 'mocha'")
42
42
  end
43
43
 
44
- Mocha::Integration.monkey_patches.each do |patch|
44
+ Mocha::MonkeyPatching.monkey_patches.each do |patch|
45
45
  require patch
46
46
  end
@@ -0,0 +1,62 @@
1
+ require 'mocha/api'
2
+ require 'mocha/options'
3
+
4
+ if !MiniTest::Unit::TestCase.ancestors.include?(Mocha::API)
5
+
6
+ require 'mocha/monkey_patching/mini_test/exception_translation'
7
+ require 'mocha/monkey_patching/mini_test/version_13'
8
+ require 'mocha/monkey_patching/mini_test/version_140'
9
+ require 'mocha/monkey_patching/mini_test/version_141'
10
+ require 'mocha/monkey_patching/mini_test/version_142_to_172'
11
+ require 'mocha/monkey_patching/mini_test/version_200'
12
+ require 'mocha/monkey_patching/mini_test/version_201_to_222'
13
+ require 'mocha/monkey_patching/mini_test/version_230_to_2101'
14
+ require 'mocha/monkey_patching/mini_test/version_2110_to_2111'
15
+ require 'mocha/monkey_patching/mini_test/version_2112_to_320'
16
+ require 'mocha/monkey_patching/mini_test/version_330'
17
+
18
+ module MiniTest
19
+ class Unit
20
+ class TestCase
21
+
22
+ include Mocha::API
23
+
24
+ alias_method :run_before_mocha, :run
25
+ remove_method :run
26
+
27
+ mini_test_version = begin
28
+ Gem::Version.new(MiniTest::Unit::VERSION)
29
+ rescue LoadError
30
+ Gem::Version.new('0.0.0')
31
+ end
32
+
33
+ $stderr.puts "Detected MiniTest version: #{mini_test_version}" if $mocha_options['debug']
34
+
35
+ if Gem::Requirement.new('>= 1.3.0', '<= 1.3.1').satisfied_by?(mini_test_version)
36
+ include Mocha::MonkeyPatching::MiniTest::Version13
37
+ elsif Gem::Requirement.new('1.4.0').satisfied_by?(mini_test_version)
38
+ include Mocha::MonkeyPatching::MiniTest::Version140
39
+ elsif Gem::Requirement.new('1.4.1').satisfied_by?(mini_test_version)
40
+ include Mocha::MonkeyPatching::MiniTest::Version141
41
+ elsif Gem::Requirement.new('>= 1.4.2', '<= 1.7.2').satisfied_by?(mini_test_version)
42
+ include Mocha::MonkeyPatching::MiniTest::Version142To172
43
+ elsif Gem::Requirement.new('2.0.0').satisfied_by?(mini_test_version)
44
+ include Mocha::MonkeyPatching::MiniTest::Version200
45
+ elsif Gem::Requirement.new('>= 2.0.1', '<= 2.2.2').satisfied_by?(mini_test_version)
46
+ include Mocha::MonkeyPatching::MiniTest::Version201To222
47
+ elsif Gem::Requirement.new('>= 2.3.0', '<= 2.10.1').satisfied_by?(mini_test_version)
48
+ include Mocha::MonkeyPatching::MiniTest::Version230To2101
49
+ elsif Gem::Requirement.new('>= 2.11.0', '<= 2.11.1').satisfied_by?(mini_test_version)
50
+ include Mocha::MonkeyPatching::MiniTest::Version2110To2111
51
+ elsif Gem::Requirement.new('>= 2.11.2', '<= 3.2.0').satisfied_by?(mini_test_version)
52
+ include Mocha::MonkeyPatching::MiniTest::Version2112To320
53
+ elsif Gem::Requirement.new('3.3.0').satisfied_by?(mini_test_version)
54
+ include Mocha::MonkeyPatching::MiniTest::Version330
55
+ else
56
+ $stderr.puts "*** No Mocha monkey-patch for MiniTest version ***" if $mocha_options['debug']
57
+ end
58
+
59
+ end
60
+ end
61
+ end
62
+ end
@@ -1,6 +1,6 @@
1
1
  module Mocha
2
2
 
3
- module Integration
3
+ module MonkeyPatching
4
4
 
5
5
  module MiniTest
6
6
 
@@ -11,7 +11,7 @@ module Mocha
11
11
  end
12
12
 
13
13
  def increment
14
- @test_case._assertions += 1
14
+ @test_case.assert(true)
15
15
  end
16
16
 
17
17
  end
@@ -2,7 +2,7 @@ require 'mocha/expectation_error'
2
2
 
3
3
  module Mocha
4
4
 
5
- module Integration
5
+ module MonkeyPatching
6
6
 
7
7
  module MiniTest
8
8
 
@@ -1,8 +1,8 @@
1
- require 'mocha/integration/mini_test/assertion_counter'
1
+ require 'mocha/monkey_patching/mini_test/assertion_counter'
2
2
 
3
3
  module Mocha
4
4
 
5
- module Integration
5
+ module MonkeyPatching
6
6
 
7
7
  module MiniTest
8
8
 
@@ -22,12 +22,12 @@ module Mocha
22
22
  @passed = true
23
23
  rescue Exception => e
24
24
  @passed = false
25
- result = runner.puke(self.class, self.name, Mocha::Integration::MiniTest.translate(e))
25
+ result = runner.puke(self.class, self.name, Mocha::MonkeyPatching::MiniTest.translate(e))
26
26
  ensure
27
27
  begin
28
28
  self.teardown
29
29
  rescue Exception => e
30
- result = runner.puke(self.class, self.name, Mocha::Integration::MiniTest.translate(e))
30
+ result = runner.puke(self.class, self.name, Mocha::MonkeyPatching::MiniTest.translate(e))
31
31
  end
32
32
  end
33
33
  ensure
@@ -1,9 +1,9 @@
1
- require 'mocha/integration/mini_test/assertion_counter'
1
+ require 'mocha/monkey_patching/mini_test/assertion_counter'
2
2
  require 'mocha/expectation_error'
3
3
 
4
4
  module Mocha
5
5
 
6
- module Integration
6
+ module MonkeyPatching
7
7
 
8
8
  module MiniTest
9
9
 
@@ -23,12 +23,12 @@ module Mocha
23
23
  @passed = true
24
24
  rescue Exception => e
25
25
  @passed = false
26
- result = runner.puke(self.class, self.__name__, Mocha::Integration::MiniTest.translate(e))
26
+ result = runner.puke(self.class, self.__name__, Mocha::MonkeyPatching::MiniTest.translate(e))
27
27
  ensure
28
28
  begin
29
29
  self.teardown
30
30
  rescue Exception => e
31
- result = runner.puke(self.class, self.__name__, Mocha::Integration::MiniTest.translate(e))
31
+ result = runner.puke(self.class, self.__name__, Mocha::MonkeyPatching::MiniTest.translate(e))
32
32
  end
33
33
  end
34
34
  ensure
@@ -1,9 +1,9 @@
1
- require 'mocha/integration/mini_test/assertion_counter'
1
+ require 'mocha/monkey_patching/mini_test/assertion_counter'
2
2
  require 'mocha/expectation_error'
3
3
 
4
4
  module Mocha
5
5
 
6
- module Integration
6
+ module MonkeyPatching
7
7
 
8
8
  module MiniTest
9
9
 
@@ -31,14 +31,14 @@ module Mocha
31
31
  raise
32
32
  rescue Exception => e
33
33
  @passed = false
34
- result = runner.puke(self.class, self.__name__, Mocha::Integration::MiniTest.translate(e))
34
+ result = runner.puke(self.class, self.__name__, Mocha::MonkeyPatching::MiniTest.translate(e))
35
35
  ensure
36
36
  begin
37
37
  self.teardown
38
38
  rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
39
39
  raise
40
40
  rescue Exception => e
41
- result = runner.puke(self.class, self.__name__, Mocha::Integration::MiniTest.translate(e))
41
+ result = runner.puke(self.class, self.__name__, Mocha::MonkeyPatching::MiniTest.translate(e))
42
42
  end
43
43
  trap 'INFO', 'DEFAULT'
44
44
  end
@@ -1,9 +1,9 @@
1
- require 'mocha/integration/mini_test/assertion_counter'
1
+ require 'mocha/monkey_patching/mini_test/assertion_counter'
2
2
  require 'mocha/expectation_error'
3
3
 
4
4
  module Mocha
5
5
 
6
- module Integration
6
+ module MonkeyPatching
7
7
 
8
8
  module MiniTest
9
9
 
@@ -31,14 +31,14 @@ module Mocha
31
31
  raise
32
32
  rescue Exception => e
33
33
  @passed = false
34
- result = runner.puke(self.class, self.__name__, Mocha::Integration::MiniTest.translate(e))
34
+ result = runner.puke(self.class, self.__name__, Mocha::MonkeyPatching::MiniTest.translate(e))
35
35
  ensure
36
36
  begin
37
37
  self.teardown
38
38
  rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
39
39
  raise
40
40
  rescue Exception => e
41
- result = runner.puke(self.class, self.__name__, Mocha::Integration::MiniTest.translate(e))
41
+ result = runner.puke(self.class, self.__name__, Mocha::MonkeyPatching::MiniTest.translate(e))
42
42
  end
43
43
  trap 'INFO', 'DEFAULT' if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
44
44
  end
@@ -1,9 +1,9 @@
1
- require 'mocha/integration/mini_test/assertion_counter'
1
+ require 'mocha/monkey_patching/mini_test/assertion_counter'
2
2
  require 'mocha/expectation_error'
3
3
 
4
4
  module Mocha
5
5
 
6
- module Integration
6
+ module MonkeyPatching
7
7
 
8
8
  module MiniTest
9
9
 
@@ -32,14 +32,14 @@ module Mocha
32
32
  raise
33
33
  rescue Exception => e
34
34
  @passed = false
35
- result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
35
+ result = runner.puke self.class, self.__name__, Mocha::MonkeyPatching::MiniTest.translate(e)
36
36
  ensure
37
37
  begin
38
38
  self.teardown
39
39
  rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
40
40
  raise
41
41
  rescue Exception => e
42
- result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
42
+ result = runner.puke self.class, self.__name__, Mocha::MonkeyPatching::MiniTest.translate(e)
43
43
  end
44
44
  trap 'INFO', 'DEFAULT' if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
45
45
  end
@@ -1,9 +1,9 @@
1
- require 'mocha/integration/mini_test/assertion_counter'
1
+ require 'mocha/monkey_patching/mini_test/assertion_counter'
2
2
  require 'mocha/expectation_error'
3
3
 
4
4
  module Mocha
5
5
 
6
- module Integration
6
+ module MonkeyPatching
7
7
 
8
8
  module MiniTest
9
9
 
@@ -32,14 +32,14 @@ module Mocha
32
32
  raise
33
33
  rescue Exception => e
34
34
  @passed = false
35
- result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
35
+ result = runner.puke self.class, self.__name__, Mocha::MonkeyPatching::MiniTest.translate(e)
36
36
  ensure
37
37
  begin
38
38
  self.teardown
39
39
  rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
40
40
  raise
41
41
  rescue Exception => e
42
- result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
42
+ result = runner.puke self.class, self.__name__, Mocha::MonkeyPatching::MiniTest.translate(e)
43
43
  end
44
44
  trap 'INFO', 'DEFAULT' if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
45
45
  end
@@ -1,9 +1,9 @@
1
- require 'mocha/integration/mini_test/assertion_counter'
1
+ require 'mocha/monkey_patching/mini_test/assertion_counter'
2
2
  require 'mocha/expectation_error'
3
3
 
4
4
  module Mocha
5
5
 
6
- module Integration
6
+ module MonkeyPatching
7
7
 
8
8
  module MiniTest
9
9
 
@@ -34,7 +34,7 @@ module Mocha
34
34
  raise
35
35
  rescue Exception => e
36
36
  @passed = false
37
- result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
37
+ result = runner.puke self.class, self.__name__, Mocha::MonkeyPatching::MiniTest.translate(e)
38
38
  ensure
39
39
  %w{ before_teardown teardown after_teardown }.each do |hook|
40
40
  begin
@@ -42,7 +42,7 @@ module Mocha
42
42
  rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
43
43
  raise
44
44
  rescue Exception => e
45
- result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
45
+ result = runner.puke self.class, self.__name__, Mocha::MonkeyPatching::MiniTest.translate(e)
46
46
  end
47
47
  end
48
48
  trap 'INFO', 'DEFAULT' if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
@@ -1,9 +1,9 @@
1
- require 'mocha/integration/mini_test/assertion_counter'
1
+ require 'mocha/monkey_patching/mini_test/assertion_counter'
2
2
  require 'mocha/expectation_error'
3
3
 
4
4
  module Mocha
5
5
 
6
- module Integration
6
+ module MonkeyPatching
7
7
 
8
8
  module MiniTest
9
9
 
@@ -37,7 +37,7 @@ module Mocha
37
37
  raise
38
38
  rescue Exception => e
39
39
  @passed = false
40
- result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
40
+ result = runner.puke self.class, self.__name__, Mocha::MonkeyPatching::MiniTest.translate(e)
41
41
  ensure
42
42
  %w{ before_teardown teardown after_teardown }.each do |hook|
43
43
  begin
@@ -45,7 +45,7 @@ module Mocha
45
45
  rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
46
46
  raise
47
47
  rescue Exception => e
48
- result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
48
+ result = runner.puke self.class, self.__name__, Mocha::MonkeyPatching::MiniTest.translate(e)
49
49
  end
50
50
  end
51
51
  trap 'INFO', 'DEFAULT' if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
@@ -1,9 +1,9 @@
1
- require 'mocha/integration/mini_test/assertion_counter'
1
+ require 'mocha/monkey_patching/mini_test/assertion_counter'
2
2
  require 'mocha/expectation_error'
3
3
 
4
4
  module Mocha
5
5
 
6
- module Integration
6
+ module MonkeyPatching
7
7
 
8
8
  module MiniTest
9
9
 
@@ -33,7 +33,7 @@ module Mocha
33
33
  raise
34
34
  rescue Exception => e
35
35
  @passed = false
36
- result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
36
+ result = runner.puke self.class, self.__name__, Mocha::MonkeyPatching::MiniTest.translate(e)
37
37
  ensure
38
38
  begin
39
39
  self.run_teardown_hooks
@@ -41,7 +41,7 @@ module Mocha
41
41
  rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
42
42
  raise
43
43
  rescue Exception => e
44
- result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
44
+ result = runner.puke self.class, self.__name__, Mocha::MonkeyPatching::MiniTest.translate(e)
45
45
  end
46
46
  trap 'INFO', 'DEFAULT' if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
47
47
  end
@@ -0,0 +1,65 @@
1
+ require 'mocha/monkey_patching/mini_test/assertion_counter'
2
+ require 'mocha/expectation_error'
3
+
4
+ module Mocha
5
+
6
+ module MonkeyPatching
7
+
8
+ module MiniTest
9
+
10
+ module Version330
11
+ def self.included(mod)
12
+ $stderr.puts "Monkey patching MiniTest v3.3.0" if $mocha_options['debug']
13
+ end
14
+ def run runner
15
+ trap "INFO" do
16
+ runner.report.each_with_index do |msg, i|
17
+ warn "\n%3d) %s" % [i + 1, msg]
18
+ end
19
+ warn ''
20
+ time = runner.start_time ? Time.now - runner.start_time : 0
21
+ warn "Current Test: %s#%s %.2fs" % [self.class, self.__name__, time]
22
+ runner.status $stderr
23
+ end if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
24
+ assertion_counter = AssertionCounter.new(self)
25
+ result = ""
26
+ begin
27
+ begin
28
+ @passed = nil
29
+ self.before_setup
30
+ self.setup
31
+ self.after_setup
32
+ self.run_test self.__name__
33
+ mocha_verify(assertion_counter)
34
+ result = "." unless io?
35
+ @passed = true
36
+ rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
37
+ raise
38
+ rescue Exception => e
39
+ @passed = false
40
+ result = runner.puke self.class, self.__name__, Mocha::MonkeyPatching::MiniTest.translate(e)
41
+ ensure
42
+ %w{ before_teardown teardown after_teardown }.each do |hook|
43
+ begin
44
+ self.send hook
45
+ rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
46
+ raise
47
+ rescue Exception => e
48
+ @passed = false
49
+ result = runner.puke self.class, self.__name__, Mocha::MonkeyPatching::MiniTest.translate(e)
50
+ end
51
+ end
52
+ trap 'INFO', 'DEFAULT' if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
53
+ end
54
+ ensure
55
+ mocha_teardown
56
+ end
57
+ result
58
+ end
59
+ end
60
+
61
+ end
62
+
63
+ end
64
+
65
+ end
@@ -3,12 +3,12 @@ require 'mocha/options'
3
3
 
4
4
  if !Test::Unit::TestCase.ancestors.include?(Mocha::API)
5
5
 
6
- require 'mocha/integration/test_unit/gem_version_200'
7
- require 'mocha/integration/test_unit/gem_version_201_to_202'
8
- require 'mocha/integration/test_unit/gem_version_203_to_220'
9
- require 'mocha/integration/test_unit/gem_version_230_to_251'
10
- require 'mocha/integration/test_unit/ruby_version_185_and_below'
11
- require 'mocha/integration/test_unit/ruby_version_186_and_above'
6
+ require 'mocha/monkey_patching/test_unit/gem_version_200'
7
+ require 'mocha/monkey_patching/test_unit/gem_version_201_to_202'
8
+ require 'mocha/monkey_patching/test_unit/gem_version_203_to_220'
9
+ require 'mocha/monkey_patching/test_unit/gem_version_230_to_251'
10
+ require 'mocha/monkey_patching/test_unit/ruby_version_185_and_below'
11
+ require 'mocha/monkey_patching/test_unit/ruby_version_186_and_above'
12
12
 
13
13
  module Test
14
14
  module Unit
@@ -33,20 +33,20 @@ if !Test::Unit::TestCase.ancestors.include?(Mocha::API)
33
33
 
34
34
  if (test_unit_version == Gem::Version.new('1.x')) || (test_unit_version == Gem::Version.new('1.2.3'))
35
35
  if RUBY_VERSION < '1.8.6'
36
- include Mocha::Integration::TestUnit::RubyVersion185AndBelow
36
+ include Mocha::MonkeyPatching::TestUnit::RubyVersion185AndBelow
37
37
  else
38
- include Mocha::Integration::TestUnit::RubyVersion186AndAbove
38
+ include Mocha::MonkeyPatching::TestUnit::RubyVersion186AndAbove
39
39
  end
40
40
  elsif Gem::Requirement.new('2.0.0').satisfied_by?(test_unit_version)
41
- include Mocha::Integration::TestUnit::GemVersion200
41
+ include Mocha::MonkeyPatching::TestUnit::GemVersion200
42
42
  elsif Gem::Requirement.new('>= 2.0.1', '<= 2.0.2').satisfied_by?(test_unit_version)
43
- include Mocha::Integration::TestUnit::GemVersion201To202
43
+ include Mocha::MonkeyPatching::TestUnit::GemVersion201To202
44
44
  elsif Gem::Requirement.new('>= 2.0.3', '<= 2.2.0').satisfied_by?(test_unit_version)
45
- include Mocha::Integration::TestUnit::GemVersion203To220
45
+ include Mocha::MonkeyPatching::TestUnit::GemVersion203To220
46
46
  elsif Gem::Requirement.new('>= 2.3.0', '<= 2.5.1').satisfied_by?(test_unit_version)
47
- include Mocha::Integration::TestUnit::GemVersion230To251
47
+ include Mocha::MonkeyPatching::TestUnit::GemVersion230To251
48
48
  else
49
- $stderr.puts "*** No Mocha integration for Test::Unit version ***" if $mocha_options['debug']
49
+ $stderr.puts "*** No Mocha monkey-patch for Test::Unit version ***" if $mocha_options['debug']
50
50
  end
51
51
 
52
52
  end
@@ -1,6 +1,6 @@
1
1
  module Mocha
2
2
 
3
- module Integration
3
+ module MonkeyPatching
4
4
 
5
5
  module TestUnit
6
6
 
@@ -1,10 +1,10 @@
1
1
  require 'test/unit/testcase'
2
- require 'mocha/integration/test_unit/assertion_counter'
2
+ require 'mocha/monkey_patching/test_unit/assertion_counter'
3
3
  require 'mocha/expectation_error'
4
4
 
5
5
  module Mocha
6
6
 
7
- module Integration
7
+ module MonkeyPatching
8
8
 
9
9
  module TestUnit
10
10
 
@@ -1,10 +1,10 @@
1
1
  require 'test/unit/testcase'
2
- require 'mocha/integration/test_unit/assertion_counter'
2
+ require 'mocha/monkey_patching/test_unit/assertion_counter'
3
3
  require 'mocha/expectation_error'
4
4
 
5
5
  module Mocha
6
6
 
7
- module Integration
7
+ module MonkeyPatching
8
8
 
9
9
  module TestUnit
10
10
 
@@ -1,10 +1,10 @@
1
1
  require 'test/unit/testcase'
2
- require 'mocha/integration/test_unit/assertion_counter'
2
+ require 'mocha/monkey_patching/test_unit/assertion_counter'
3
3
  require 'mocha/expectation_error'
4
4
 
5
5
  module Mocha
6
6
 
7
- module Integration
7
+ module MonkeyPatching
8
8
 
9
9
  module TestUnit
10
10
 
@@ -1,10 +1,10 @@
1
1
  require 'test/unit/testcase'
2
- require 'mocha/integration/test_unit/assertion_counter'
2
+ require 'mocha/monkey_patching/test_unit/assertion_counter'
3
3
  require 'mocha/expectation_error'
4
4
 
5
5
  module Mocha
6
6
 
7
- module Integration
7
+ module MonkeyPatching
8
8
 
9
9
  module TestUnit
10
10
 
@@ -1,10 +1,10 @@
1
1
  require 'test/unit/testcase'
2
- require 'mocha/integration/test_unit/assertion_counter'
2
+ require 'mocha/monkey_patching/test_unit/assertion_counter'
3
3
  require 'mocha/expectation_error'
4
4
 
5
5
  module Mocha
6
6
 
7
- module Integration
7
+ module MonkeyPatching
8
8
 
9
9
  module TestUnit
10
10
 
@@ -1,10 +1,10 @@
1
1
  require 'test/unit/testcase'
2
- require 'mocha/integration/test_unit/assertion_counter'
2
+ require 'mocha/monkey_patching/test_unit/assertion_counter'
3
3
  require 'mocha/expectation_error'
4
4
 
5
5
  module Mocha
6
6
 
7
- module Integration
7
+ module MonkeyPatching
8
8
 
9
9
  module TestUnit
10
10
 
@@ -4,6 +4,7 @@ require 'mocha/class_method'
4
4
  require 'mocha/module_method'
5
5
  require 'mocha/any_instance_method'
6
6
  require 'mocha/argument_iterator'
7
+ require 'mocha/expectation_error_factory'
7
8
 
8
9
  module Mocha
9
10
 
@@ -65,7 +66,7 @@ module Mocha
65
66
  # @see Mock#expects
66
67
  def expects(expected_methods_vs_return_values)
67
68
  if expected_methods_vs_return_values.to_s =~ /the[^a-z]*spanish[^a-z]*inquisition/i
68
- raise Mocha::ExpectationError.new('NOBODY EXPECTS THE SPANISH INQUISITION!')
69
+ raise ExpectationErrorFactory.build('NOBODY EXPECTS THE SPANISH INQUISITION!')
69
70
  end
70
71
  if frozen?
71
72
  raise StubbingError.new("can't stub method on frozen object: #{mocha_inspect}", caller)
@@ -1,3 +1,3 @@
1
1
  module Mocha
2
- VERSION = "0.12.1"
2
+ VERSION = "0.12.2"
3
3
  end
@@ -19,7 +19,7 @@ else
19
19
  if defined?(MiniTest)
20
20
 
21
21
  # monkey-patch MiniTest now that it has hopefully been loaded
22
- require 'mocha/integration/mini_test'
22
+ require 'mocha/monkey_patching/mini_test'
23
23
 
24
24
  class MiniTestSampleTest < MiniTest::Unit::TestCase
25
25
 
@@ -1,7 +1,7 @@
1
1
  require 'test/unit/testcase'
2
2
 
3
3
  if defined?(MiniTest)
4
- require 'mocha/integration/mini_test'
4
+ require 'mocha/monkey_patching/mini_test'
5
5
  require File.expand_path('../mini_test_result', __FILE__)
6
6
  else
7
7
  require File.expand_path('../test_unit_result', __FILE__)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mocha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.12.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-19 00:00:00.000000000 Z
12
+ date: 2012-08-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: metaclass
16
- requirement: &70237796907960 !ruby/object:Gem::Requirement
16
+ requirement: &70321302911880 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.0.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70237796907960
24
+ version_requirements: *70321302911880
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70237796906640 !ruby/object:Gem::Requirement
27
+ requirement: &70321302910560 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70237796906640
35
+ version_requirements: *70321302910560
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: introspection
38
- requirement: &70237796906180 !ruby/object:Gem::Requirement
38
+ requirement: &70321302910100 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.0.1
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70237796906180
46
+ version_requirements: *70321302910100
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: yard
49
- requirement: &70237796905800 !ruby/object:Gem::Requirement
49
+ requirement: &70321302909720 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70237796905800
57
+ version_requirements: *70321302909720
58
58
  description: Mocking and stubbing library with JMock/SchMock syntax, which allows
59
59
  mocking and stubbing of methods on real (non-mock) classes.
60
60
  email: mocha-developer@googlegroups.com
@@ -104,37 +104,39 @@ files:
104
104
  - lib/mocha/exception_raiser.rb
105
105
  - lib/mocha/expectation.rb
106
106
  - lib/mocha/expectation_error.rb
107
+ - lib/mocha/expectation_error_factory.rb
107
108
  - lib/mocha/expectation_list.rb
108
109
  - lib/mocha/in_state_ordering_constraint.rb
109
110
  - lib/mocha/inspect.rb
110
111
  - lib/mocha/instance_method.rb
111
- - lib/mocha/integration.rb
112
- - lib/mocha/integration/mini_test.rb
113
- - lib/mocha/integration/mini_test/assertion_counter.rb
114
- - lib/mocha/integration/mini_test/exception_translation.rb
115
- - lib/mocha/integration/mini_test/version_13.rb
116
- - lib/mocha/integration/mini_test/version_140.rb
117
- - lib/mocha/integration/mini_test/version_141.rb
118
- - lib/mocha/integration/mini_test/version_142_to_172.rb
119
- - lib/mocha/integration/mini_test/version_200.rb
120
- - lib/mocha/integration/mini_test/version_201_to_222.rb
121
- - lib/mocha/integration/mini_test/version_2110_to_2111.rb
122
- - lib/mocha/integration/mini_test/version_2112_to_320.rb
123
- - lib/mocha/integration/mini_test/version_230_to_2101.rb
124
- - lib/mocha/integration/test_unit.rb
125
- - lib/mocha/integration/test_unit/assertion_counter.rb
126
- - lib/mocha/integration/test_unit/gem_version_200.rb
127
- - lib/mocha/integration/test_unit/gem_version_201_to_202.rb
128
- - lib/mocha/integration/test_unit/gem_version_203_to_220.rb
129
- - lib/mocha/integration/test_unit/gem_version_230_to_251.rb
130
- - lib/mocha/integration/test_unit/ruby_version_185_and_below.rb
131
- - lib/mocha/integration/test_unit/ruby_version_186_and_above.rb
132
112
  - lib/mocha/is_a.rb
133
113
  - lib/mocha/logger.rb
134
114
  - lib/mocha/method_matcher.rb
135
115
  - lib/mocha/mock.rb
136
116
  - lib/mocha/mockery.rb
137
117
  - lib/mocha/module_method.rb
118
+ - lib/mocha/monkey_patching.rb
119
+ - lib/mocha/monkey_patching/mini_test.rb
120
+ - lib/mocha/monkey_patching/mini_test/assertion_counter.rb
121
+ - lib/mocha/monkey_patching/mini_test/exception_translation.rb
122
+ - lib/mocha/monkey_patching/mini_test/version_13.rb
123
+ - lib/mocha/monkey_patching/mini_test/version_140.rb
124
+ - lib/mocha/monkey_patching/mini_test/version_141.rb
125
+ - lib/mocha/monkey_patching/mini_test/version_142_to_172.rb
126
+ - lib/mocha/monkey_patching/mini_test/version_200.rb
127
+ - lib/mocha/monkey_patching/mini_test/version_201_to_222.rb
128
+ - lib/mocha/monkey_patching/mini_test/version_2110_to_2111.rb
129
+ - lib/mocha/monkey_patching/mini_test/version_2112_to_320.rb
130
+ - lib/mocha/monkey_patching/mini_test/version_230_to_2101.rb
131
+ - lib/mocha/monkey_patching/mini_test/version_330.rb
132
+ - lib/mocha/monkey_patching/test_unit.rb
133
+ - lib/mocha/monkey_patching/test_unit/assertion_counter.rb
134
+ - lib/mocha/monkey_patching/test_unit/gem_version_200.rb
135
+ - lib/mocha/monkey_patching/test_unit/gem_version_201_to_202.rb
136
+ - lib/mocha/monkey_patching/test_unit/gem_version_203_to_220.rb
137
+ - lib/mocha/monkey_patching/test_unit/gem_version_230_to_251.rb
138
+ - lib/mocha/monkey_patching/test_unit/ruby_version_185_and_below.rb
139
+ - lib/mocha/monkey_patching/test_unit/ruby_version_186_and_above.rb
138
140
  - lib/mocha/multiple_yields.rb
139
141
  - lib/mocha/names.rb
140
142
  - lib/mocha/no_yields.rb
@@ -309,7 +311,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
309
311
  version: '0'
310
312
  segments:
311
313
  - 0
312
- hash: 512632440970329998
314
+ hash: 378206207515710598
313
315
  required_rubygems_version: !ruby/object:Gem::Requirement
314
316
  none: false
315
317
  requirements:
@@ -1,59 +0,0 @@
1
- require 'mocha/api'
2
- require 'mocha/options'
3
-
4
- if !MiniTest::Unit::TestCase.ancestors.include?(Mocha::API)
5
-
6
- require 'mocha/integration/mini_test/exception_translation'
7
- require 'mocha/integration/mini_test/version_13'
8
- require 'mocha/integration/mini_test/version_140'
9
- require 'mocha/integration/mini_test/version_141'
10
- require 'mocha/integration/mini_test/version_142_to_172'
11
- require 'mocha/integration/mini_test/version_200'
12
- require 'mocha/integration/mini_test/version_201_to_222'
13
- require 'mocha/integration/mini_test/version_230_to_2101'
14
- require 'mocha/integration/mini_test/version_2110_to_2111'
15
- require 'mocha/integration/mini_test/version_2112_to_320'
16
-
17
- module MiniTest
18
- class Unit
19
- class TestCase
20
-
21
- include Mocha::API
22
-
23
- alias_method :run_before_mocha, :run
24
- remove_method :run
25
-
26
- mini_test_version = begin
27
- Gem::Version.new(MiniTest::Unit::VERSION)
28
- rescue LoadError
29
- Gem::Version.new('0.0.0')
30
- end
31
-
32
- $stderr.puts "Detected MiniTest version: #{mini_test_version}" if $mocha_options['debug']
33
-
34
- if Gem::Requirement.new('>= 1.3.0', '<= 1.3.1').satisfied_by?(mini_test_version)
35
- include Mocha::Integration::MiniTest::Version13
36
- elsif Gem::Requirement.new('1.4.0').satisfied_by?(mini_test_version)
37
- include Mocha::Integration::MiniTest::Version140
38
- elsif Gem::Requirement.new('1.4.1').satisfied_by?(mini_test_version)
39
- include Mocha::Integration::MiniTest::Version141
40
- elsif Gem::Requirement.new('>= 1.4.2', '<= 1.7.2').satisfied_by?(mini_test_version)
41
- include Mocha::Integration::MiniTest::Version142To172
42
- elsif Gem::Requirement.new('2.0.0').satisfied_by?(mini_test_version)
43
- include Mocha::Integration::MiniTest::Version200
44
- elsif Gem::Requirement.new('>= 2.0.1', '<= 2.2.2').satisfied_by?(mini_test_version)
45
- include Mocha::Integration::MiniTest::Version201To222
46
- elsif Gem::Requirement.new('>= 2.3.0', '<= 2.10.1').satisfied_by?(mini_test_version)
47
- include Mocha::Integration::MiniTest::Version230To2101
48
- elsif Gem::Requirement.new('>= 2.11.0', '<= 2.11.1').satisfied_by?(mini_test_version)
49
- include Mocha::Integration::MiniTest::Version2110To2111
50
- elsif Gem::Requirement.new('>= 2.11.2', '<= 3.2.0').satisfied_by?(mini_test_version)
51
- include Mocha::Integration::MiniTest::Version2112To320
52
- else
53
- $stderr.puts "*** No Mocha integration for MiniTest version ***" if $mocha_options['debug']
54
- end
55
-
56
- end
57
- end
58
- end
59
- end