mocha 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +28 -10
- data/examples/stubba.rb +1 -1
- data/lib/mocha/auto_verify.rb +6 -6
- data/lib/mocha/deprecation.rb +22 -0
- data/lib/mocha/exception_raiser.rb +17 -0
- data/lib/mocha/expectation.rb +167 -84
- data/lib/mocha/infinite_range.rb +4 -6
- data/lib/mocha/inspect.rb +3 -1
- data/lib/mocha/is_a.rb +9 -0
- data/lib/mocha/missing_expectation.rb +27 -0
- data/lib/mocha/mock.rb +191 -5
- data/lib/mocha/multiple_yields.rb +20 -0
- data/lib/mocha/no_yields.rb +11 -0
- data/lib/mocha/object.rb +11 -1
- data/lib/mocha/parameter_matchers.rb +9 -0
- data/lib/mocha/parameter_matchers/all_of.rb +39 -0
- data/lib/mocha/parameter_matchers/any_of.rb +44 -0
- data/lib/mocha/parameter_matchers/anything.rb +30 -0
- data/lib/mocha/parameter_matchers/has_entry.rb +39 -0
- data/lib/mocha/parameter_matchers/has_key.rb +39 -0
- data/lib/mocha/parameter_matchers/has_value.rb +39 -0
- data/lib/mocha/parameter_matchers/includes.rb +37 -0
- data/lib/mocha/return_values.rb +31 -0
- data/lib/mocha/single_return_value.rb +24 -0
- data/lib/mocha/single_yield.rb +18 -0
- data/lib/mocha/standalone.rb +2 -0
- data/lib/mocha/stub.rb +18 -0
- data/lib/mocha/yield_parameters.rb +31 -0
- data/test/{mocha_acceptance_test.rb → acceptance/mocha_acceptance_test.rb} +1 -1
- data/test/acceptance/mocked_methods_dispatch_acceptance_test.rb +72 -0
- data/test/acceptance/parameter_matcher_acceptance_test.rb +63 -0
- data/test/{standalone_acceptance_test.rb → acceptance/standalone_acceptance_test.rb} +22 -1
- data/test/{stubba_acceptance_test.rb → acceptance/stubba_acceptance_test.rb} +1 -1
- data/test/deprecation_disabler.rb +15 -0
- data/test/{mocha_test_result_integration_test.rb → integration/mocha_test_result_integration_test.rb} +1 -1
- data/test/{stubba_integration_test.rb → integration/stubba_integration_test.rb} +1 -1
- data/test/{stubba_test_result_integration_test.rb → integration/stubba_test_result_integration_test.rb} +1 -1
- data/test/test_helper.rb +8 -0
- data/test/test_runner.rb +31 -0
- data/test/{mocha → unit}/any_instance_method_test.rb +0 -0
- data/test/unit/array_inspect_test.rb +16 -0
- data/test/{mocha → unit}/auto_verify_test.rb +0 -0
- data/test/{mocha → unit}/central_test.rb +0 -0
- data/test/{mocha → unit}/class_method_test.rb +0 -0
- data/test/unit/date_time_inspect_test.rb +21 -0
- data/test/unit/expectation_raiser_test.rb +28 -0
- data/test/{mocha → unit}/expectation_test.rb +105 -63
- data/test/unit/hash_inspect_test.rb +16 -0
- data/test/{mocha → unit}/infinite_range_test.rb +8 -5
- data/test/{mocha → unit}/metaclass_test.rb +0 -0
- data/test/unit/missing_expectation_test.rb +51 -0
- data/test/unit/mock_test.rb +351 -0
- data/test/unit/multiple_yields_test.rb +18 -0
- data/test/unit/no_yield_test.rb +18 -0
- data/test/unit/object_inspect_test.rb +35 -0
- data/test/{mocha → unit}/object_test.rb +0 -0
- data/test/unit/parameter_matchers/all_of_test.rb +26 -0
- data/test/unit/parameter_matchers/any_of_test.rb +26 -0
- data/test/unit/parameter_matchers/anything_test.rb +21 -0
- data/test/unit/parameter_matchers/has_entry_test.rb +25 -0
- data/test/unit/parameter_matchers/has_key_test.rb +25 -0
- data/test/unit/parameter_matchers/has_value_test.rb +25 -0
- data/test/unit/parameter_matchers/includes_test.rb +25 -0
- data/test/unit/parameter_matchers/stub_matcher.rb +22 -0
- data/test/{mocha → unit}/pretty_parameters_test.rb +0 -0
- data/test/unit/return_values_test.rb +63 -0
- data/test/{mocha → unit}/setup_and_teardown_test.rb +0 -0
- data/test/unit/single_return_value_test.rb +33 -0
- data/test/unit/single_yield_test.rb +18 -0
- data/test/unit/string_inspect_test.rb +11 -0
- data/test/unit/stub_test.rb +24 -0
- data/test/unit/yield_parameters_test.rb +93 -0
- metadata +117 -73
- data/lib/mocha/mock_methods.rb +0 -122
- data/test/all_tests.rb +0 -75
- data/test/mocha/inspect_test.rb +0 -90
- data/test/mocha/mock_methods_test.rb +0 -235
- data/test/mocha/mock_test.rb +0 -84
@@ -0,0 +1,93 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "test_helper")
|
2
|
+
|
3
|
+
require 'mocha/yield_parameters'
|
4
|
+
require 'mocha/no_yields'
|
5
|
+
require 'mocha/single_yield'
|
6
|
+
require 'mocha/multiple_yields'
|
7
|
+
|
8
|
+
class YieldParametersTest < Test::Unit::TestCase
|
9
|
+
|
10
|
+
include Mocha
|
11
|
+
|
12
|
+
def test_should_return_null_yield_parameter_group_by_default
|
13
|
+
yield_parameters = YieldParameters.new
|
14
|
+
assert yield_parameters.next_invocation.is_a?(NoYields)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_should_return_single_yield_parameter_group
|
18
|
+
yield_parameters = YieldParameters.new
|
19
|
+
yield_parameters.add(1, 2, 3)
|
20
|
+
parameter_group = yield_parameters.next_invocation
|
21
|
+
assert parameter_group.is_a?(SingleYield)
|
22
|
+
assert_equal [1, 2, 3], parameter_group.parameters
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_should_keep_returning_single_yield_parameter_group
|
26
|
+
yield_parameters = YieldParameters.new
|
27
|
+
yield_parameters.add(1, 2, 3)
|
28
|
+
yield_parameters.next_invocation
|
29
|
+
parameter_group = yield_parameters.next_invocation
|
30
|
+
assert parameter_group.is_a?(SingleYield)
|
31
|
+
assert_equal [1, 2, 3], parameter_group.parameters
|
32
|
+
parameter_group = yield_parameters.next_invocation
|
33
|
+
assert parameter_group.is_a?(SingleYield)
|
34
|
+
assert_equal [1, 2, 3], parameter_group.parameters
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_should_return_consecutive_single_yield_parameter_groups
|
38
|
+
yield_parameters = YieldParameters.new
|
39
|
+
yield_parameters.add(1, 2, 3)
|
40
|
+
yield_parameters.add(4, 5)
|
41
|
+
parameter_group = yield_parameters.next_invocation
|
42
|
+
assert parameter_group.is_a?(SingleYield)
|
43
|
+
assert_equal [1, 2, 3], parameter_group.parameters
|
44
|
+
parameter_group = yield_parameters.next_invocation
|
45
|
+
assert parameter_group.is_a?(SingleYield)
|
46
|
+
assert_equal [4, 5], parameter_group.parameters
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_should_return_multiple_yield_parameter_group
|
50
|
+
yield_parameters = YieldParameters.new
|
51
|
+
yield_parameters.multiple_add([1, 2, 3], [4, 5])
|
52
|
+
parameter_group = yield_parameters.next_invocation
|
53
|
+
assert parameter_group.is_a?(MultipleYields)
|
54
|
+
assert_equal [[1, 2, 3], [4, 5]], parameter_group.parameter_groups
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_should_keep_returning_multiple_yield_parameter_group
|
58
|
+
yield_parameters = YieldParameters.new
|
59
|
+
yield_parameters.multiple_add([1, 2, 3], [4, 5])
|
60
|
+
yield_parameters.next_invocation
|
61
|
+
parameter_group = yield_parameters.next_invocation
|
62
|
+
assert parameter_group.is_a?(MultipleYields)
|
63
|
+
assert_equal [[1, 2, 3], [4, 5]], parameter_group.parameter_groups
|
64
|
+
parameter_group = yield_parameters.next_invocation
|
65
|
+
assert parameter_group.is_a?(MultipleYields)
|
66
|
+
assert_equal [[1, 2, 3], [4, 5]], parameter_group.parameter_groups
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_should_return_consecutive_multiple_yield_parameter_groups
|
70
|
+
yield_parameters = YieldParameters.new
|
71
|
+
yield_parameters.multiple_add([1, 2, 3], [4, 5])
|
72
|
+
yield_parameters.multiple_add([6, 7], [8, 9, 0])
|
73
|
+
parameter_group = yield_parameters.next_invocation
|
74
|
+
assert parameter_group.is_a?(MultipleYields)
|
75
|
+
assert_equal [[1, 2, 3], [4, 5]], parameter_group.parameter_groups
|
76
|
+
parameter_group = yield_parameters.next_invocation
|
77
|
+
assert parameter_group.is_a?(MultipleYields)
|
78
|
+
assert_equal [[6, 7], [8, 9, 0]], parameter_group.parameter_groups
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_should_return_consecutive_single_and_multiple_yield_parameter_groups
|
82
|
+
yield_parameters = YieldParameters.new
|
83
|
+
yield_parameters.add(1, 2, 3)
|
84
|
+
yield_parameters.multiple_add([4, 5, 6], [7, 8])
|
85
|
+
parameter_group = yield_parameters.next_invocation
|
86
|
+
assert parameter_group.is_a?(SingleYield)
|
87
|
+
assert_equal [1, 2, 3], parameter_group.parameters
|
88
|
+
parameter_group = yield_parameters.next_invocation
|
89
|
+
assert parameter_group.is_a?(MultipleYields)
|
90
|
+
assert_equal [[4, 5, 6], [7, 8]], parameter_group.parameter_groups
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
metadata
CHANGED
@@ -1,99 +1,143 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
rubygems_version: 0.9.2
|
3
3
|
specification_version: 1
|
4
4
|
name: mocha
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.5.0
|
7
|
+
date: 2007-06-08 00:00:00 +01:00
|
8
8
|
summary: Mocking and stubbing library
|
9
9
|
require_paths:
|
10
|
-
|
10
|
+
- lib
|
11
11
|
email: mocha-developer@rubyforge.org
|
12
12
|
homepage: http://mocha.rubyforge.org
|
13
13
|
rubyforge_project: mocha
|
14
|
-
description:
|
15
|
-
stubbing of methods on real (non-mock) classes."
|
14
|
+
description: Mocking and stubbing library with JMock/SchMock syntax, which allows mocking and stubbing of methods on real (non-mock) classes.
|
16
15
|
autorequire: mocha
|
17
16
|
default_executable:
|
18
17
|
bindir: bin
|
19
18
|
has_rdoc: true
|
20
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
21
20
|
requirements:
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
version: 0.0.0
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
26
24
|
version:
|
27
25
|
platform: ruby
|
28
26
|
signing_key:
|
29
27
|
cert_chain:
|
28
|
+
post_install_message:
|
30
29
|
authors:
|
31
|
-
|
30
|
+
- James Mead
|
32
31
|
files:
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
32
|
+
- lib/mocha_standalone.rb
|
33
|
+
- lib/stubba.rb
|
34
|
+
- lib/mocha.rb
|
35
|
+
- lib/mocha/no_yields.rb
|
36
|
+
- lib/mocha/stub.rb
|
37
|
+
- lib/mocha/setup_and_teardown.rb
|
38
|
+
- lib/mocha/infinite_range.rb
|
39
|
+
- lib/mocha/expectation.rb
|
40
|
+
- lib/mocha/standalone.rb
|
41
|
+
- lib/mocha/central.rb
|
42
|
+
- lib/mocha/inspect.rb
|
43
|
+
- lib/mocha/mock.rb
|
44
|
+
- lib/mocha/parameter_matchers.rb
|
45
|
+
- lib/mocha/yield_parameters.rb
|
46
|
+
- lib/mocha/expectation_error.rb
|
47
|
+
- lib/mocha/auto_verify.rb
|
48
|
+
- lib/mocha/deprecation.rb
|
49
|
+
- lib/mocha/return_values.rb
|
50
|
+
- lib/mocha/exception_raiser.rb
|
51
|
+
- lib/mocha/multiple_yields.rb
|
52
|
+
- lib/mocha/instance_method.rb
|
53
|
+
- lib/mocha/class_method.rb
|
54
|
+
- lib/mocha/object.rb
|
55
|
+
- lib/mocha/pretty_parameters.rb
|
56
|
+
- lib/mocha/single_yield.rb
|
57
|
+
- lib/mocha/any_instance_method.rb
|
58
|
+
- lib/mocha/test_case_adapter.rb
|
59
|
+
- lib/mocha/is_a.rb
|
60
|
+
- lib/mocha/missing_expectation.rb
|
61
|
+
- lib/mocha/metaclass.rb
|
62
|
+
- lib/mocha/single_return_value.rb
|
63
|
+
- lib/mocha/parameter_matchers/anything.rb
|
64
|
+
- lib/mocha/parameter_matchers/has_key.rb
|
65
|
+
- lib/mocha/parameter_matchers/includes.rb
|
66
|
+
- lib/mocha/parameter_matchers/has_value.rb
|
67
|
+
- lib/mocha/parameter_matchers/any_of.rb
|
68
|
+
- lib/mocha/parameter_matchers/all_of.rb
|
69
|
+
- lib/mocha/parameter_matchers/has_entry.rb
|
70
|
+
- test/execution_point.rb
|
71
|
+
- test/test_helper.rb
|
72
|
+
- test/active_record_test_case.rb
|
73
|
+
- test/deprecation_disabler.rb
|
74
|
+
- test/test_runner.rb
|
75
|
+
- test/method_definer.rb
|
76
|
+
- test/unit/date_time_inspect_test.rb
|
77
|
+
- test/unit/infinite_range_test.rb
|
78
|
+
- test/unit/expectation_test.rb
|
79
|
+
- test/unit/setup_and_teardown_test.rb
|
80
|
+
- test/unit/expectation_raiser_test.rb
|
81
|
+
- test/unit/central_test.rb
|
82
|
+
- test/unit/mock_test.rb
|
83
|
+
- test/unit/yield_parameters_test.rb
|
84
|
+
- test/unit/object_inspect_test.rb
|
85
|
+
- test/unit/string_inspect_test.rb
|
86
|
+
- test/unit/auto_verify_test.rb
|
87
|
+
- test/unit/return_values_test.rb
|
88
|
+
- test/unit/no_yield_test.rb
|
89
|
+
- test/unit/array_inspect_test.rb
|
90
|
+
- test/unit/multiple_yields_test.rb
|
91
|
+
- test/unit/class_method_test.rb
|
92
|
+
- test/unit/object_test.rb
|
93
|
+
- test/unit/single_yield_test.rb
|
94
|
+
- test/unit/hash_inspect_test.rb
|
95
|
+
- test/unit/pretty_parameters_test.rb
|
96
|
+
- test/unit/any_instance_method_test.rb
|
97
|
+
- test/unit/missing_expectation_test.rb
|
98
|
+
- test/unit/metaclass_test.rb
|
99
|
+
- test/unit/single_return_value_test.rb
|
100
|
+
- test/unit/stub_test.rb
|
101
|
+
- test/unit/parameter_matchers/has_value_test.rb
|
102
|
+
- test/unit/parameter_matchers/anything_test.rb
|
103
|
+
- test/unit/parameter_matchers/stub_matcher.rb
|
104
|
+
- test/unit/parameter_matchers/has_key_test.rb
|
105
|
+
- test/unit/parameter_matchers/includes_test.rb
|
106
|
+
- test/unit/parameter_matchers/has_entry_test.rb
|
107
|
+
- test/unit/parameter_matchers/any_of_test.rb
|
108
|
+
- test/unit/parameter_matchers/all_of_test.rb
|
109
|
+
- test/integration/stubba_test_result_integration_test.rb
|
110
|
+
- test/integration/stubba_integration_test.rb
|
111
|
+
- test/integration/mocha_test_result_integration_test.rb
|
112
|
+
- test/acceptance/parameter_matcher_acceptance_test.rb
|
113
|
+
- test/acceptance/standalone_acceptance_test.rb
|
114
|
+
- test/acceptance/stubba_acceptance_test.rb
|
115
|
+
- test/acceptance/mocked_methods_dispatch_acceptance_test.rb
|
116
|
+
- test/acceptance/mocha_acceptance_test.rb
|
117
|
+
- examples/stubba.rb
|
118
|
+
- examples/mocha.rb
|
119
|
+
- examples/misc.rb
|
120
|
+
- MIT-LICENSE
|
121
|
+
- RELEASE
|
122
|
+
- Rakefile
|
123
|
+
- COPYING
|
124
|
+
- README
|
125
|
+
test_files: []
|
126
|
+
|
87
127
|
rdoc_options:
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
128
|
+
- --title
|
129
|
+
- Mocha
|
130
|
+
- --main
|
131
|
+
- README
|
132
|
+
- --line-numbers
|
93
133
|
extra_rdoc_files:
|
94
|
-
|
95
|
-
|
134
|
+
- README
|
135
|
+
- COPYING
|
96
136
|
executables: []
|
137
|
+
|
97
138
|
extensions: []
|
139
|
+
|
98
140
|
requirements: []
|
99
|
-
|
141
|
+
|
142
|
+
dependencies: []
|
143
|
+
|
data/lib/mocha/mock_methods.rb
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
require 'mocha/expectation'
|
2
|
-
require 'mocha/metaclass'
|
3
|
-
|
4
|
-
module Mocha
|
5
|
-
# Methods added to mock objects.
|
6
|
-
# These methods all return an expectation which can be further modified by methods on Mocha::Expectation.
|
7
|
-
module MockMethods
|
8
|
-
|
9
|
-
# :stopdoc:
|
10
|
-
|
11
|
-
attr_reader :stub_everything
|
12
|
-
|
13
|
-
def expectations
|
14
|
-
@expectations ||= []
|
15
|
-
end
|
16
|
-
|
17
|
-
# :startdoc:
|
18
|
-
|
19
|
-
# :call-seq: expects(method_name) -> expectation
|
20
|
-
# expects(method_names) -> last expectation
|
21
|
-
#
|
22
|
-
# Adds an expectation that a method identified by +method_name+ symbol must be called exactly once with any parameters.
|
23
|
-
# Returns the new expectation which can be further modified by methods on Mocha::Expectation.
|
24
|
-
# object = mock()
|
25
|
-
# object.expects(:method1)
|
26
|
-
# object.method1
|
27
|
-
# # no error raised
|
28
|
-
#
|
29
|
-
# object = mock()
|
30
|
-
# object.expects(:method1)
|
31
|
-
# # error raised, because method1 not called exactly once
|
32
|
-
# If +method_names+ is a +Hash+, an expectation will be set up for each entry using the key as +method_name+ and value as +return_value+.
|
33
|
-
# object = mock()
|
34
|
-
# object.expects(:method1 => :result1, :method2 => :result2)
|
35
|
-
#
|
36
|
-
# # exactly equivalent to
|
37
|
-
#
|
38
|
-
# object = mock()
|
39
|
-
# object.expects(:method1).returns(:result1)
|
40
|
-
# object.expects(:method2).returns(:result2)
|
41
|
-
def expects(method_names, backtrace = nil)
|
42
|
-
method_names = method_names.is_a?(Hash) ? method_names : { method_names => nil }
|
43
|
-
method_names.each do |method_name, return_value|
|
44
|
-
expectations << Expectation.new(self, method_name, backtrace).returns(return_value)
|
45
|
-
self.__metaclass__.send(:undef_method, method_name) if self.__metaclass__.method_defined?(method_name)
|
46
|
-
end
|
47
|
-
expectations.last
|
48
|
-
end
|
49
|
-
|
50
|
-
alias_method :__expects__, :expects
|
51
|
-
|
52
|
-
# :call-seq: stubs(method_name) -> expectation
|
53
|
-
# stubs(method_names) -> last expectation
|
54
|
-
#
|
55
|
-
# Adds an expectation that a method identified by +method_name+ symbol may be called any number of times with any parameters.
|
56
|
-
# Returns the new expectation which can be further modified by methods on Mocha::Expectation.
|
57
|
-
# object = mock()
|
58
|
-
# object.stubs(:method1)
|
59
|
-
# object.method1
|
60
|
-
# object.method1
|
61
|
-
# # no error raised
|
62
|
-
# If +method_names+ is a +Hash+, an expectation will be set up for each entry using the key as +method_name+ and value as +return_value+.
|
63
|
-
# object = mock()
|
64
|
-
# object.stubs(:method1 => :result1, :method2 => :result2)
|
65
|
-
#
|
66
|
-
# # exactly equivalent to
|
67
|
-
#
|
68
|
-
# object = mock()
|
69
|
-
# object.stubs(:method1).returns(:result1)
|
70
|
-
# object.stubs(:method2).returns(:result2)
|
71
|
-
def stubs(method_names, backtrace = nil)
|
72
|
-
method_names = method_names.is_a?(Hash) ? method_names : { method_names => nil }
|
73
|
-
method_names.each do |method_name, return_value|
|
74
|
-
expectations << Stub.new(self, method_name, backtrace).returns(return_value)
|
75
|
-
self.__metaclass__.send(:undef_method, method_name) if self.__metaclass__.method_defined?(method_name)
|
76
|
-
end
|
77
|
-
expectations.last
|
78
|
-
end
|
79
|
-
|
80
|
-
alias_method :__stubs__, :stubs
|
81
|
-
|
82
|
-
# :stopdoc:
|
83
|
-
|
84
|
-
def method_missing(symbol, *arguments, &block)
|
85
|
-
matching_expectation = matching_expectation(symbol, *arguments)
|
86
|
-
if matching_expectation then
|
87
|
-
matching_expectation.invoke(&block)
|
88
|
-
elsif stub_everything then
|
89
|
-
return
|
90
|
-
else
|
91
|
-
begin
|
92
|
-
super_method_missing(symbol, *arguments, &block)
|
93
|
-
rescue NoMethodError
|
94
|
-
unexpected_method_called(symbol, *arguments)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def respond_to?(symbol)
|
100
|
-
expectations.any? { |expectation| expectation.method_name == symbol }
|
101
|
-
end
|
102
|
-
|
103
|
-
def super_method_missing(symbol, *arguments, &block)
|
104
|
-
raise NoMethodError
|
105
|
-
end
|
106
|
-
|
107
|
-
def unexpected_method_called(symbol, *arguments)
|
108
|
-
MissingExpectation.new(self, symbol).with(*arguments).verify
|
109
|
-
end
|
110
|
-
|
111
|
-
def matching_expectation(symbol, *arguments)
|
112
|
-
expectations.reverse.detect { |expectation| expectation.match?(symbol, *arguments) }
|
113
|
-
end
|
114
|
-
|
115
|
-
def verify(&block)
|
116
|
-
expectations.each { |expectation| expectation.verify(&block) }
|
117
|
-
end
|
118
|
-
|
119
|
-
# :startdoc:
|
120
|
-
|
121
|
-
end
|
122
|
-
end
|
data/test/all_tests.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'test/unit/ui/console/testrunner'
|
2
|
-
|
3
|
-
require 'mocha/inspect_test'
|
4
|
-
require 'mocha/pretty_parameters_test'
|
5
|
-
require 'mocha/expectation_test'
|
6
|
-
require 'mocha/infinite_range_test'
|
7
|
-
require 'mocha/mock_methods_test'
|
8
|
-
require 'mocha/mock_test'
|
9
|
-
require 'mocha/auto_verify_test'
|
10
|
-
|
11
|
-
require 'mocha/central_test'
|
12
|
-
require 'mocha/class_method_test'
|
13
|
-
require 'mocha/any_instance_method_test'
|
14
|
-
require 'mocha/setup_and_teardown_test'
|
15
|
-
require 'mocha/object_test'
|
16
|
-
require 'mocha/metaclass_test'
|
17
|
-
|
18
|
-
class UnitTests
|
19
|
-
|
20
|
-
def self.suite
|
21
|
-
suite = Test::Unit::TestSuite.new('UnitTests')
|
22
|
-
suite << InspectTest.suite
|
23
|
-
suite << PrettyParametersTest.suite
|
24
|
-
suite << ExpectationTest.suite
|
25
|
-
suite << InfiniteRangeTest.suite
|
26
|
-
suite << MockMethodsTest.suite
|
27
|
-
suite << MockTest.suite
|
28
|
-
suite << AutoVerifyTest.suite
|
29
|
-
suite << CentralTest.suite
|
30
|
-
suite << ClassMethodTest.suite
|
31
|
-
suite << AnyInstanceMethodTest.suite
|
32
|
-
suite << SetupAndTeardownTest.suite
|
33
|
-
suite << ObjectTest.suite
|
34
|
-
suite << MetaclassTest.suite
|
35
|
-
suite
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
Test::Unit::UI::Console::TestRunner.run(UnitTests)
|
41
|
-
|
42
|
-
require 'mocha_test_result_integration_test'
|
43
|
-
require 'stubba_test_result_integration_test'
|
44
|
-
require 'stubba_integration_test'
|
45
|
-
|
46
|
-
class IntegrationTests
|
47
|
-
|
48
|
-
def self.suite
|
49
|
-
suite = Test::Unit::TestSuite.new('IntegrationTests')
|
50
|
-
suite << MochaTestResultIntegrationTest.suite
|
51
|
-
suite << StubbaTestResultIntegrationTest.suite
|
52
|
-
suite << StubbaIntegrationTest.suite
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
Test::Unit::UI::Console::TestRunner.run(IntegrationTests)
|
58
|
-
|
59
|
-
require 'mocha_acceptance_test'
|
60
|
-
require 'stubba_acceptance_test'
|
61
|
-
require 'standalone_acceptance_test'
|
62
|
-
|
63
|
-
class AcceptanceTests
|
64
|
-
|
65
|
-
def self.suite
|
66
|
-
suite = Test::Unit::TestSuite.new('AcceptanceTests')
|
67
|
-
suite << MochaAcceptanceTest.suite
|
68
|
-
suite << StubbaAcceptanceTest.suite
|
69
|
-
suite << StandaloneAcceptanceTest.suite
|
70
|
-
suite
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
Test::Unit::UI::Console::TestRunner.run(AcceptanceTests)
|