bourne 1.3.0 → 1.3.2
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/.travis.yml +2 -0
- data/LICENSE +1 -1
- data/NEWS.md +3 -0
- data/README.md +1 -1
- data/bourne.gemspec +1 -1
- data/lib/bourne/mock.rb +1 -1
- data/lib/bourne/version.rb +1 -1
- data/test/unit/mock_test.rb +45 -16
- metadata +4 -4
data/.travis.yml
CHANGED
data/LICENSE
CHANGED
data/NEWS.md
CHANGED
data/README.md
CHANGED
@@ -73,4 +73,4 @@ The names and logos for thoughtbot are trademarks of thoughtbot, inc.
|
|
73
73
|
License
|
74
74
|
-------
|
75
75
|
|
76
|
-
Bourne is Copyright © 2010-
|
76
|
+
Bourne is Copyright © 2010-2013 Joe Ferris and thoughtbot. It is free software, and may be redistributed under the terms specified in the LICENSE file.
|
data/bourne.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
21
|
s.require_paths = ["lib"]
|
22
22
|
|
23
|
-
s.add_dependency('mocha', '0.13.
|
23
|
+
s.add_dependency('mocha', '0.13.2') # follow instructions in mock.rb to update
|
24
24
|
|
25
25
|
s.add_development_dependency('rake')
|
26
26
|
end
|
data/lib/bourne/mock.rb
CHANGED
@@ -6,7 +6,7 @@ module Mocha # :nodoc:
|
|
6
6
|
# Overwrites #method_missing on Mocha::Mock
|
7
7
|
# - pass arguments to .invoke() calls to create Invocation
|
8
8
|
# - keep lowest else branch (bourne code)
|
9
|
-
# - update from https://github.com/freerange/mocha/blob/master/lib/mocha/mock.rb#
|
9
|
+
# - update from https://github.com/freerange/mocha/blob/master/lib/mocha/mock.rb#L227
|
10
10
|
# - update test/unit/mock_test.rb
|
11
11
|
class Mock # :nodoc:
|
12
12
|
def method_missing(symbol, *arguments, &block)
|
data/lib/bourne/version.rb
CHANGED
data/test/unit/mock_test.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# - keep: FakeExpectation test
|
5
5
|
require File.expand_path('../../test_helper', __FILE__)
|
6
6
|
require 'bourne/mock'
|
7
|
-
require 'mocha/
|
7
|
+
require 'mocha/expectation_error_factory'
|
8
8
|
require 'set'
|
9
9
|
require 'simple_counter'
|
10
10
|
|
@@ -13,18 +13,18 @@ class MockTest < Test::Unit::TestCase
|
|
13
13
|
include Mocha
|
14
14
|
|
15
15
|
def test_should_set_single_expectation
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
mock = build_mock
|
17
|
+
mock.expects(:method1).returns(1)
|
18
|
+
assert_nothing_raised(ExpectationErrorFactory.exception_class) do
|
19
|
+
assert_equal 1, mock.method1
|
20
|
+
end
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_should_build_and_store_expectations
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
mock = build_mock
|
25
|
+
expectation = mock.expects(:method1)
|
26
|
+
assert_not_nil expectation
|
27
|
+
assert_equal [expectation], mock.__expectations__.to_a
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_should_not_stub_everything_by_default
|
@@ -40,7 +40,7 @@ class MockTest < Test::Unit::TestCase
|
|
40
40
|
|
41
41
|
def test_should_be_able_to_extend_mock_object_with_module
|
42
42
|
mock = build_mock
|
43
|
-
assert_nothing_raised(
|
43
|
+
assert_nothing_raised(ExpectationErrorFactory.exception_class) { mock.extend(Module.new) }
|
44
44
|
end
|
45
45
|
|
46
46
|
def test_should_be_equal
|
@@ -106,7 +106,7 @@ class MockTest < Test::Unit::TestCase
|
|
106
106
|
mock = build_mock
|
107
107
|
mock.stub_everything
|
108
108
|
result = nil
|
109
|
-
assert_nothing_raised(
|
109
|
+
assert_nothing_raised(ExpectationErrorFactory.exception_class) do
|
110
110
|
result = mock.unexpected_method
|
111
111
|
end
|
112
112
|
assert_nil result
|
@@ -114,7 +114,7 @@ class MockTest < Test::Unit::TestCase
|
|
114
114
|
|
115
115
|
def test_should_raise_assertion_error_for_unexpected_method_call
|
116
116
|
mock = build_mock
|
117
|
-
error = assert_raise(
|
117
|
+
error = assert_raise(ExpectationErrorFactory.exception_class) do
|
118
118
|
mock.unexpected_method_called(:my_method, :argument1, :argument2)
|
119
119
|
end
|
120
120
|
assert_match(/unexpected invocation/, error.message)
|
@@ -218,6 +218,12 @@ class MockTest < Test::Unit::TestCase
|
|
218
218
|
assert_equal true, mock.respond_to?(:method1)
|
219
219
|
end
|
220
220
|
|
221
|
+
def test_should_respond_to_expected_method_as_string
|
222
|
+
mock = build_mock
|
223
|
+
mock.expects(:method1)
|
224
|
+
assert_equal true, mock.respond_to?('method1')
|
225
|
+
end
|
226
|
+
|
221
227
|
def test_should_not_respond_to_unexpected_method
|
222
228
|
mock = build_mock
|
223
229
|
assert_equal false, mock.respond_to?(:method1)
|
@@ -241,11 +247,34 @@ class MockTest < Test::Unit::TestCase
|
|
241
247
|
assert_equal false, mock.respond_to?(:invoked_method)
|
242
248
|
end
|
243
249
|
|
244
|
-
def
|
250
|
+
def test_should_respond_to_methods_which_the_responder_instance_does_responds_to
|
251
|
+
klass = Class.new do
|
252
|
+
define_method(:respond_to?) { |symbol| true }
|
253
|
+
end
|
254
|
+
mock = build_mock
|
255
|
+
mock.responds_like_instance_of(klass)
|
256
|
+
assert_equal true, mock.respond_to?(:invoked_method)
|
257
|
+
end
|
258
|
+
|
259
|
+
def test_should_not_respond_to_methods_which_the_responder_instance_does_not_responds_to
|
260
|
+
klass = Class.new do
|
261
|
+
define_method(:respond_to?) { |symbol| false }
|
262
|
+
end
|
263
|
+
mock = build_mock
|
264
|
+
mock.responds_like_instance_of(klass)
|
265
|
+
assert_equal false, mock.respond_to?(:invoked_method)
|
266
|
+
end
|
267
|
+
|
268
|
+
def test_respond_like_should_return_itself_to_allow_method_chaining
|
245
269
|
mock = build_mock
|
246
270
|
assert_same mock.responds_like(Object.new), mock
|
247
271
|
end
|
248
272
|
|
273
|
+
def test_respond_like_instance_of_should_return_itself_to_allow_method_chaining
|
274
|
+
mock = build_mock
|
275
|
+
assert_same mock.responds_like_instance_of(Object), mock
|
276
|
+
end
|
277
|
+
|
249
278
|
def test_should_not_raise_no_method_error_if_mock_is_not_restricted_to_respond_like_a_responder
|
250
279
|
mock = build_mock
|
251
280
|
mock.stubs(:invoked_method)
|
@@ -290,7 +319,7 @@ class MockTest < Test::Unit::TestCase
|
|
290
319
|
|
291
320
|
def test_should_handle_respond_to_with_private_methods_param_without_error
|
292
321
|
mock = build_mock
|
293
|
-
assert_nothing_raised{ mock.respond_to?(:object_id, false) }
|
322
|
+
assert_nothing_raised { mock.respond_to?(:object_id, false) }
|
294
323
|
end
|
295
324
|
|
296
325
|
def test_should_respond_to_any_method_if_stubbing_everything
|
@@ -304,7 +333,7 @@ class MockTest < Test::Unit::TestCase
|
|
304
333
|
mock = build_mock
|
305
334
|
mock.expects(:method1)
|
306
335
|
mock.unstub(:method1)
|
307
|
-
e = assert_raises(
|
336
|
+
e = assert_raises(ExpectationErrorFactory.exception_class) { mock.method1 }
|
308
337
|
assert_match(/unexpected invocation/, e.message)
|
309
338
|
end
|
310
339
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bourne
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mocha
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.13.
|
21
|
+
version: 0.13.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.13.
|
29
|
+
version: 0.13.2
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rake
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|