mocha 0.9.5 → 0.9.6
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 +17 -2
- data/Rakefile +10 -7
- data/examples/misc.rb +0 -1
- data/examples/mocha.rb +0 -1
- data/examples/stubba.rb +0 -1
- data/lib/mocha.rb +1 -47
- data/lib/mocha/any_instance_method.rb +5 -1
- data/lib/mocha/{standalone.rb → api.rb} +8 -1
- data/lib/mocha/class_method.rb +5 -1
- data/lib/mocha/expectation.rb +3 -3
- data/lib/mocha/integration.rb +38 -0
- data/lib/mocha/integration/mini_test.rb +21 -0
- data/lib/mocha/integration/mini_test/assertion_counter.rb +23 -0
- data/lib/mocha/integration/mini_test/version_131_and_above.rb +50 -0
- data/lib/mocha/integration/test_unit.rb +40 -0
- data/lib/mocha/integration/test_unit/assertion_counter.rb +23 -0
- data/lib/mocha/integration/test_unit/gem_version_200.rb +49 -0
- data/lib/mocha/integration/test_unit/gem_version_201_and_above.rb +49 -0
- data/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb +48 -0
- data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +50 -0
- data/lib/mocha/parameter_matchers/has_entry.rb +1 -0
- data/lib/mocha_standalone.rb +2 -2
- data/test/acceptance/{standalone_test.rb → api_test.rb} +2 -2
- data/test/acceptance/bug_21465_test.rb +2 -2
- data/test/acceptance/bug_21563_test.rb +1 -1
- data/test/acceptance/expected_invocation_count_test.rb +19 -19
- data/test/acceptance/failure_messages_test.rb +6 -6
- data/test/acceptance/minitest_test.rb +32 -9
- data/test/acceptance/mocha_test_result_test.rb +8 -8
- data/test/acceptance/mock_test.rb +10 -10
- data/test/acceptance/mock_with_initializer_block_test.rb +3 -3
- data/test/acceptance/mocked_methods_dispatch_test.rb +5 -5
- data/test/acceptance/optional_parameters_test.rb +6 -6
- data/test/acceptance/parameter_matcher_test.rb +20 -20
- data/test/acceptance/partial_mocks_test.rb +2 -2
- data/test/acceptance/return_value_test.rb +4 -4
- data/test/acceptance/sequence_test.rb +11 -11
- data/test/acceptance/states_test.rb +4 -4
- data/test/acceptance/stub_any_instance_method_test.rb +12 -12
- data/test/acceptance/stub_class_method_test.rb +12 -12
- data/test/acceptance/stub_everything_test.rb +4 -4
- data/test/acceptance/stub_instance_method_test.rb +13 -13
- data/test/acceptance/stub_module_method_test.rb +12 -12
- data/test/acceptance/stub_test.rb +4 -4
- data/test/acceptance/stubba_test.rb +1 -1
- data/test/acceptance/stubba_test_result_test.rb +6 -6
- data/test/acceptance/stubbing_error_backtrace_test.rb +4 -4
- data/test/acceptance/stubbing_method_unnecessarily_test.rb +5 -5
- data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +10 -10
- data/test/acceptance/stubbing_non_existent_class_method_test.rb +11 -11
- data/test/acceptance/stubbing_non_existent_instance_method_test.rb +11 -11
- data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +9 -9
- data/test/acceptance/stubbing_non_public_class_method_test.rb +10 -10
- data/test/acceptance/stubbing_non_public_instance_method_test.rb +10 -10
- data/test/acceptance/stubbing_on_non_mock_object_test.rb +5 -5
- data/test/test_helper.rb +4 -0
- data/test/test_runner.rb +1 -1
- data/test/unit/parameter_matchers/has_entry_test.rb +20 -0
- metadata +14 -6
- data/lib/mocha/mini_test_adapter.rb +0 -50
- data/lib/mocha/test_case_adapter.rb +0 -103
@@ -16,7 +16,7 @@ class StubbingNonExistentInstanceMethodTest < Test::Unit::TestCase
|
|
16
16
|
def test_should_allow_stubbing_non_existent_instance_method
|
17
17
|
Mocha::Configuration.allow(:stubbing_non_existent_method)
|
18
18
|
instance = Class.new.new
|
19
|
-
test_result =
|
19
|
+
test_result = run_as_test do
|
20
20
|
instance.stubs(:non_existent_method)
|
21
21
|
end
|
22
22
|
assert !@logger.warnings.include?("stubbing non-existent method: #{instance}.non_existent_method")
|
@@ -26,7 +26,7 @@ class StubbingNonExistentInstanceMethodTest < Test::Unit::TestCase
|
|
26
26
|
def test_should_warn_when_stubbing_non_existent_instance_method
|
27
27
|
Mocha::Configuration.warn_when(:stubbing_non_existent_method)
|
28
28
|
instance = Class.new.new
|
29
|
-
test_result =
|
29
|
+
test_result = run_as_test do
|
30
30
|
instance.stubs(:non_existent_method)
|
31
31
|
end
|
32
32
|
assert_passed(test_result)
|
@@ -36,7 +36,7 @@ class StubbingNonExistentInstanceMethodTest < Test::Unit::TestCase
|
|
36
36
|
def test_should_prevent_stubbing_non_existent_instance_method
|
37
37
|
Mocha::Configuration.prevent(:stubbing_non_existent_method)
|
38
38
|
instance = Class.new.new
|
39
|
-
test_result =
|
39
|
+
test_result = run_as_test do
|
40
40
|
instance.stubs(:non_existent_method)
|
41
41
|
end
|
42
42
|
assert_failed(test_result)
|
@@ -45,7 +45,7 @@ class StubbingNonExistentInstanceMethodTest < Test::Unit::TestCase
|
|
45
45
|
|
46
46
|
def test_should_default_to_allow_stubbing_non_existent_instance_method
|
47
47
|
instance = Class.new.new
|
48
|
-
test_result =
|
48
|
+
test_result = run_as_test do
|
49
49
|
instance.stubs(:non_existent_method)
|
50
50
|
end
|
51
51
|
assert !@logger.warnings.include?("stubbing non-existent method: #{instance}.non_existent_method")
|
@@ -59,7 +59,7 @@ class StubbingNonExistentInstanceMethodTest < Test::Unit::TestCase
|
|
59
59
|
public :existing_public_method
|
60
60
|
end
|
61
61
|
instance = klass.new
|
62
|
-
test_result =
|
62
|
+
test_result = run_as_test do
|
63
63
|
instance.stubs(:existing_public_method)
|
64
64
|
end
|
65
65
|
assert_passed(test_result)
|
@@ -73,7 +73,7 @@ class StubbingNonExistentInstanceMethodTest < Test::Unit::TestCase
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
instance = klass.new
|
76
|
-
test_result =
|
76
|
+
test_result = run_as_test do
|
77
77
|
instance.stubs(:method_to_which_instance_responds)
|
78
78
|
end
|
79
79
|
assert_passed(test_result)
|
@@ -86,7 +86,7 @@ class StubbingNonExistentInstanceMethodTest < Test::Unit::TestCase
|
|
86
86
|
protected :existing_protected_method
|
87
87
|
end
|
88
88
|
instance = klass.new
|
89
|
-
test_result =
|
89
|
+
test_result = run_as_test do
|
90
90
|
instance.stubs(:existing_protected_method)
|
91
91
|
end
|
92
92
|
assert_passed(test_result)
|
@@ -99,7 +99,7 @@ class StubbingNonExistentInstanceMethodTest < Test::Unit::TestCase
|
|
99
99
|
private :existing_private_method
|
100
100
|
end
|
101
101
|
instance = klass.new
|
102
|
-
test_result =
|
102
|
+
test_result = run_as_test do
|
103
103
|
instance.stubs(:existing_private_method)
|
104
104
|
end
|
105
105
|
assert_passed(test_result)
|
@@ -112,7 +112,7 @@ class StubbingNonExistentInstanceMethodTest < Test::Unit::TestCase
|
|
112
112
|
public :existing_public_method
|
113
113
|
end
|
114
114
|
instance = Class.new(superklass).new
|
115
|
-
test_result =
|
115
|
+
test_result = run_as_test do
|
116
116
|
instance.stubs(:existing_public_method)
|
117
117
|
end
|
118
118
|
assert_passed(test_result)
|
@@ -125,7 +125,7 @@ class StubbingNonExistentInstanceMethodTest < Test::Unit::TestCase
|
|
125
125
|
protected :existing_protected_method
|
126
126
|
end
|
127
127
|
instance = Class.new(superklass).new
|
128
|
-
test_result =
|
128
|
+
test_result = run_as_test do
|
129
129
|
instance.stubs(:existing_protected_method)
|
130
130
|
end
|
131
131
|
assert_passed(test_result)
|
@@ -138,7 +138,7 @@ class StubbingNonExistentInstanceMethodTest < Test::Unit::TestCase
|
|
138
138
|
private :existing_private_method
|
139
139
|
end
|
140
140
|
instance = Class.new(superklass).new
|
141
|
-
test_result =
|
141
|
+
test_result = run_as_test do
|
142
142
|
instance.stubs(:existing_private_method)
|
143
143
|
end
|
144
144
|
assert_passed(test_result)
|
@@ -19,7 +19,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Test::Unit::TestCase
|
|
19
19
|
def private_method; end
|
20
20
|
private :private_method
|
21
21
|
end
|
22
|
-
test_result =
|
22
|
+
test_result = run_as_test do
|
23
23
|
klass.any_instance.stubs(:private_method)
|
24
24
|
end
|
25
25
|
assert_passed(test_result)
|
@@ -32,7 +32,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Test::Unit::TestCase
|
|
32
32
|
def protected_method; end
|
33
33
|
protected :protected_method
|
34
34
|
end
|
35
|
-
test_result =
|
35
|
+
test_result = run_as_test do
|
36
36
|
klass.any_instance.stubs(:protected_method)
|
37
37
|
end
|
38
38
|
assert_passed(test_result)
|
@@ -45,7 +45,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Test::Unit::TestCase
|
|
45
45
|
def private_method; end
|
46
46
|
private :private_method
|
47
47
|
end
|
48
|
-
test_result =
|
48
|
+
test_result = run_as_test do
|
49
49
|
klass.any_instance.stubs(:private_method)
|
50
50
|
end
|
51
51
|
assert_passed(test_result)
|
@@ -58,7 +58,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Test::Unit::TestCase
|
|
58
58
|
def protected_method; end
|
59
59
|
protected :protected_method
|
60
60
|
end
|
61
|
-
test_result =
|
61
|
+
test_result = run_as_test do
|
62
62
|
klass.any_instance.stubs(:protected_method)
|
63
63
|
end
|
64
64
|
assert_passed(test_result)
|
@@ -71,7 +71,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Test::Unit::TestCase
|
|
71
71
|
def private_method; end
|
72
72
|
private :private_method
|
73
73
|
end
|
74
|
-
test_result =
|
74
|
+
test_result = run_as_test do
|
75
75
|
klass.any_instance.stubs(:private_method)
|
76
76
|
end
|
77
77
|
assert_failed(test_result)
|
@@ -84,7 +84,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Test::Unit::TestCase
|
|
84
84
|
def protected_method; end
|
85
85
|
protected :protected_method
|
86
86
|
end
|
87
|
-
test_result =
|
87
|
+
test_result = run_as_test do
|
88
88
|
klass.any_instance.stubs(:protected_method)
|
89
89
|
end
|
90
90
|
assert_failed(test_result)
|
@@ -96,7 +96,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Test::Unit::TestCase
|
|
96
96
|
def private_method; end
|
97
97
|
private :private_method
|
98
98
|
end
|
99
|
-
test_result =
|
99
|
+
test_result = run_as_test do
|
100
100
|
klass.any_instance.stubs(:private_method)
|
101
101
|
end
|
102
102
|
assert_passed(test_result)
|
@@ -108,7 +108,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Test::Unit::TestCase
|
|
108
108
|
def protected_method; end
|
109
109
|
protected :protected_method
|
110
110
|
end
|
111
|
-
test_result =
|
111
|
+
test_result = run_as_test do
|
112
112
|
klass.any_instance.stubs(:protected_method)
|
113
113
|
end
|
114
114
|
assert_passed(test_result)
|
@@ -121,7 +121,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Test::Unit::TestCase
|
|
121
121
|
def public_method; end
|
122
122
|
public :public_method
|
123
123
|
end
|
124
|
-
test_result =
|
124
|
+
test_result = run_as_test do
|
125
125
|
klass.any_instance.stubs(:public_method)
|
126
126
|
end
|
127
127
|
assert_passed(test_result)
|
@@ -21,7 +21,7 @@ class StubbingNonPublicClassMethodTest < Test::Unit::TestCase
|
|
21
21
|
private :private_method
|
22
22
|
end
|
23
23
|
end
|
24
|
-
test_result =
|
24
|
+
test_result = run_as_test do
|
25
25
|
klass.stubs(:private_method)
|
26
26
|
end
|
27
27
|
assert_passed(test_result)
|
@@ -36,7 +36,7 @@ class StubbingNonPublicClassMethodTest < Test::Unit::TestCase
|
|
36
36
|
protected :protected_method
|
37
37
|
end
|
38
38
|
end
|
39
|
-
test_result =
|
39
|
+
test_result = run_as_test do
|
40
40
|
klass.stubs(:protected_method)
|
41
41
|
end
|
42
42
|
assert_passed(test_result)
|
@@ -51,7 +51,7 @@ class StubbingNonPublicClassMethodTest < Test::Unit::TestCase
|
|
51
51
|
private :private_method
|
52
52
|
end
|
53
53
|
end
|
54
|
-
test_result =
|
54
|
+
test_result = run_as_test do
|
55
55
|
klass.stubs(:private_method)
|
56
56
|
end
|
57
57
|
assert_passed(test_result)
|
@@ -66,7 +66,7 @@ class StubbingNonPublicClassMethodTest < Test::Unit::TestCase
|
|
66
66
|
protected :protected_method
|
67
67
|
end
|
68
68
|
end
|
69
|
-
test_result =
|
69
|
+
test_result = run_as_test do
|
70
70
|
klass.stubs(:protected_method)
|
71
71
|
end
|
72
72
|
assert_passed(test_result)
|
@@ -81,7 +81,7 @@ class StubbingNonPublicClassMethodTest < Test::Unit::TestCase
|
|
81
81
|
private :private_method
|
82
82
|
end
|
83
83
|
end
|
84
|
-
test_result =
|
84
|
+
test_result = run_as_test do
|
85
85
|
klass.stubs(:private_method)
|
86
86
|
end
|
87
87
|
assert_failed(test_result)
|
@@ -96,7 +96,7 @@ class StubbingNonPublicClassMethodTest < Test::Unit::TestCase
|
|
96
96
|
protected :protected_method
|
97
97
|
end
|
98
98
|
end
|
99
|
-
test_result =
|
99
|
+
test_result = run_as_test do
|
100
100
|
klass.stubs(:protected_method)
|
101
101
|
end
|
102
102
|
assert_failed(test_result)
|
@@ -110,7 +110,7 @@ class StubbingNonPublicClassMethodTest < Test::Unit::TestCase
|
|
110
110
|
private :private_method
|
111
111
|
end
|
112
112
|
end
|
113
|
-
test_result =
|
113
|
+
test_result = run_as_test do
|
114
114
|
klass.stubs(:private_method)
|
115
115
|
end
|
116
116
|
assert_passed(test_result)
|
@@ -124,7 +124,7 @@ class StubbingNonPublicClassMethodTest < Test::Unit::TestCase
|
|
124
124
|
protected :protected_method
|
125
125
|
end
|
126
126
|
end
|
127
|
-
test_result =
|
127
|
+
test_result = run_as_test do
|
128
128
|
klass.stubs(:protected_method)
|
129
129
|
end
|
130
130
|
assert_passed(test_result)
|
@@ -139,7 +139,7 @@ class StubbingNonPublicClassMethodTest < Test::Unit::TestCase
|
|
139
139
|
public :public_method
|
140
140
|
end
|
141
141
|
end
|
142
|
-
test_result =
|
142
|
+
test_result = run_as_test do
|
143
143
|
klass.stubs(:public_method)
|
144
144
|
end
|
145
145
|
assert_passed(test_result)
|
@@ -154,7 +154,7 @@ class StubbingNonPublicClassMethodTest < Test::Unit::TestCase
|
|
154
154
|
end
|
155
155
|
end
|
156
156
|
end
|
157
|
-
test_result =
|
157
|
+
test_result = run_as_test do
|
158
158
|
klass.stubs(:method_to_which_class_responds)
|
159
159
|
end
|
160
160
|
assert_passed(test_result)
|
@@ -19,7 +19,7 @@ class StubbingNonPublicInstanceMethodTest < Test::Unit::TestCase
|
|
19
19
|
def private_method; end
|
20
20
|
private :private_method
|
21
21
|
end.new
|
22
|
-
test_result =
|
22
|
+
test_result = run_as_test do
|
23
23
|
instance.stubs(:private_method)
|
24
24
|
end
|
25
25
|
assert_passed(test_result)
|
@@ -32,7 +32,7 @@ class StubbingNonPublicInstanceMethodTest < Test::Unit::TestCase
|
|
32
32
|
def protected_method; end
|
33
33
|
protected :protected_method
|
34
34
|
end.new
|
35
|
-
test_result =
|
35
|
+
test_result = run_as_test do
|
36
36
|
instance.stubs(:protected_method)
|
37
37
|
end
|
38
38
|
assert_passed(test_result)
|
@@ -45,7 +45,7 @@ class StubbingNonPublicInstanceMethodTest < Test::Unit::TestCase
|
|
45
45
|
def private_method; end
|
46
46
|
private :private_method
|
47
47
|
end.new
|
48
|
-
test_result =
|
48
|
+
test_result = run_as_test do
|
49
49
|
instance.stubs(:private_method)
|
50
50
|
end
|
51
51
|
assert_passed(test_result)
|
@@ -58,7 +58,7 @@ class StubbingNonPublicInstanceMethodTest < Test::Unit::TestCase
|
|
58
58
|
def protected_method; end
|
59
59
|
protected :protected_method
|
60
60
|
end.new
|
61
|
-
test_result =
|
61
|
+
test_result = run_as_test do
|
62
62
|
instance.stubs(:protected_method)
|
63
63
|
end
|
64
64
|
assert_passed(test_result)
|
@@ -71,7 +71,7 @@ class StubbingNonPublicInstanceMethodTest < Test::Unit::TestCase
|
|
71
71
|
def private_method; end
|
72
72
|
private :private_method
|
73
73
|
end.new
|
74
|
-
test_result =
|
74
|
+
test_result = run_as_test do
|
75
75
|
instance.stubs(:private_method)
|
76
76
|
end
|
77
77
|
assert_failed(test_result)
|
@@ -84,7 +84,7 @@ class StubbingNonPublicInstanceMethodTest < Test::Unit::TestCase
|
|
84
84
|
def protected_method; end
|
85
85
|
protected :protected_method
|
86
86
|
end.new
|
87
|
-
test_result =
|
87
|
+
test_result = run_as_test do
|
88
88
|
instance.stubs(:protected_method)
|
89
89
|
end
|
90
90
|
assert_failed(test_result)
|
@@ -96,7 +96,7 @@ class StubbingNonPublicInstanceMethodTest < Test::Unit::TestCase
|
|
96
96
|
def private_method; end
|
97
97
|
private :private_method
|
98
98
|
end.new
|
99
|
-
test_result =
|
99
|
+
test_result = run_as_test do
|
100
100
|
instance.stubs(:private_method)
|
101
101
|
end
|
102
102
|
assert_passed(test_result)
|
@@ -108,7 +108,7 @@ class StubbingNonPublicInstanceMethodTest < Test::Unit::TestCase
|
|
108
108
|
def protected_method; end
|
109
109
|
protected :protected_method
|
110
110
|
end.new
|
111
|
-
test_result =
|
111
|
+
test_result = run_as_test do
|
112
112
|
instance.stubs(:protected_method)
|
113
113
|
end
|
114
114
|
assert_passed(test_result)
|
@@ -121,7 +121,7 @@ class StubbingNonPublicInstanceMethodTest < Test::Unit::TestCase
|
|
121
121
|
def public_method; end
|
122
122
|
public :public_method
|
123
123
|
end.new
|
124
|
-
test_result =
|
124
|
+
test_result = run_as_test do
|
125
125
|
instance.stubs(:public_method)
|
126
126
|
end
|
127
127
|
assert_passed(test_result)
|
@@ -134,7 +134,7 @@ class StubbingNonPublicInstanceMethodTest < Test::Unit::TestCase
|
|
134
134
|
(method == :method_to_which_instance_responds)
|
135
135
|
end
|
136
136
|
end.new
|
137
|
-
test_result =
|
137
|
+
test_result = run_as_test do
|
138
138
|
instance.stubs(:method_to_which_instance_responds)
|
139
139
|
end
|
140
140
|
assert_passed(test_result)
|
@@ -16,7 +16,7 @@ class StubbingOnNonMockObjectTest < Test::Unit::TestCase
|
|
16
16
|
def test_should_allow_stubbing_method_on_non_mock_object
|
17
17
|
Mocha::Configuration.allow(:stubbing_method_on_non_mock_object)
|
18
18
|
non_mock_object = Class.new { def existing_method; end }
|
19
|
-
test_result =
|
19
|
+
test_result = run_as_test do
|
20
20
|
non_mock_object.stubs(:existing_method)
|
21
21
|
end
|
22
22
|
assert_passed(test_result)
|
@@ -26,7 +26,7 @@ class StubbingOnNonMockObjectTest < Test::Unit::TestCase
|
|
26
26
|
def test_should_warn_on_stubbing_method_on_non_mock_object
|
27
27
|
Mocha::Configuration.warn_when(:stubbing_method_on_non_mock_object)
|
28
28
|
non_mock_object = Class.new { def existing_method; end }
|
29
|
-
test_result =
|
29
|
+
test_result = run_as_test do
|
30
30
|
non_mock_object.stubs(:existing_method)
|
31
31
|
end
|
32
32
|
assert_passed(test_result)
|
@@ -36,7 +36,7 @@ class StubbingOnNonMockObjectTest < Test::Unit::TestCase
|
|
36
36
|
def test_should_prevent_stubbing_method_on_non_mock_object
|
37
37
|
Mocha::Configuration.prevent(:stubbing_method_on_non_mock_object)
|
38
38
|
non_mock_object = Class.new { def existing_method; end }
|
39
|
-
test_result =
|
39
|
+
test_result = run_as_test do
|
40
40
|
non_mock_object.stubs(:existing_method)
|
41
41
|
end
|
42
42
|
assert_failed(test_result)
|
@@ -45,7 +45,7 @@ class StubbingOnNonMockObjectTest < Test::Unit::TestCase
|
|
45
45
|
|
46
46
|
def test_should_default_to_allow_stubbing_method_on_non_mock_object
|
47
47
|
non_mock_object = Class.new { def existing_method; end }
|
48
|
-
test_result =
|
48
|
+
test_result = run_as_test do
|
49
49
|
non_mock_object.stubs(:existing_method)
|
50
50
|
end
|
51
51
|
assert_passed(test_result)
|
@@ -54,7 +54,7 @@ class StubbingOnNonMockObjectTest < Test::Unit::TestCase
|
|
54
54
|
|
55
55
|
def test_should_allow_stubbing_method_on_mock_object
|
56
56
|
Mocha::Configuration.prevent(:stubbing_method_on_non_mock_object)
|
57
|
-
test_result =
|
57
|
+
test_result = run_as_test do
|
58
58
|
mock = mock('mock')
|
59
59
|
mock.stubs(:any_method)
|
60
60
|
end
|
data/test/test_helper.rb
CHANGED
@@ -8,4 +8,8 @@ $:.unshift File.expand_path(File.join(File.dirname(__FILE__), 'unit'))
|
|
8
8
|
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), 'unit', 'parameter_matchers'))
|
9
9
|
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), 'acceptance'))
|
10
10
|
|
11
|
+
if ENV['MOCHA_OPTIONS'] == 'use_test_unit_gem'
|
12
|
+
gem 'test-unit'
|
13
|
+
end
|
14
|
+
|
11
15
|
require 'test/unit'
|
data/test/test_runner.rb
CHANGED
@@ -3,7 +3,7 @@ require 'test/unit/testcase'
|
|
3
3
|
|
4
4
|
module TestRunner
|
5
5
|
|
6
|
-
def
|
6
|
+
def run_as_test(test_result = Test::Unit::TestResult.new, &block)
|
7
7
|
test_class = Class.new(Test::Unit::TestCase) do
|
8
8
|
define_method(:test_me, &block)
|
9
9
|
end
|
@@ -59,4 +59,24 @@ class HasEntryTest < Test::Unit::TestCase
|
|
59
59
|
assert !matcher.matches?([{ :key_1 => 'value_1', :key_2 => 'value_2' }])
|
60
60
|
end
|
61
61
|
|
62
|
+
def test_should_not_match_object_that_doesnt_respond_to_keys
|
63
|
+
matcher = has_entry(:key_1 => equals('value_2'))
|
64
|
+
object = Class.new do
|
65
|
+
def [](key)
|
66
|
+
'value_2'
|
67
|
+
end
|
68
|
+
end.new
|
69
|
+
assert !matcher.matches?([object])
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_should_not_match_object_that_doesnt_respond_to_square_bracket
|
73
|
+
matcher = has_entry(:key_1 => equals('value_2'))
|
74
|
+
object = Class.new do
|
75
|
+
def keys
|
76
|
+
[:key_1]
|
77
|
+
end
|
78
|
+
end.new
|
79
|
+
assert !matcher.matches?([object])
|
80
|
+
end
|
81
|
+
|
62
82
|
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.9.
|
4
|
+
version: 0.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Mead
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-06-29 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -33,6 +33,7 @@ extra_rdoc_files:
|
|
33
33
|
- COPYING
|
34
34
|
files:
|
35
35
|
- lib/mocha/any_instance_method.rb
|
36
|
+
- lib/mocha/api.rb
|
36
37
|
- lib/mocha/argument_iterator.rb
|
37
38
|
- lib/mocha/backtrace_filter.rb
|
38
39
|
- lib/mocha/cardinality.rb
|
@@ -48,11 +49,20 @@ files:
|
|
48
49
|
- lib/mocha/in_state_ordering_constraint.rb
|
49
50
|
- lib/mocha/inspect.rb
|
50
51
|
- lib/mocha/instance_method.rb
|
52
|
+
- lib/mocha/integration/mini_test/assertion_counter.rb
|
53
|
+
- lib/mocha/integration/mini_test/version_131_and_above.rb
|
54
|
+
- lib/mocha/integration/mini_test.rb
|
55
|
+
- lib/mocha/integration/test_unit/assertion_counter.rb
|
56
|
+
- lib/mocha/integration/test_unit/gem_version_200.rb
|
57
|
+
- lib/mocha/integration/test_unit/gem_version_201_and_above.rb
|
58
|
+
- lib/mocha/integration/test_unit/ruby_version_185_and_below.rb
|
59
|
+
- lib/mocha/integration/test_unit/ruby_version_186_and_above.rb
|
60
|
+
- lib/mocha/integration/test_unit.rb
|
61
|
+
- lib/mocha/integration.rb
|
51
62
|
- lib/mocha/is_a.rb
|
52
63
|
- lib/mocha/logger.rb
|
53
64
|
- lib/mocha/metaclass.rb
|
54
65
|
- lib/mocha/method_matcher.rb
|
55
|
-
- lib/mocha/mini_test_adapter.rb
|
56
66
|
- lib/mocha/mock.rb
|
57
67
|
- lib/mocha/mockery.rb
|
58
68
|
- lib/mocha/module_method.rb
|
@@ -87,16 +97,15 @@ files:
|
|
87
97
|
- lib/mocha/sequence.rb
|
88
98
|
- lib/mocha/single_return_value.rb
|
89
99
|
- lib/mocha/single_yield.rb
|
90
|
-
- lib/mocha/standalone.rb
|
91
100
|
- lib/mocha/state_machine.rb
|
92
101
|
- lib/mocha/stubbing_error.rb
|
93
|
-
- lib/mocha/test_case_adapter.rb
|
94
102
|
- lib/mocha/unexpected_invocation.rb
|
95
103
|
- lib/mocha/yield_parameters.rb
|
96
104
|
- lib/mocha.rb
|
97
105
|
- lib/mocha_standalone.rb
|
98
106
|
- lib/stubba.rb
|
99
107
|
- test/acceptance/acceptance_test_helper.rb
|
108
|
+
- test/acceptance/api_test.rb
|
100
109
|
- test/acceptance/bug_18914_test.rb
|
101
110
|
- test/acceptance/bug_21465_test.rb
|
102
111
|
- test/acceptance/bug_21563_test.rb
|
@@ -113,7 +122,6 @@ files:
|
|
113
122
|
- test/acceptance/partial_mocks_test.rb
|
114
123
|
- test/acceptance/return_value_test.rb
|
115
124
|
- test/acceptance/sequence_test.rb
|
116
|
-
- test/acceptance/standalone_test.rb
|
117
125
|
- test/acceptance/states_test.rb
|
118
126
|
- test/acceptance/stub_any_instance_method_test.rb
|
119
127
|
- test/acceptance/stub_class_method_test.rb
|