mocha 0.12.0 → 0.12.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.
- data/RELEASE.rdoc +7 -0
- data/Rakefile +2 -2
- data/build-matrix.rb +59 -0
- data/gemfiles/Gemfile.test-unit.2.0.0 +0 -1
- data/lib/mocha/api.rb +0 -8
- data/lib/mocha/integration.rb +4 -2
- data/lib/mocha/integration/test_unit.rb +3 -3
- data/lib/mocha/integration/test_unit/{gem_version_230_to_250.rb → gem_version_230_to_251.rb} +2 -2
- data/lib/mocha/version.rb +1 -1
- data/test/acceptance/api_test.rb +21 -21
- metadata +13 -14
- data/lib/stubba.rb +0 -4
- data/test/acceptance/stubba_test.rb +0 -15
data/RELEASE.rdoc
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
= 0.12.1
|
2
|
+
* Deprecation warning (instead of fail fast) if neither Test::Unit nor MiniTest is loaded. Fixes #88.
|
3
|
+
* Remove deprecated access to `Mocha::Standalone`.
|
4
|
+
* Remove the deprecated file `stubba.rb`.
|
5
|
+
* Officially support test-unit v2.5.1 (still monkey-patching).
|
6
|
+
* Improve the API acceptance test.
|
7
|
+
|
1
8
|
= 0.12.0
|
2
9
|
* Fail fast if neither Test::Unit nor MiniTest is loaded. Fixes #40.
|
3
10
|
* Officially support MiniTest up to v3.2.0 (still monkey-patching).
|
data/Rakefile
CHANGED
@@ -114,8 +114,8 @@ end
|
|
114
114
|
desc "Generate documentation"
|
115
115
|
task 'generate_docs' => ['clobber_yardoc', 'yardoc']
|
116
116
|
|
117
|
-
desc "Publish docs to
|
118
|
-
task 'publish_docs' do
|
117
|
+
desc "Publish docs to gofreerange.com/docs/mocha"
|
118
|
+
task 'publish_docs' => 'generate_docs' do
|
119
119
|
path = "/home/freerange/docs/mocha"
|
120
120
|
system %{ssh gofreerange.com "sudo rm -fr #{path} && mkdir -p #{path}" && scp -r doc/* gofreerange.com:#{path}}
|
121
121
|
end
|
data/build-matrix.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
def execute(*commands)
|
4
|
+
commands.each do |command|
|
5
|
+
system(command)
|
6
|
+
unless $?.success?
|
7
|
+
message = [
|
8
|
+
"Executing shell command failed.",
|
9
|
+
" Command: #{command}",
|
10
|
+
" Status: #{$?.exitstatus}"
|
11
|
+
].join("\n")
|
12
|
+
raise message
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def reset_bundle
|
18
|
+
execute(
|
19
|
+
"rm -rf .bundle/gems",
|
20
|
+
"rm -rf gemfiles/.bundle/gems",
|
21
|
+
"rm -f *.lock",
|
22
|
+
"rm -f gemfiles/*.lock"
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def with_rbenv(command)
|
27
|
+
%{export PATH="$HOME/.rbenv/bin:$PATH"; eval "$(rbenv init -)"; #{command}}
|
28
|
+
end
|
29
|
+
|
30
|
+
def run(gemfile)
|
31
|
+
ENV["BUNDLE_GEMFILE"] = gemfile
|
32
|
+
ENV["MOCHA_OPTIONS"] = "debug"
|
33
|
+
reset_bundle
|
34
|
+
execute(
|
35
|
+
with_rbenv("bundle install --gemfile=#{gemfile}"),
|
36
|
+
with_rbenv("bundle exec rake test")
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
EXCLUDED_RUBY_193_GEMFILES = [
|
41
|
+
"gemfiles/Gemfile.minitest.1.3.0",
|
42
|
+
"gemfiles/Gemfile.minitest.1.4.0",
|
43
|
+
"gemfiles/Gemfile.minitest.1.4.1",
|
44
|
+
"gemfiles/Gemfile.minitest.1.4.2"
|
45
|
+
]
|
46
|
+
|
47
|
+
["1.8.7-p352", "1.9.3-p125-perf"].each do |ruby_version|
|
48
|
+
execute("rbenv local #{ruby_version}")
|
49
|
+
["test-unit", "minitest"].each do |test_library|
|
50
|
+
reset_bundle
|
51
|
+
Dir["gemfiles/Gemfile.#{test_library}.*"].each do |gemfile|
|
52
|
+
ruby_version_without_patch = ruby_version.split("-")[0]
|
53
|
+
next if (ruby_version_without_patch == "1.9.3") && EXCLUDED_RUBY_193_GEMFILES.include?(gemfile)
|
54
|
+
p [ruby_version_without_patch, test_library, gemfile]
|
55
|
+
run(gemfile)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
execute("rbenv local --unset")
|
59
|
+
end
|
data/lib/mocha/api.rb
CHANGED
@@ -176,12 +176,4 @@ module Mocha
|
|
176
176
|
|
177
177
|
end
|
178
178
|
|
179
|
-
# @private
|
180
|
-
def self.const_missing(name)
|
181
|
-
return super unless name == :Standalone
|
182
|
-
require 'mocha/deprecation'
|
183
|
-
Deprecation.warning "Mocha::Standalone has been renamed to Mocha::API"
|
184
|
-
return API
|
185
|
-
end
|
186
|
-
|
187
179
|
end
|
data/lib/mocha/integration.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'mocha/options'
|
2
|
+
require 'mocha/deprecation'
|
2
3
|
|
3
4
|
module Mocha
|
4
5
|
|
@@ -35,8 +36,9 @@ module Mocha
|
|
35
36
|
|
36
37
|
end
|
37
38
|
|
38
|
-
unless Mocha::Integration.monkey_patches.any?
|
39
|
-
|
39
|
+
unless Mocha::Integration.monkey_patches.any?
|
40
|
+
Mocha::Deprecation.warning("Test::Unit or MiniTest must be loaded *before* Mocha.")
|
41
|
+
Mocha::Deprecation.warning("If you're integrating with another test library, you should probably require 'mocha_standalone' instead of 'mocha'")
|
40
42
|
end
|
41
43
|
|
42
44
|
Mocha::Integration.monkey_patches.each do |patch|
|
@@ -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/
|
9
|
+
require 'mocha/integration/test_unit/gem_version_230_to_251'
|
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
|
|
@@ -43,8 +43,8 @@ if !Test::Unit::TestCase.ancestors.include?(Mocha::API)
|
|
43
43
|
include Mocha::Integration::TestUnit::GemVersion201To202
|
44
44
|
elsif Gem::Requirement.new('>= 2.0.3', '<= 2.2.0').satisfied_by?(test_unit_version)
|
45
45
|
include Mocha::Integration::TestUnit::GemVersion203To220
|
46
|
-
elsif Gem::Requirement.new('>= 2.3.0', '<= 2.5.
|
47
|
-
include Mocha::Integration::TestUnit::
|
46
|
+
elsif Gem::Requirement.new('>= 2.3.0', '<= 2.5.1').satisfied_by?(test_unit_version)
|
47
|
+
include Mocha::Integration::TestUnit::GemVersion230To251
|
48
48
|
else
|
49
49
|
$stderr.puts "*** No Mocha integration for Test::Unit version ***" if $mocha_options['debug']
|
50
50
|
end
|
data/lib/mocha/integration/test_unit/{gem_version_230_to_250.rb → gem_version_230_to_251.rb}
RENAMED
@@ -8,9 +8,9 @@ module Mocha
|
|
8
8
|
|
9
9
|
module TestUnit
|
10
10
|
|
11
|
-
module
|
11
|
+
module GemVersion230To251
|
12
12
|
def self.included(mod)
|
13
|
-
$stderr.puts "Monkey patching Test::Unit gem >= v2.3.0 and <= v2.5.
|
13
|
+
$stderr.puts "Monkey patching Test::Unit gem >= v2.3.0 and <= v2.5.1" if $mocha_options['debug']
|
14
14
|
end
|
15
15
|
def run(result)
|
16
16
|
assertion_counter = AssertionCounter.new(result)
|
data/lib/mocha/version.rb
CHANGED
data/test/acceptance/api_test.rb
CHANGED
@@ -44,40 +44,40 @@ end
|
|
44
44
|
|
45
45
|
class SampleTest < NotATestUnitTestCase
|
46
46
|
|
47
|
-
def
|
47
|
+
def mock_object_with_fulfilled_expectation
|
48
48
|
mockee = mock()
|
49
49
|
mockee.expects(:blah)
|
50
50
|
mockee.blah
|
51
51
|
end
|
52
52
|
|
53
|
-
def
|
53
|
+
def mock_object_with_unfulfilled_expectation
|
54
54
|
mockee = mock()
|
55
55
|
mockee.expects(:blah)
|
56
56
|
end
|
57
57
|
|
58
|
-
def
|
58
|
+
def mock_object_with_unexpected_invocation
|
59
59
|
mockee = mock()
|
60
60
|
mockee.blah
|
61
61
|
end
|
62
62
|
|
63
|
-
def
|
63
|
+
def real_object_with_fulfilled_expectation
|
64
64
|
stubbee = Class.new { define_method(:blah) {} }.new
|
65
65
|
stubbee.expects(:blah)
|
66
66
|
stubbee.blah
|
67
67
|
end
|
68
68
|
|
69
|
-
def
|
69
|
+
def real_object_with_unfulfilled_expectation
|
70
70
|
stubbee = Class.new { define_method(:blah) {} }.new
|
71
71
|
stubbee.expects(:blah)
|
72
72
|
end
|
73
73
|
|
74
|
-
def
|
74
|
+
def mock_object_with_matching_parameter
|
75
75
|
mockee = mock()
|
76
76
|
mockee.expects(:blah).with(has_key(:wibble))
|
77
77
|
mockee.blah(:wibble => 1)
|
78
78
|
end
|
79
79
|
|
80
|
-
def
|
80
|
+
def mock_object_with_non_matching_parameter
|
81
81
|
mockee = mock()
|
82
82
|
mockee.expects(:blah).with(has_key(:wibble))
|
83
83
|
mockee.blah(:wobble => 2)
|
@@ -102,38 +102,38 @@ class APITest < Test::Unit::TestCase
|
|
102
102
|
teardown_acceptance_test
|
103
103
|
end
|
104
104
|
|
105
|
-
def
|
106
|
-
assert_nothing_raised { sample_test.run(:
|
105
|
+
def test_should_pass_mock_object_test
|
106
|
+
assert_nothing_raised { sample_test.run(:mock_object_with_fulfilled_expectation) }
|
107
107
|
assert_equal 1, sample_test.assertion_counter.count
|
108
108
|
end
|
109
109
|
|
110
|
-
def
|
111
|
-
assert_raises(NotATestUnitAssertionFailedError) { sample_test.run(:
|
110
|
+
def test_should_fail_mock_object_test_due_to_unfulfilled_exception
|
111
|
+
assert_raises(NotATestUnitAssertionFailedError) { sample_test.run(:mock_object_with_unfulfilled_expectation) }
|
112
112
|
assert_equal 1, sample_test.assertion_counter.count
|
113
113
|
end
|
114
114
|
|
115
|
-
def
|
116
|
-
assert_raises(NotATestUnitAssertionFailedError) { sample_test.run(:
|
115
|
+
def test_should_fail_mock_object_test_due_to_unexpected_invocation
|
116
|
+
assert_raises(NotATestUnitAssertionFailedError) { sample_test.run(:mock_object_with_unexpected_invocation) }
|
117
117
|
assert_equal 0, sample_test.assertion_counter.count
|
118
118
|
end
|
119
119
|
|
120
|
-
def
|
121
|
-
assert_nothing_raised { sample_test.run(:
|
120
|
+
def test_should_pass_real_object_test
|
121
|
+
assert_nothing_raised { sample_test.run(:real_object_with_fulfilled_expectation) }
|
122
122
|
assert_equal 1, sample_test.assertion_counter.count
|
123
123
|
end
|
124
124
|
|
125
|
-
def
|
126
|
-
assert_raises(NotATestUnitAssertionFailedError) { sample_test.run(:
|
125
|
+
def test_should_fail_real_object_test
|
126
|
+
assert_raises(NotATestUnitAssertionFailedError) { sample_test.run(:real_object_with_unfulfilled_expectation) }
|
127
127
|
assert_equal 1, sample_test.assertion_counter.count
|
128
128
|
end
|
129
129
|
|
130
|
-
def
|
131
|
-
assert_nothing_raised { sample_test.run(:
|
130
|
+
def test_should_pass_mock_object_test_with_matching_parameter
|
131
|
+
assert_nothing_raised { sample_test.run(:mock_object_with_matching_parameter) }
|
132
132
|
assert_equal 1, sample_test.assertion_counter.count
|
133
133
|
end
|
134
134
|
|
135
|
-
def
|
136
|
-
assert_raises(NotATestUnitAssertionFailedError) { sample_test.run(:
|
135
|
+
def test_should_fail_mock_object_test_with_non_matching_parameter
|
136
|
+
assert_raises(NotATestUnitAssertionFailedError) { sample_test.run(:mock_object_with_non_matching_parameter) }
|
137
137
|
end
|
138
138
|
|
139
139
|
end
|
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.
|
4
|
+
version: 0.12.1
|
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-
|
12
|
+
date: 2012-07-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: metaclass
|
16
|
-
requirement: &
|
16
|
+
requirement: &70237796907960 !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: *
|
24
|
+
version_requirements: *70237796907960
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70237796906640 !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: *
|
35
|
+
version_requirements: *70237796906640
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: introspection
|
38
|
-
requirement: &
|
38
|
+
requirement: &70237796906180 !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: *
|
46
|
+
version_requirements: *70237796906180
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: yard
|
49
|
-
requirement: &
|
49
|
+
requirement: &70237796905800 !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: *
|
57
|
+
version_requirements: *70237796905800
|
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
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- README.rdoc
|
72
72
|
- RELEASE.rdoc
|
73
73
|
- Rakefile
|
74
|
+
- build-matrix.rb
|
74
75
|
- examples/misc.rb
|
75
76
|
- examples/mocha.rb
|
76
77
|
- examples/stubba.rb
|
@@ -125,7 +126,7 @@ files:
|
|
125
126
|
- lib/mocha/integration/test_unit/gem_version_200.rb
|
126
127
|
- lib/mocha/integration/test_unit/gem_version_201_to_202.rb
|
127
128
|
- lib/mocha/integration/test_unit/gem_version_203_to_220.rb
|
128
|
-
- lib/mocha/integration/test_unit/
|
129
|
+
- lib/mocha/integration/test_unit/gem_version_230_to_251.rb
|
129
130
|
- lib/mocha/integration/test_unit/ruby_version_185_and_below.rb
|
130
131
|
- lib/mocha/integration/test_unit/ruby_version_186_and_above.rb
|
131
132
|
- lib/mocha/is_a.rb
|
@@ -175,7 +176,6 @@ files:
|
|
175
176
|
- lib/mocha/version.rb
|
176
177
|
- lib/mocha/yield_parameters.rb
|
177
178
|
- lib/mocha_standalone.rb
|
178
|
-
- lib/stubba.rb
|
179
179
|
- mocha.gemspec
|
180
180
|
- test/acceptance/acceptance_test_helper.rb
|
181
181
|
- test/acceptance/api_test.rb
|
@@ -219,7 +219,6 @@ files:
|
|
219
219
|
- test/acceptance/stub_module_method_test.rb
|
220
220
|
- test/acceptance/stub_test.rb
|
221
221
|
- test/acceptance/stubba_example_test.rb
|
222
|
-
- test/acceptance/stubba_test.rb
|
223
222
|
- test/acceptance/stubba_test_result_test.rb
|
224
223
|
- test/acceptance/stubbing_error_backtrace_test.rb
|
225
224
|
- test/acceptance/stubbing_frozen_object_test.rb
|
@@ -310,7 +309,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
310
309
|
version: '0'
|
311
310
|
segments:
|
312
311
|
- 0
|
313
|
-
hash:
|
312
|
+
hash: 512632440970329998
|
314
313
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
315
314
|
none: false
|
316
315
|
requirements:
|
data/lib/stubba.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
require 'deprecation_disabler'
|
3
|
-
|
4
|
-
class StubbaTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
include DeprecationDisabler
|
7
|
-
|
8
|
-
def test_should_report_deprecation_of_stubba_which_will_be_removed_in_a_future_release
|
9
|
-
disable_deprecations do
|
10
|
-
load 'stubba.rb'
|
11
|
-
end
|
12
|
-
assert Mocha::Deprecation.messages.include?("require 'stubba' is no longer needed and stubba.rb will soon be removed")
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|