rubyunit 0.3.16 → 0.3.17
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/RubyUnit/Assertions/Basic.rb +111 -108
- data/lib/RubyUnit/Assertions/Classes.rb +216 -0
- data/lib/RubyUnit/Assertions/Collections.rb +105 -0
- data/lib/RubyUnit/Assertions/Comparisons.rb +205 -0
- data/lib/RubyUnit/Assertions/Exceptions.rb +122 -0
- data/lib/RubyUnit/Assertions/Methods.rb +162 -0
- data/lib/RubyUnit/Assertions/Root.rb +93 -0
- data/lib/RubyUnit/Assertions.rb +22 -97
- data/lib/RubyUnit.rb +16 -9
- data/tests/AssertionFailure/TC_Class.rb +8 -3
- data/tests/AssertionFailure/TC_Instance.rb +13 -26
- data/tests/AssertionFailure/data/Class.rb +13 -0
- data/tests/AssertionFailure/data/Instance.rb +9 -10
- data/tests/Assertions/{TC_Class.rb → TC_Classes.rb} +3 -4
- data/tests/Assertions/TC_Collections.rb +13 -0
- data/tests/Assertions/TC_Comparisons.rb +13 -0
- data/tests/Assertions/TC_Exceptions.rb +13 -0
- data/tests/Assertions/TC_Methods.rb +13 -0
- data/tests/Assertions/data/Basic.rb +2 -2
- data/tests/Assertions/data/{Class.rb → Classes.rb} +1 -1
- data/tests/Assertions/data/Collections.rb +13 -0
- data/tests/Assertions/data/Comparisons.rb +7 -0
- data/tests/Assertions/data/Exceptions.rb +7 -0
- data/tests/Assertions/data/Methods.rb +7 -0
- data/tests/RubyUnit/TC_GemInfo.rb +4 -3
- data/tests/RubyUnit/TC_RubyUnit.rb +8 -7
- data/tests/RubyUnit/data/GemInfo.rb +1 -1
- data/tests/RubyUnit/data/RubyUnit.rb +9 -2
- data/tests/TS_Assertions.rb +2 -4
- metadata +20 -12
- data/lib/RubyUnit/Assertions/Class.rb +0 -198
- data/lib/RubyUnit/Assertions/Collection.rb +0 -80
- data/lib/RubyUnit/Assertions/Comparison.rb +0 -200
- data/lib/RubyUnit/Assertions/Exception.rb +0 -105
- data/lib/RubyUnit/Assertions/Method.rb +0 -157
- data/tests/Assertions/TC_Comparison.rb +0 -13
- data/tests/Assertions/data/Comparison.rb +0 -7
@@ -1,198 +0,0 @@
|
|
1
|
-
module RubyUnit
|
2
|
-
module Assertions
|
3
|
-
include AssertionMessage
|
4
|
-
#
|
5
|
-
# Assert that an object is an instance of the specified class or one of
|
6
|
-
# its descendents.
|
7
|
-
# * raises RubyUnit::AssertionFailure unless _object_ is an instance of
|
8
|
-
# _klass_ or one of its descendents.
|
9
|
-
#
|
10
|
-
# klass::
|
11
|
-
# The class that is expected
|
12
|
-
#
|
13
|
-
# object::
|
14
|
-
# The object that will be checked against _klass_
|
15
|
-
#
|
16
|
-
# message::
|
17
|
-
# The message provided to be reported for a failure
|
18
|
-
#
|
19
|
-
# assertKindOf String, 25, 'Nope, try again.' # => fail
|
20
|
-
#
|
21
|
-
def assertKindOf klass, object, message = nil
|
22
|
-
__assert (object.is_a? klass), ASSERT_KIND_OF_ERROR, message, {:klass=>klass, :object=>object}
|
23
|
-
end
|
24
|
-
|
25
|
-
alias_method :assertIsA, :assertKindOf
|
26
|
-
|
27
|
-
#
|
28
|
-
# Assert that an object is not an instance of the specified class or one of
|
29
|
-
# its descendents.
|
30
|
-
# * raises RubyUnit::AssertionFailure if _object_ is an instance of _exclusion_ or
|
31
|
-
# one of its descendents.
|
32
|
-
#
|
33
|
-
# exclusion::
|
34
|
-
# The class that is excluded
|
35
|
-
#
|
36
|
-
# object::
|
37
|
-
# The object that will be checked against _klass_
|
38
|
-
#
|
39
|
-
# message::
|
40
|
-
# The message provided to be reported for a failure
|
41
|
-
#
|
42
|
-
# assertNotKindOf Numeric, 25, 'Nope, try again.' # => fail
|
43
|
-
#
|
44
|
-
def assertNotKindOf exclusion, object, message = nil
|
45
|
-
__reject (object.is_a? exclusion), ASSERT_NOT_KIND_OF_ERROR, message, {:exclusion=>exclusion, :object=>object}
|
46
|
-
end
|
47
|
-
|
48
|
-
[:assertNotIsA, :assertIsNotA].each do |method|
|
49
|
-
alias_method method, :assertNotKindOf
|
50
|
-
end
|
51
|
-
|
52
|
-
#
|
53
|
-
# Assert that an object is an instance of a specified class
|
54
|
-
# * raises RubyUnit::AssertionFailure unless _object_ is an instance of _klass_.
|
55
|
-
#
|
56
|
-
# klass::
|
57
|
-
# The class that is expected
|
58
|
-
#
|
59
|
-
# object::
|
60
|
-
# The object that will be checked against _klass_
|
61
|
-
#
|
62
|
-
# message::
|
63
|
-
# The message provided to be reported for a failure
|
64
|
-
#
|
65
|
-
# assertInstanceOf Integer, '25', 'So close, but... No.' # => fail
|
66
|
-
#
|
67
|
-
def assertInstanceOf klass, object, message = nil
|
68
|
-
__assert (object.instance_of? klass), ASSERT_INSTANCE_OF_ERROR, message, {:klass=>klass, :object=>object}
|
69
|
-
end
|
70
|
-
|
71
|
-
#
|
72
|
-
# Assert that an object is an instance of a specified class
|
73
|
-
# * raises RubyUnit::AssertionFailure unless _object_ is an instance of _klass_.
|
74
|
-
#
|
75
|
-
# exclusion::
|
76
|
-
# The class that is expected
|
77
|
-
#
|
78
|
-
# object::
|
79
|
-
# The object that will be checked against _klass_
|
80
|
-
#
|
81
|
-
# message::
|
82
|
-
# The message provided to be reported for a failure
|
83
|
-
#
|
84
|
-
# assertNotInstanceOf Integer, 25, 'So close, but... No.' # => fail
|
85
|
-
#
|
86
|
-
def assertNotInstanceOf exclusion, object, message = nil
|
87
|
-
__reject (object.instance_of? exclusion), ASSERT_NOT_INSTANCE_OF_ERROR, message, {:exclusion=>exclusion, :object=>object}
|
88
|
-
end
|
89
|
-
|
90
|
-
#
|
91
|
-
# Assert that a class is a descendent of another class
|
92
|
-
# * raises RubyUnit::AssertionFailure unless _descendent_ is a descendent of _klass_
|
93
|
-
#
|
94
|
-
# klass::
|
95
|
-
# The parent class
|
96
|
-
#
|
97
|
-
# descendent::
|
98
|
-
# The descendent class
|
99
|
-
#
|
100
|
-
# message::
|
101
|
-
# The message provided to be reported for a failure
|
102
|
-
#
|
103
|
-
# assertDescendent Numeric, Exception, 'Nope' # => fail
|
104
|
-
#
|
105
|
-
def assertDescendent klass, descendent, message = nil
|
106
|
-
raise ArgumentError, 'Expecting Class' unless klass.is_a? Class
|
107
|
-
__assert (descendent < klass), ASSERT_DESCENDENT_ERROR, message, {:klass=>klass, :descendent=>descendent}
|
108
|
-
end
|
109
|
-
|
110
|
-
#
|
111
|
-
# Assert that a class is not a descendent of another class
|
112
|
-
# * raises RubyUnit::AssertionFailure if _illegal_ is a descendent of _klass_
|
113
|
-
#
|
114
|
-
# klass::
|
115
|
-
# The parent class
|
116
|
-
#
|
117
|
-
# descendent::
|
118
|
-
# The illegal descendent class
|
119
|
-
#
|
120
|
-
# message::
|
121
|
-
# The message provided to be reported for a failure
|
122
|
-
#
|
123
|
-
# assertDescendent StandardError, Exception, 'It is' # => fail
|
124
|
-
#
|
125
|
-
def assertNotDescendent klass, illegal, message = nil
|
126
|
-
raise ArgumentError, 'Expecting Class' unless klass.is_a? Class
|
127
|
-
__reject (illegal < klass), ASSERT_NOT_DESCENDENT_ERROR, message, {:klass=>klass, :illegal=>illegal}
|
128
|
-
end
|
129
|
-
|
130
|
-
#
|
131
|
-
# Assert that a constant is defined correctly in the correct class
|
132
|
-
# * raises RubyUnit::AssertionFailure unless the constant is defined in
|
133
|
-
# the specified class and it is the correct type and value
|
134
|
-
#
|
135
|
-
# expected::
|
136
|
-
# The value that is expected for the constant
|
137
|
-
#
|
138
|
-
# klass::
|
139
|
-
# The class where the constant should be defined
|
140
|
-
#
|
141
|
-
# konstant::
|
142
|
-
# The name of the constant
|
143
|
-
#
|
144
|
-
# message::
|
145
|
-
# The message provided to be reported for a failure
|
146
|
-
#
|
147
|
-
# assertConst 42, Numbers, 'TWENTYFOUR', 'So dyslexic.' # => fail
|
148
|
-
#
|
149
|
-
def assertConst expected, klass, konstant, message = nil
|
150
|
-
__wrap_assertion do
|
151
|
-
assertConstDefined klass, konstant, message
|
152
|
-
value = klass.const_get konstant
|
153
|
-
assertIsA expected.class, value, message
|
154
|
-
assertEqual expected, value, message
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
#
|
159
|
-
# Assert that a constant is defined in the specified class
|
160
|
-
# * raises RubyUnit::AssertionFailure unless the constant is defined in
|
161
|
-
# the specified class
|
162
|
-
#
|
163
|
-
# klass::
|
164
|
-
# The class where the constant should be defined
|
165
|
-
#
|
166
|
-
# konstant::
|
167
|
-
# The name of the constant
|
168
|
-
#
|
169
|
-
# message::
|
170
|
-
# The message provided to be reported for a failure
|
171
|
-
#
|
172
|
-
# assertConstDefined Numbers, 'FORTYTWO', 'Mystery.' # => ??
|
173
|
-
#
|
174
|
-
def assertConstDefined klass, konstant, message = nil
|
175
|
-
__assert (klass.const_defined? konstant), ASSERT_CONST_DEFINED_ERROR, message, {:klass=>klass, :konstant=>konstant}
|
176
|
-
end
|
177
|
-
|
178
|
-
#
|
179
|
-
# Assert that a constant is not defined in the specified class
|
180
|
-
# * raises RubyUnit::AssertionFailure if the constant is defined in
|
181
|
-
# the specified class
|
182
|
-
#
|
183
|
-
# klass::
|
184
|
-
# The class where the constant should not be defined
|
185
|
-
#
|
186
|
-
# konstant::
|
187
|
-
# The name of the constant
|
188
|
-
#
|
189
|
-
# message::
|
190
|
-
# The message provided to be reported for a failure
|
191
|
-
#
|
192
|
-
# assertConstNotDefined Numbers, 'TWENTYFOUR', 'Mystery.' # => ??
|
193
|
-
#
|
194
|
-
def assertConstNotDefined klass, konstant, message = nil
|
195
|
-
__reject (klass.const_defined? konstant), ASSERT_CONST_NOT_DEFINED_ERROR, message, {:klass=>klass, :konstant=>konstant}
|
196
|
-
end
|
197
|
-
end
|
198
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
module RubyUnit
|
2
|
-
module Assertions
|
3
|
-
include AssertionMessage
|
4
|
-
#
|
5
|
-
# Assert that a collection includes a specified value
|
6
|
-
# * raises RubyUnit::AssertionFailure unless _collection_ responds to _value_
|
7
|
-
#
|
8
|
-
# object::
|
9
|
-
# The collection to check
|
10
|
-
#
|
11
|
-
# method::
|
12
|
-
# The value the object should contain
|
13
|
-
#
|
14
|
-
# message::
|
15
|
-
# The message provided to be reported for a failure
|
16
|
-
#
|
17
|
-
# assertInclude [1, 2], 'not in', 'It does not, so... no' # => fail
|
18
|
-
#
|
19
|
-
def assertInclude collection, value, message = nil
|
20
|
-
assertRespondTo collection, :include?, message
|
21
|
-
__assert (collection.include? value), ASSERT_INCLUDE_ERROR, message, {:collection=>collection, :value=>value}
|
22
|
-
end
|
23
|
-
|
24
|
-
#
|
25
|
-
# Assert that a collection does not include a specified value
|
26
|
-
# * raises RubyUnit::AssertionFailure if _collection_ responds to _value_
|
27
|
-
#
|
28
|
-
# object::
|
29
|
-
# The collection to check
|
30
|
-
#
|
31
|
-
# method::
|
32
|
-
# The value the object should not contain
|
33
|
-
#
|
34
|
-
# message::
|
35
|
-
# The message provided to be reported for a failure
|
36
|
-
#
|
37
|
-
# assertNotInclude [1, 2, 3], 2, 'It does, so close' # => fail
|
38
|
-
#
|
39
|
-
def assertNotInclude collection, value, message = nil
|
40
|
-
assertRespondTo collection, :include?, message
|
41
|
-
__reject (collection.include? value), ASSERT_NOT_INCLUDE_ERROR, message, {:collection=>collection, :value=>value}
|
42
|
-
end
|
43
|
-
|
44
|
-
#
|
45
|
-
# Assert that a value is empty
|
46
|
-
# * raises RubyUnit::AssertionFailure unless _object_ responds to :empty?
|
47
|
-
# * raises RubyUnit::AssertionFailure unless _object_ is empty
|
48
|
-
#
|
49
|
-
# object::
|
50
|
-
# The object to check
|
51
|
-
#
|
52
|
-
# message::
|
53
|
-
# The message provided to be reported for a failure
|
54
|
-
#
|
55
|
-
# assertEmpty [1, 2], 'Not empty' # => fail
|
56
|
-
#
|
57
|
-
def assertEmpty object, message = nil
|
58
|
-
assertRespondTo object, :include?, message
|
59
|
-
__assert object.empty?, ASSERT_EMPTY_ERROR, message, {:object=>object}
|
60
|
-
end
|
61
|
-
|
62
|
-
#
|
63
|
-
# Assert that a value is not empty
|
64
|
-
# * raises RubyUnit::AssertionFailure unless _object_ responds to :empty?
|
65
|
-
# * raises RubyUnit::AssertionFailure if _object_ is empty
|
66
|
-
#
|
67
|
-
# object::
|
68
|
-
# The object to check
|
69
|
-
#
|
70
|
-
# message::
|
71
|
-
# The message provided to be reported for a failure
|
72
|
-
#
|
73
|
-
# assertNotInclude [1, 2, 3], 2, 'It does, so close' # => fail
|
74
|
-
#
|
75
|
-
def assertNotEmpty object, message = nil
|
76
|
-
assertRespondTo object, :include?, message
|
77
|
-
__reject object.empty?, ASSERT_NOT_EMPTY_ERROR, message, {:object=>object}
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
@@ -1,200 +0,0 @@
|
|
1
|
-
module RubyUnit
|
2
|
-
module Assertions
|
3
|
-
include AssertionMessage
|
4
|
-
|
5
|
-
#
|
6
|
-
# Assert that two values are equal.
|
7
|
-
# * raises RubyUnit::AssertionFailure unless _expected_ equals _actual_
|
8
|
-
#
|
9
|
-
# expected::
|
10
|
-
# The value that is forbidden by the assertion
|
11
|
-
#
|
12
|
-
# actual::
|
13
|
-
# The value that is being checked by the assertion
|
14
|
-
#
|
15
|
-
# message::
|
16
|
-
# The message provided to be reported for a failure
|
17
|
-
#
|
18
|
-
# assertEqual 42, 24, "This will fail" # => fail
|
19
|
-
#
|
20
|
-
def assertEqual expected, actual, message = nil
|
21
|
-
__assert (expected == actual), ASSERT_EQUAL_ERROR, message, {:expected=>expected, :actual=>actual}
|
22
|
-
end
|
23
|
-
|
24
|
-
#
|
25
|
-
# Assert that two values are NOT equal.
|
26
|
-
# * raises RubyUnit::AssertionFailure if _illegal_ equals _actual_
|
27
|
-
#
|
28
|
-
# illegal::
|
29
|
-
# The value that is not allowed by the assertion
|
30
|
-
#
|
31
|
-
# actual::
|
32
|
-
# The value that is being checked by the assertion
|
33
|
-
#
|
34
|
-
# message::
|
35
|
-
# The message provided to be reported for a failure
|
36
|
-
#
|
37
|
-
# assertNotEqual 3.14, 3.14, "This will fail" # => fail
|
38
|
-
#
|
39
|
-
def assertNotEqual illegal, actual, message = nil
|
40
|
-
__reject (illegal == actual), ASSERT_NOT_EQUAL_ERROR, message, {:illegal=>illegal, :actual=>actual}
|
41
|
-
end
|
42
|
-
|
43
|
-
#
|
44
|
-
# Assert that one value is greater than another.
|
45
|
-
# * raises RubyUnit::AssertionFailure unless _greater_ is greater than _value_
|
46
|
-
#
|
47
|
-
# greater::
|
48
|
-
# The value that should be greater
|
49
|
-
#
|
50
|
-
# value::
|
51
|
-
# The value that is being checked by the assertion
|
52
|
-
#
|
53
|
-
# message::
|
54
|
-
# The message provided to be reported for a failure
|
55
|
-
#
|
56
|
-
# assertGreaterThan 24, 42, "This will fail" # => fail
|
57
|
-
#
|
58
|
-
def assertGreaterThan greater, value, message = nil
|
59
|
-
__assert (greater > value), ASSERT_GREATERTHAN_ERROR, message, {:greater=>greater, :value=>value}
|
60
|
-
end
|
61
|
-
|
62
|
-
#
|
63
|
-
# Assert that one value is greater than another.
|
64
|
-
# * raises RubyUnit::AssertionFailure unless _greater_ is greater than or equal to _value_
|
65
|
-
#
|
66
|
-
# greater::
|
67
|
-
# The value that should be greater than or equal
|
68
|
-
#
|
69
|
-
# value::
|
70
|
-
# The value that is being checked by the assertion
|
71
|
-
#
|
72
|
-
# message::
|
73
|
-
# The message provided to be reported for a failure
|
74
|
-
#
|
75
|
-
# assertGreaterThanOrEqual 24, 42, "This will fail" # => fail
|
76
|
-
#
|
77
|
-
def assertGreaterThanOrEqual greater, value, message = nil
|
78
|
-
__assert (greater >= value), ASSERT_GREATERTHANOREQUAL_ERROR, message, {:greater=>greater, :value=>value}
|
79
|
-
end
|
80
|
-
|
81
|
-
#
|
82
|
-
# Assert that one value is less than another.
|
83
|
-
# * raises RubyUnit::AssertionFailure unless _less_ is less than _value_
|
84
|
-
#
|
85
|
-
# less::
|
86
|
-
# The value that should be less
|
87
|
-
#
|
88
|
-
# value::
|
89
|
-
# The value that is being checked by the assertion
|
90
|
-
#
|
91
|
-
# message::
|
92
|
-
# The message provided to be reported for a failure
|
93
|
-
#
|
94
|
-
# assertLessThan 42, 24, "This will fail" # => fail
|
95
|
-
#
|
96
|
-
def assertLessThan less, value, message = nil
|
97
|
-
__assert (less < value), ASSERT_LESSTHAN_ERROR, message, {:less=>less, :value=>value}
|
98
|
-
end
|
99
|
-
|
100
|
-
#
|
101
|
-
# Assert that one value is less than another.
|
102
|
-
# * raises RubyUnit::AssertionFailure unless _less_ is less than or equal to _value_
|
103
|
-
#
|
104
|
-
# less::
|
105
|
-
# The value that should be less than or equal
|
106
|
-
#
|
107
|
-
# value::
|
108
|
-
# The value that is being checked by the assertion
|
109
|
-
#
|
110
|
-
# message::
|
111
|
-
# The message provided to be reported for a failure
|
112
|
-
#
|
113
|
-
# assertLessThanOrEqual 42, 24, "This will fail" # => fail
|
114
|
-
#
|
115
|
-
def assertLessThanOrEqual less, value, message = nil
|
116
|
-
__assert (less <= value), ASSERT_LESSTHANOREQUAL_ERROR, message, {:less=>less, :value=>value}
|
117
|
-
end
|
118
|
-
|
119
|
-
#
|
120
|
-
# Assert that a value matches a Regexp pattern.
|
121
|
-
# * raises RubyUnit::AssertionFailure unless _value_ matches _pattern_
|
122
|
-
#
|
123
|
-
# pattern::
|
124
|
-
# A Regexp pattern expected by the assertion
|
125
|
-
#
|
126
|
-
# value::
|
127
|
-
# The value that is being checked for the assertion
|
128
|
-
#
|
129
|
-
# message::
|
130
|
-
# The message provided to be reported for a failure
|
131
|
-
#
|
132
|
-
# assertMatch /^Hello/, 'Goodbye!', "This will fail" # => fail
|
133
|
-
#
|
134
|
-
def assertMatch pattern, value, message = nil
|
135
|
-
pattern = [pattern] unless pattern.is_a? Array
|
136
|
-
pattern.each do |regex|
|
137
|
-
__assert (value =~ regex), ASSERT_MATCH_ERROR, message, {:pattern=>pattern, :value=>value}
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
#
|
142
|
-
# Assert that a value does not match a Regexp pattern.
|
143
|
-
# * raises RubyUnit::AssertionFailure if _value_ matches _pattern_
|
144
|
-
#
|
145
|
-
# pattern::
|
146
|
-
# A Regexp pattern excluded by the assertion
|
147
|
-
#
|
148
|
-
# value::
|
149
|
-
# The value that is being checked for the assertion
|
150
|
-
#
|
151
|
-
# message::
|
152
|
-
# The message provided to be reported for a failure
|
153
|
-
#
|
154
|
-
# assertMatch /^Good/, 'Goodbye!', "This will fail" # => fail
|
155
|
-
#
|
156
|
-
def assertNotMatch exclusion, value, message = nil
|
157
|
-
__reject (value =~ exclusion), ASSERT_NO_MATCH_ERROR, message, {:exclusion=>exclusion, :value=>value}
|
158
|
-
end
|
159
|
-
|
160
|
-
#
|
161
|
-
# Assert that two objects are the same object
|
162
|
-
# * raises RubyUnit::AssertionFailure unless _expected_ and _actual_ are
|
163
|
-
# the same object.
|
164
|
-
#
|
165
|
-
# expected::
|
166
|
-
# The expected object
|
167
|
-
#
|
168
|
-
# actual::
|
169
|
-
# The object that is being checked against _expected_
|
170
|
-
#
|
171
|
-
# message::
|
172
|
-
# The message provided to be reported for a failure
|
173
|
-
#
|
174
|
-
# assertSame '42', 42, 'Not even close.' # => fail
|
175
|
-
#
|
176
|
-
def assertSame expected, actual, message = nil
|
177
|
-
__assert (expected.equal? actual), ASSERT_SAME_ERROR, message, {:expected=>expected, :actual=>actual}
|
178
|
-
end
|
179
|
-
|
180
|
-
#
|
181
|
-
# Assert that two objects are not the same object
|
182
|
-
# * raises RubyUnit::AssertionFailure if _illegal_ and _actual_ are the
|
183
|
-
# same object.
|
184
|
-
#
|
185
|
-
# illegal::
|
186
|
-
# The expected that it shouldn't be
|
187
|
-
#
|
188
|
-
# actual::
|
189
|
-
# The object that is being checked against _illegal_
|
190
|
-
#
|
191
|
-
# message::
|
192
|
-
# The message provided to be reported for a failure
|
193
|
-
#
|
194
|
-
# assertNotSame value, value, 'Imagine that!' # => fail
|
195
|
-
#
|
196
|
-
def assertNotSame illegal, actual, message = nil
|
197
|
-
__reject (illegal.equal? actual), ASSERT_NOT_SAME_ERROR, message, {:illegal=>illegal, :actual=>actual}
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
@@ -1,105 +0,0 @@
|
|
1
|
-
module RubyUnit
|
2
|
-
module Assertions
|
3
|
-
include AssertionMessage
|
4
|
-
|
5
|
-
#
|
6
|
-
# Assert that no exception is raised.
|
7
|
-
# * raises RubyUnit::AssertionFailure if any exception is raised
|
8
|
-
#
|
9
|
-
# message::
|
10
|
-
# The message provided to be reported for a failure
|
11
|
-
#
|
12
|
-
# &block::
|
13
|
-
# The code block that is executed
|
14
|
-
#
|
15
|
-
# assertNothingRaised 'Not expecting an exception!' do
|
16
|
-
# # do something
|
17
|
-
# end
|
18
|
-
#
|
19
|
-
def assertNothingRaised message = nil, &block
|
20
|
-
__wrap_assertion do
|
21
|
-
begin
|
22
|
-
yield
|
23
|
-
rescue Exception => e
|
24
|
-
build_message ASSERT_NOTHING_RAISED_ERROR, message, {:exception=>e.message}
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
#
|
30
|
-
# Assert that a specified exception message is raised.
|
31
|
-
# * raises RubyUnit::AssertionFailure unless the correct Exception message is raised
|
32
|
-
#
|
33
|
-
# pattern::
|
34
|
-
# The String or Regexp that will be used to validate the Exception message
|
35
|
-
#
|
36
|
-
# message::
|
37
|
-
# The message provided to be reported for a failure
|
38
|
-
#
|
39
|
-
# &block::
|
40
|
-
# The code block that is expected to throw the Exception
|
41
|
-
#
|
42
|
-
# assertRaiseMessage /^Invalid/, 'Expecting an exception!' do
|
43
|
-
# # do something
|
44
|
-
# end
|
45
|
-
#
|
46
|
-
def assertRaiseMessage pattern, message = nil, &block
|
47
|
-
assertRaiseExpected Exception, pattern, message, &block
|
48
|
-
end
|
49
|
-
|
50
|
-
#
|
51
|
-
# Assert that a specified exception type is raised.
|
52
|
-
# * raises RubyUnit::AssertionFailure unless the correct Exception type is raised
|
53
|
-
#
|
54
|
-
# e::
|
55
|
-
# The Exception class that is expected.
|
56
|
-
#
|
57
|
-
# message::
|
58
|
-
# The message provided to be reported for a failure
|
59
|
-
#
|
60
|
-
# &block::
|
61
|
-
# The code block that is expected to throw the Exception
|
62
|
-
#
|
63
|
-
# assertRaiseKindOf StandardError, 'Expecting an exception!' do # => fail
|
64
|
-
# # do something
|
65
|
-
# end
|
66
|
-
#
|
67
|
-
def assertRaiseKindOf e, message = nil, &block
|
68
|
-
assertRaiseExpected e, '', message, &block
|
69
|
-
end
|
70
|
-
|
71
|
-
#
|
72
|
-
# Assert that a specified exception is raised.
|
73
|
-
# * raises RubyUnit::AssertionFailure unless the correct Exception is raised
|
74
|
-
#
|
75
|
-
# exception::
|
76
|
-
# The Exception class that is expected.
|
77
|
-
#
|
78
|
-
# pattern::
|
79
|
-
# The String or Regexp that will be used to validate the Exception message
|
80
|
-
#
|
81
|
-
# message::
|
82
|
-
# The message provided to be reported for a failure
|
83
|
-
#
|
84
|
-
# &block::
|
85
|
-
# The code block that is expected to throw the Exception
|
86
|
-
#
|
87
|
-
# assertRaiseExpected StandardError, /^Invalid/, 'Expecting an exception!' do
|
88
|
-
# raise StandardError, 'Invalid Retroincabulator'
|
89
|
-
# end
|
90
|
-
#
|
91
|
-
def assertRaiseExpected exception, pattern, message = nil &block
|
92
|
-
__validate_exception pattern, exception
|
93
|
-
__wrap_assertion do
|
94
|
-
begin
|
95
|
-
yield
|
96
|
-
build_message ASSERT_RAISE_EXPECTED_ERROR, message, {:exception=>exception, :pattern=>pattern}
|
97
|
-
rescue exception => e
|
98
|
-
assertEqual pattern, e.message if pattern.is_a? String and pattern.length > 0
|
99
|
-
assertMatch pattern, e.message if pattern.is_a? Regexp
|
100
|
-
e
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|