mocha 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,12 +12,26 @@ Mocha was harvested from projects at {Reevoo}[http://www.reevoo.com/] by me ({Ja
12
12
 
13
13
  https://secure.travis-ci.org/floehopper/mocha.png
14
14
 
15
- == Download and Installation
15
+ == Installation
16
16
 
17
- Install the gem with the following command...
17
+ Install the latest version of the gem with the following command...
18
18
 
19
19
  $ gem install mocha
20
20
 
21
+ Note that if you are intending to use Mocha with Test::Unit or MiniTest, you should only load Mocha *after* loading the relevant test library...
22
+
23
+ require "test/unit"
24
+ require "mocha"
25
+
26
+ If you're using Bundler, ensure the correct load order by not auto-requiring Mocha in the Gemfile and then later load it once you know the test library has been loaded...
27
+
28
+ # Gemfile
29
+ gem "mocha", :require => false
30
+
31
+ # Elsewhere after Bundler has loaded gems
32
+ require "test/unit"
33
+ require "mocha"
34
+
21
35
  Or install the {Rails}[http://www.rubyonrails.org/] plugin...
22
36
 
23
37
  $ script/plugin install git://github.com/floehopper/mocha.git
@@ -40,4 +54,4 @@ Or download Mocha...
40
54
 
41
55
  Copyright Revieworld Ltd. 2006
42
56
 
43
- You may use, copy and redistribute this library under the same terms as {Ruby itself}[http://www.ruby-lang.org/en/LICENSE.txt] or under the {MIT license}[http://mocha.rubyforge.org/files/MIT-LICENSE.html].
57
+ You may use, copy and redistribute this library under the same terms as {Ruby itself}[http://www.ruby-lang.org/en/LICENSE.txt] or under the {MIT license}[http://mocha.rubyforge.org/files/MIT-LICENSE.html].
@@ -1,4 +1,14 @@
1
- = 0.10.0 ()
1
+ = 0.10.1 ()
2
+ * Merge pull request #51 from meineerde/issues/50-minitest-2.10.0. Use Gem::Requirement & Gem::Version for version comparison. Fixes issue #50. Thanks to meineerde.
3
+ * Fixed typo in rdoc for Mocha::ObjectMethods.
4
+ * Improve README as suggested in issue #46. Explain that Mocha must be loaded after test libraries and how to achieve this using Bundler.
5
+ * Merge pull request #43 - nobody expects the spanish inquisition! Thanks to cairo140.
6
+ * Fix for issue #39 - improve documentation for Expectation#multiple_yields.
7
+ * Fix for issue #38 where a subtle change in test-unit v2.3.0 had been missed - only visible in verbose mode.
8
+ * Support for MiniTest up to v2.6.2 has been verified.
9
+ * Add explicit development dependency on coderay for generating syntax-highlighted code examples.
10
+
11
+ = 0.10.0 (68a4a59e1af74baf3929af418f73f5627bba548d)
2
12
  * Add Expectation#throws to allow a stubbed method to use Kernel#throw.
3
13
  * Updates for versions of Test::Unit up to and including v2.3.3 (including patch by Jens Fahnenbruck).
4
14
  * Updates for versions of MiniTest up to and including v2.5.1.
@@ -230,6 +230,9 @@ module Mocha # :nodoc:
230
230
  # :call-seq: multiple_yields(*parameter_groups) -> expectation
231
231
  #
232
232
  # Modifies expectation so that when the expected method is called, it yields multiple times per invocation with the specified +parameter_groups+.
233
+ #
234
+ # Note that each +parameter_group+ should be an Array representing the parameters to be passed to the block for a single yield. In the following example when the expected_method is called, the stub will invoke the block twice, the first time it passes 'result_1', 'result_2' as the parameters, and the second time it passes 'result_3' as the parameters.
235
+ #
233
236
  # object = mock()
234
237
  # object.expects(:expected_method).multiple_yields(['result_1', 'result_2'], ['result_3'])
235
238
  # yielded_values = []
@@ -10,7 +10,7 @@ if !MiniTest::Unit::TestCase.ancestors.include?(Mocha::API)
10
10
  require 'mocha/integration/mini_test/version_142_to_172'
11
11
  require 'mocha/integration/mini_test/version_200'
12
12
  require 'mocha/integration/mini_test/version_201_to_222'
13
- require 'mocha/integration/mini_test/version_230_to_251'
13
+ require 'mocha/integration/mini_test/version_230_to_262'
14
14
 
15
15
  module MiniTest
16
16
  class Unit
@@ -22,30 +22,28 @@ if !MiniTest::Unit::TestCase.ancestors.include?(Mocha::API)
22
22
  remove_method :run
23
23
 
24
24
  mini_test_version = begin
25
- MiniTest::Unit::VERSION
25
+ Gem::Version.new(MiniTest::Unit::VERSION)
26
26
  rescue LoadError
27
- 'unknown'
27
+ Gem::Version.new('0.0.0')
28
28
  end
29
29
 
30
30
  $stderr.puts "Detected MiniTest version: #{mini_test_version}" if $options['debug']
31
31
 
32
- if (mini_test_version >= '1.3.0') && (mini_test_version <= '1.3.1')
32
+ if Gem::Requirement.new('>= 1.3.0', '<= 1.3.1') =~ mini_test_version
33
33
  include Mocha::Integration::MiniTest::Version13
34
- elsif (mini_test_version == '1.4.0')
34
+ elsif Gem::Requirement.new('1.4.0') =~ mini_test_version
35
35
  include Mocha::Integration::MiniTest::Version140
36
- elsif (mini_test_version == '1.4.1')
36
+ elsif Gem::Requirement.new('1.4.1') =~ mini_test_version
37
37
  include Mocha::Integration::MiniTest::Version141
38
- elsif (mini_test_version >= '1.4.2') && (mini_test_version <= '1.7.2')
38
+ elsif Gem::Requirement.new('>= 1.4.2', '<= 1.7.2') =~ mini_test_version
39
39
  include Mocha::Integration::MiniTest::Version142To172
40
- elsif (mini_test_version == '2.0.0')
40
+ elsif Gem::Requirement.new('2.0.0') =~ mini_test_version
41
41
  include Mocha::Integration::MiniTest::Version200
42
- elsif (mini_test_version >= '2.0.1') && (mini_test_version <= '2.2.2')
42
+ elsif Gem::Requirement.new('>= 2.0.1', '<= 2.2.2') =~ mini_test_version
43
43
  include Mocha::Integration::MiniTest::Version201To222
44
- elsif (mini_test_version >= '2.3.0') && (mini_test_version <= '2.5.1')
45
- include Mocha::Integration::MiniTest::Version230To251
46
- elsif (mini_test_version > '2.5.1')
47
- $stderr.puts "*** MiniTest integration has not been verified but patching anyway ***" if $options['debug']
48
- include Mocha::Integration::MiniTest::Version230To251
44
+ elsif Gem::Requirement.new('>= 2.3.0') =~ mini_test_version
45
+ $stderr.puts "*** MiniTest integration has not been verified but patching anyway ***" if (Gem::Requirement.new('> 2.6.2') =~ mini_test_version) && $options['debug']
46
+ include Mocha::Integration::MiniTest::Version230To262
49
47
  else
50
48
  $stderr.puts "*** No Mocha integration for MiniTest version ***" if $options['debug']
51
49
  end
@@ -7,9 +7,9 @@ module Mocha
7
7
 
8
8
  module MiniTest
9
9
 
10
- module Version230To251
10
+ module Version230To262
11
11
  def self.included(mod)
12
- $stderr.puts "Monkey patching MiniTest >= v2.3.0 <= v2.5.1" if $options['debug']
12
+ $stderr.puts "Monkey patching MiniTest >= v2.3.0 <= v2.6.2" if $options['debug']
13
13
  end
14
14
  def run runner
15
15
  trap 'INFO' do
@@ -6,7 +6,7 @@ if !Test::Unit::TestCase.ancestors.include?(Mocha::API)
6
6
  require 'mocha/integration/test_unit/gem_version_200'
7
7
  require 'mocha/integration/test_unit/gem_version_201_to_202'
8
8
  require 'mocha/integration/test_unit/gem_version_203_to_220'
9
- require 'mocha/integration/test_unit/gem_version_230_to_233'
9
+ require 'mocha/integration/test_unit/gem_version_230_to_240'
10
10
  require 'mocha/integration/test_unit/ruby_version_185_and_below'
11
11
  require 'mocha/integration/test_unit/ruby_version_186_and_above'
12
12
 
@@ -21,9 +21,9 @@ if !Test::Unit::TestCase.ancestors.include?(Mocha::API)
21
21
 
22
22
  test_unit_version = begin
23
23
  load 'test/unit/version.rb'
24
- Test::Unit::VERSION
24
+ Gem::Version.new(Test::Unit::VERSION)
25
25
  rescue LoadError
26
- '1.x'
26
+ Gem::Version.new('1.x')
27
27
  end
28
28
 
29
29
  if $options['debug']
@@ -31,23 +31,21 @@ if !Test::Unit::TestCase.ancestors.include?(Mocha::API)
31
31
  $stderr.puts "Detected Test::Unit version: #{test_unit_version}"
32
32
  end
33
33
 
34
- if (test_unit_version == '1.x') || (test_unit_version == '1.2.3')
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
36
  include Mocha::Integration::TestUnit::RubyVersion185AndBelow
37
37
  else
38
38
  include Mocha::Integration::TestUnit::RubyVersion186AndAbove
39
39
  end
40
- elsif (test_unit_version == '2.0.0')
40
+ elsif Gem::Requirement.new('2.0.0') =~ test_unit_version
41
41
  include Mocha::Integration::TestUnit::GemVersion200
42
- elsif (test_unit_version >= '2.0.1') && (test_unit_version <= '2.0.2')
42
+ elsif Gem::Requirement.new('>= 2.0.1', '<= 2.0.2') =~ test_unit_version
43
43
  include Mocha::Integration::TestUnit::GemVersion201To202
44
- elsif (test_unit_version >= '2.0.3') && (test_unit_version <= '2.2.0')
44
+ elsif Gem::Requirement.new('>= 2.0.3', '<= 2.2.0') =~ test_unit_version
45
45
  include Mocha::Integration::TestUnit::GemVersion203To220
46
- elsif (test_unit_version >= '2.3.0') && (test_unit_version <= '2.3.3')
47
- include Mocha::Integration::TestUnit::GemVersion230To233
48
- elsif (test_unit_version > '2.3.3')
49
- $stderr.puts "*** Test::Unit integration has not been verified but patching anyway ***" if $options['debug']
50
- include Mocha::Integration::TestUnit::GemVersion230To233
46
+ elsif Gem::Requirement.new('>= 2.3.0') =~ test_unit_version
47
+ $stderr.puts "*** Test::Unit integration has not been verified but patching anyway ***" if (Gem::Requirement.new('> 2.4.0') =~ test_unit_version) && $options['debug']
48
+ include Mocha::Integration::TestUnit::GemVersion230To240
51
49
  else
52
50
  $stderr.puts "*** No Mocha integration for Test::Unit version ***" if $options['debug']
53
51
  end
@@ -8,9 +8,9 @@ module Mocha
8
8
 
9
9
  module TestUnit
10
10
 
11
- module GemVersion230To233
11
+ module GemVersion230To240
12
12
  def self.included(mod)
13
- $stderr.puts "Monkey patching Test::Unit gem >= v2.3.0 and <= v2.3.3" if $options['debug']
13
+ $stderr.puts "Monkey patching Test::Unit gem >= v2.3.0 and <= v2.4.0" if $options['debug']
14
14
  end
15
15
  def run(result)
16
16
  assertion_counter = AssertionCounter.new(result)
@@ -18,7 +18,7 @@ module Mocha
18
18
  @internal_data.test_started
19
19
  @_result = result
20
20
  yield(Test::Unit::TestCase::STARTED, name)
21
- yield(Test::Unit::TestCase::STARTED_OBJECT, name)
21
+ yield(Test::Unit::TestCase::STARTED_OBJECT, self)
22
22
  begin
23
23
  begin
24
24
  run_setup
@@ -44,7 +44,7 @@ module Mocha
44
44
  @internal_data.test_finished
45
45
  result.add_run
46
46
  yield(Test::Unit::TestCase::FINISHED, name)
47
- yield(Test::Unit::TestCase::FINISHED_OBJECT, name)
47
+ yield(Test::Unit::TestCase::FINISHED_OBJECT, self)
48
48
  ensure
49
49
  # @_result = nil # For test-spec's after_all :<
50
50
  end
@@ -7,7 +7,7 @@ require 'mocha/argument_iterator'
7
7
 
8
8
  module Mocha
9
9
 
10
- # Methods added all objects to allow mocking and stubbing on real objects.
10
+ # Methods added to all objects to allow mocking and stubbing on real objects.
11
11
  #
12
12
  # Methods return a Mocha::Expectation which can be further modified by methods on Mocha::Expectation.
13
13
  module ObjectMethods
@@ -51,6 +51,9 @@ module Mocha
51
51
  # product.expects(:valid?).returns(true)
52
52
  # product.expects(:save).returns(true)
53
53
  def expects(method_name_or_hash)
54
+ if method_name_or_hash.to_s =~ /the[^a-z]*spanish[^a-z]*inquisition/i
55
+ raise Mocha::ExpectationError.new('NOBODY EXPECTS THE SPANISH INQUISITION!')
56
+ end
54
57
  expectation = nil
55
58
  mockery = Mocha::Mockery.instance
56
59
  iterator = ArgumentIterator.new(method_name_or_hash)
@@ -1,3 +1,3 @@
1
1
  module Mocha
2
- VERSION = "0.10.0"
2
+ VERSION = "0.10.1"
3
3
  end
@@ -29,15 +29,18 @@ Gem::Specification.new do |s|
29
29
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
30
30
  s.add_development_dependency("rake", ">= 0")
31
31
  s.add_development_dependency("introspection", "~> 0.0.1")
32
- s.add_development_dependency("rdoc", "~> 2.4.2")
32
+ s.add_development_dependency("rdoc", "~> 3.1")
33
+ s.add_development_dependency("coderay", "~> 0.1")
33
34
  else
34
35
  s.add_dependency("rake", ">= 0")
35
36
  s.add_dependency("introspection", "~> 0.0.1")
36
- s.add_dependency("rdoc", "~> 2.4.2")
37
+ s.add_dependency("rdoc", "~> 3.1")
38
+ s.add_dependency("coderay", "~> 0.1")
37
39
  end
38
40
  else
39
41
  s.add_dependency("rake", ">= 0")
40
42
  s.add_dependency("introspection", "~> 0.0.1")
41
- s.add_dependency("rdoc", "~> 2.4.2")
43
+ s.add_dependency("rdoc", "~> 3.1")
44
+ s.add_dependency("coderay", "~> 0.1")
42
45
  end
43
46
  end
@@ -78,5 +78,10 @@ class ObjectTest < Test::Unit::TestCase
78
78
  any_instance = Class::AnyInstance.new(klass)
79
79
  assert_equal klass, any_instance.stubba_object
80
80
  end
81
+
82
+ def test_nobody_expects_the_spanish_inquisition
83
+ object = Object.new
84
+ assert_raise(Mocha::ExpectationError) { object.expects(:the_spanish_inquisition) }
85
+ end
81
86
 
82
- end
87
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mocha
3
3
  version: !ruby/object:Gem::Version
4
- hash: 55
4
+ hash: 53
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 10
9
- - 0
10
- version: 0.10.0
9
+ - 1
10
+ version: 0.10.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Mead
@@ -15,10 +15,12 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-05 00:00:00 Z
18
+ date: 2012-01-16 00:00:00 +00:00
19
+ default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
- version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
22
24
  none: false
23
25
  requirements:
24
26
  - - ~>
@@ -29,12 +31,12 @@ dependencies:
29
31
  - 0
30
32
  - 1
31
33
  version: 0.0.1
32
- requirement: *id001
33
34
  type: :runtime
34
35
  name: metaclass
35
- prerelease: false
36
+ version_requirements: *id001
36
37
  - !ruby/object:Gem::Dependency
37
- version_requirements: &id002 !ruby/object:Gem::Requirement
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
38
40
  none: false
39
41
  requirements:
40
42
  - - ">="
@@ -43,12 +45,12 @@ dependencies:
43
45
  segments:
44
46
  - 0
45
47
  version: "0"
46
- requirement: *id002
47
48
  type: :development
48
49
  name: rake
49
- prerelease: false
50
+ version_requirements: *id002
50
51
  - !ruby/object:Gem::Dependency
51
- version_requirements: &id003 !ruby/object:Gem::Requirement
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
52
54
  none: false
53
55
  requirements:
54
56
  - - ~>
@@ -59,26 +61,39 @@ dependencies:
59
61
  - 0
60
62
  - 1
61
63
  version: 0.0.1
62
- requirement: *id003
63
64
  type: :development
64
65
  name: introspection
65
- prerelease: false
66
+ version_requirements: *id003
66
67
  - !ruby/object:Gem::Dependency
67
- version_requirements: &id004 !ruby/object:Gem::Requirement
68
+ prerelease: false
69
+ requirement: &id004 !ruby/object:Gem::Requirement
68
70
  none: false
69
71
  requirements:
70
72
  - - ~>
71
73
  - !ruby/object:Gem::Version
72
- hash: 27
74
+ hash: 5
73
75
  segments:
74
- - 2
75
- - 4
76
- - 2
77
- version: 2.4.2
78
- requirement: *id004
76
+ - 3
77
+ - 1
78
+ version: "3.1"
79
79
  type: :development
80
80
  name: rdoc
81
+ version_requirements: *id004
82
+ - !ruby/object:Gem::Dependency
81
83
  prerelease: false
84
+ requirement: &id005 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ hash: 9
90
+ segments:
91
+ - 0
92
+ - 1
93
+ version: "0.1"
94
+ type: :development
95
+ name: coderay
96
+ version_requirements: *id005
82
97
  description: Mocking and stubbing library with JMock/SchMock syntax, which allows mocking and stubbing of methods on real (non-mock) classes.
83
98
  email: mocha-developer@googlegroups.com
84
99
  executables: []
@@ -140,13 +155,13 @@ files:
140
155
  - lib/mocha/integration/mini_test/version_142_to_172.rb
141
156
  - lib/mocha/integration/mini_test/version_200.rb
142
157
  - lib/mocha/integration/mini_test/version_201_to_222.rb
143
- - lib/mocha/integration/mini_test/version_230_to_251.rb
158
+ - lib/mocha/integration/mini_test/version_230_to_262.rb
144
159
  - lib/mocha/integration/test_unit.rb
145
160
  - lib/mocha/integration/test_unit/assertion_counter.rb
146
161
  - lib/mocha/integration/test_unit/gem_version_200.rb
147
162
  - lib/mocha/integration/test_unit/gem_version_201_to_202.rb
148
163
  - lib/mocha/integration/test_unit/gem_version_203_to_220.rb
149
- - lib/mocha/integration/test_unit/gem_version_230_to_233.rb
164
+ - lib/mocha/integration/test_unit/gem_version_230_to_240.rb
150
165
  - lib/mocha/integration/test_unit/ruby_version_185_and_below.rb
151
166
  - lib/mocha/integration/test_unit/ruby_version_186_and_above.rb
152
167
  - lib/mocha/is_a.rb
@@ -305,6 +320,7 @@ files:
305
320
  - test/unit/string_inspect_test.rb
306
321
  - test/unit/thrower_test.rb
307
322
  - test/unit/yield_parameters_test.rb
323
+ has_rdoc: true
308
324
  homepage: http://mocha.rubyforge.org
309
325
  licenses: []
310
326
 
@@ -338,7 +354,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
338
354
  requirements: []
339
355
 
340
356
  rubyforge_project: mocha
341
- rubygems_version: 1.8.8
357
+ rubygems_version: 1.6.2
342
358
  signing_key:
343
359
  specification_version: 3
344
360
  summary: Mocking and stubbing library