rubyunit 0.2.14 → 0.3.15

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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -5
  3. data/TestSuite.rb +7 -23
  4. data/lib/RubyUnit/AssertionFailure.rb +9 -9
  5. data/lib/RubyUnit/AssertionMessage.rb +70 -0
  6. data/lib/RubyUnit/Assertions/Basic.rb +121 -0
  7. data/lib/RubyUnit/Assertions/Class.rb +196 -0
  8. data/lib/RubyUnit/Assertions/Collection.rb +80 -0
  9. data/lib/RubyUnit/Assertions/Comparison.rb +200 -0
  10. data/lib/RubyUnit/Assertions/Exception.rb +105 -0
  11. data/lib/RubyUnit/Assertions/Method.rb +157 -0
  12. data/lib/RubyUnit/Assertions.rb +9 -636
  13. data/lib/RubyUnit/Runner.rb +1 -2
  14. data/lib/RubyUnit.rb +28 -4
  15. data/tests/AssertionFailure/TC_Class.rb +2 -13
  16. data/tests/AssertionFailure/TC_Instance.rb +1 -1
  17. data/tests/AssertionFailure/data/Instance.rb +3 -3
  18. data/tests/AssertionMessage/TC_Constant.rb +20 -0
  19. data/tests/AssertionMessage/data/Constant.rb +70 -0
  20. data/tests/Assertions/TC_Basic.rb +349 -0
  21. data/tests/Assertions/TC_Class.rb +75 -0
  22. data/tests/Assertions/TC_Comparison.rb +13 -0
  23. data/tests/Assertions/data/Basic.rb +90 -0
  24. data/tests/Assertions/data/Class.rb +54 -0
  25. data/tests/Assertions/data/Comparison.rb +7 -0
  26. data/tests/Assertions/data/ObjectTypes.rb +174 -0
  27. data/tests/IncompleteTest/TC_IncompleteTest.rb +15 -0
  28. data/tests/RubyUnit/TC_RubyUnit.rb +30 -0
  29. data/tests/RubyUnit/data/RubyUnit.rb +16 -0
  30. data/tests/Runner/TC_Runner.rb +9 -0
  31. data/tests/SkippedTest/TC_SkippedTest.rb +15 -0
  32. data/tests/TS_AssertionFailure.rb +4 -2
  33. data/tests/TS_AssertionMessage.rb +9 -0
  34. data/tests/TS_Assertions.rb +67 -0
  35. data/tests/TS_IncompleteTest.rb +9 -0
  36. data/tests/TS_RubyUnit.rb +4 -2
  37. data/tests/TS_Runner.rb +9 -0
  38. data/tests/TS_SkippedTest.rb +9 -0
  39. data/tests/TS_TestCase.rb +9 -0
  40. data/tests/TestCase/TC_TestCase.rb +120 -0
  41. data/tests/TestCase/data/TestCase.rb +24 -0
  42. metadata +32 -12
  43. data/tests/AssertionFailure/data/Class.rb +0 -12
  44. data/tests/TEST_Assertions.rb +0 -37
  45. data/tests/TEST_IncompleteTest.rb +0 -13
  46. data/tests/TEST_Runner.rb +0 -7
  47. data/tests/TEST_SkippedTest.rb +0 -13
  48. data/tests/TEST_TestCase.rb +0 -122
  49. data/tests/data/Assertions.rb +0 -23
  50. data/tests/data/TestCase.rb +0 -22
  51. data/tests/fixture/TestCase.rb +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b64f6dbfe4319e46907b2011f73fdadd28eefe7a
4
- data.tar.gz: b71d665242db3cfc15f5db95b9c4410bd5f67d38
3
+ metadata.gz: fbbc44756c8014588e15f7b9db7f6d07e3d40ad4
4
+ data.tar.gz: c3a39f3f2a8a55fdeaeabfab1857655714a18c26
5
5
  SHA512:
6
- metadata.gz: bad85169080b04079d2603d31ebd4bcd9eba77c9b62770d1418d4e6abcc16df2b942f5d72ae1e6a94d5c37e45ffcc656033e3e8dac39cf679e411cc198b31ab0
7
- data.tar.gz: c7ff085f436ef93f1a13b07fd5b5b547906cd13690d32d9759c6c512bc5316d8b095d258c1f529b561d81fcfa1b2e87e68735e0968f6555e3247730021dbcd65
6
+ metadata.gz: 623a1fe7c5dfde8032454373019dc7e51eed67e3b4c2dca6360bfe3ebb4d64ccfd61765fa8b0ba6b97b22ba475e585570a1b847e6062341fc17386e3ac3478eb
7
+ data.tar.gz: e95597151407a17709aade4fc6a955c4500b53e750113c9827fc20f08d99d3a81c36a6826999262dfa879913627da868ca4546f42f37eb800e4d57e356f64533
data/README.md CHANGED
@@ -3,10 +3,8 @@ RubyUnit
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/rubyunit.svg)](http://badge.fury.io/rb/rubyunit)
5
5
  [![Code Climate](https://codeclimate.com/github/RubyUnit/RubyUnit/badges/gpa.svg)](https://codeclimate.com/github/RubyUnit/RubyUnit)
6
- [![Test Coverage](https://codeclimate.com/github/RubyUnit/RubyUnit/badges/coverage.svg)](https://codeclimate.com/github/RubyUnit/RubyUnit)
7
-
8
- ### Practical Examples
9
- * https://github.com/matthewclower/PlayingCards
6
+ [![Build Status](https://travis-ci.org/RubyUnit/RubyUnit.svg?branch=master)](https://travis-ci.org/RubyUnit/RubyUnit)
7
+ <!-- [![Test Coverage](https://codeclimate.com/github/RubyUnit/RubyUnit/badges/coverage.svg)](https://codeclimate.com/github/RubyUnit/RubyUnit) -->
10
8
 
11
9
  ### Links
12
10
  * http://rubyunit.github.io/
@@ -17,7 +15,8 @@ RubyUnit
17
15
 
18
16
  Unit testing and test-driven development is a crucial part of the software
19
17
  development life cycle. This tool is intended to make development and
20
- testing in Ruby easier on everyone.
18
+ testing in Ruby easier on everyone. RubyUnit is also designed to with a focus
19
+ on data-driven testing.
21
20
 
22
21
  ### Install
23
22
 
data/TestSuite.rb CHANGED
@@ -4,30 +4,14 @@
4
4
  # in this repository
5
5
  path = File.dirname(__FILE__)
6
6
 
7
- $LOAD_PATH.unshift("#{path}/lib") if not ARGV.include? '--gem'
8
- $LOAD_PATH.unshift("#{path}/tests")
7
+ $LOAD_PATH.unshift("#{path}/lib") unless ARGV.include? '--gem'
9
8
 
10
9
  require 'RubyUnit'
11
10
 
12
- # Test Sets
11
+ RubyUnit.debug = true if ARGV.include? '--debug'
13
12
 
14
- # RubyUnit module => RubyUnit.rb
15
- require 'TS_RubyUnit'
16
-
17
- # AssertionFailure exception => RubyUnit/AssertionFailure.rb
18
- require 'TS_AssertionFailure'
19
-
20
- # Assertions module => RubyUnit/Assertions.rb
21
- require 'TEST_Assertions'
22
-
23
- # IncompleteTest exception => RubyUnit/IncompleteTest.rb
24
- require 'TEST_IncompleteTest'
25
-
26
- # Runner class => RubyUnit/Runner.rb
27
- require 'TEST_Runner'
28
-
29
- # SkippedTest exception => RubyUnit/SkippedTest.rb
30
- require 'TEST_SkippedTest'
31
-
32
- # TestCase class => RubyUnit/TestCase.rb
33
- require 'TEST_TestCase'
13
+ # Automatically load Test Sets
14
+ Dir['tests/TS_*.rb'].each do |test_set|
15
+ puts "Adding Test Set #{test_set}" if RubyUnit.debug
16
+ require_relative test_set
17
+ end
@@ -1,14 +1,14 @@
1
+ require 'RubyUnit/AssertionMessage'
2
+
1
3
  module RubyUnit
2
- #
4
+ ##
3
5
  # Exception that is raised when a test assertion fails.
4
6
  #
5
7
  class AssertionFailure < StandardError
8
+ include AssertionMessage
6
9
  attr_reader :data
7
10
 
8
- # Error messages
9
- FAILING = 'Failing test'
10
-
11
- #
11
+ ##
12
12
  # Create a RubyUnit::AssertionFailure exception
13
13
  #
14
14
  # data::
@@ -19,14 +19,14 @@ module RubyUnit
19
19
  @data = data
20
20
  end
21
21
 
22
- #
22
+ ##
23
23
  # Create a string from the assertion data
24
24
  #
25
25
  def info
26
26
  s = "\n"
27
- s = "#{message}\n" if message.length > 0
28
- @data.each do |index, value|
29
- s << "\n#{index}:\n\t#{value.inspect}"
27
+ s = "#{FAILURE}: #{message}\n" if message.length > 0
28
+ @data.each do |key, value|
29
+ s << "\n#{key}:\n\t#{value.inspect}"
30
30
  end
31
31
  s
32
32
  end
@@ -0,0 +1,70 @@
1
+ module RubyUnit
2
+ ##
3
+ # module containing text for assertion errors and messages
4
+ #
5
+ module AssertionMessage
6
+ ##
7
+ # Error messages
8
+ FAILING = 'Failing test'
9
+ FAILURE = 'Failed to ASSERT'
10
+
11
+ ##
12
+ # Basic assertions
13
+ ASSERT_ERROR = 'Value IS NOT false OR nil'
14
+ ASSERT_NOT_ERROR = 'Value IS false OR nil'
15
+ ASSERT_TRUE_ERROR = 'Value IS EXACLTY true'
16
+ ASSERT_FALSE_ERROR = 'Value IS EXACLTY false'
17
+ ASSERT_NIL_ERROR = 'Value IS EXACTLY nil'
18
+ ASSERT_NOT_NIL_ERROR = 'Value IS NOT nil'
19
+
20
+ ##
21
+ # Class assertions
22
+ ASSERT_KIND_OF_ERROR = 'Object IS kind_of?'
23
+ ASSERT_NOT_KIND_OF_ERROR = 'Object IS NOT kind_of?'
24
+ ASSERT_INSTANCE_OF_ERROR = 'Object IS instance_of?'
25
+ ASSERT_NOT_INSTANCE_OF_ERROR = 'Object IS NOT instance_of?'
26
+ ASSERT_DESCENDENT_ERROR = 'Object IS a descendent'
27
+ ASSERT_NOT_DESCENDENT_ERROR = 'Object IS NOT a descendent'
28
+ ASSERT_CONST_ERROR = 'Object defines correct constant'
29
+ ASSERT_CONST_DEFINED_ERROR = 'Object defines constant'
30
+ ASSERT_CONST_NOT_DEFINED_ERROR = 'Object does NOT define constant'
31
+
32
+ ##
33
+ # Collection assertions
34
+ ASSERT_INCLUDE_ERROR = 'Collection includes object'
35
+ ASSERT_NOT_INCLUDE_ERROR = 'Collection does NOT include object'
36
+ ASSERT_EMPTY_ERROR = 'Collection IS empty'
37
+ ASSERT_NOT_EMPTY_ERROR = 'Collection IS NOT empty'
38
+
39
+ ##
40
+ # Comparison assertions
41
+ ASSERT_EQUAL_ERROR = 'Objects ARE equal'
42
+ ASSERT_NOT_EQUAL_ERROR = 'Objects ARE NOT equal'
43
+ ASSERT_GREATERTHAN_ERROR = 'Object IS greater than expected'
44
+ ASSERT_GREATERTHANOREQUAL_ERROR = 'Object IS greater than OR equal to expected'
45
+ ASSERT_LESSTHAN_ERROR = 'Object IS less than expected'
46
+ ASSERT_LESSTHANOREQUAL_ERROR = 'Object IS less than OR equal to expected'
47
+ ASSERT_MATCH_ERROR = 'Value matches Regexp'
48
+ ASSERT_NOT_MATCH_ERROR = 'Value does NOT match Regexp'
49
+ ASSERT_SAME_ERROR = 'Objects ARE the same'
50
+ ASSERT_NOT_SAME_ERROR = 'Objects ARE NOT the same'
51
+
52
+ ##
53
+ # Exception assertions
54
+ ASSERT_NOTHING_RAISED_ERROR = 'Exception WAS NOT raised'
55
+ ASSERT_RAISE_MESSAGE_ERROR = 'Exception message WAS raised'
56
+ ASSERT_RAISE_KIND_OF_ERROR = 'Exception Class WAS raised'
57
+ ASSERT_RAISE_EXPECTED_ERROR = 'Expected Exception WAS raised'
58
+
59
+ ##
60
+ # Method assertions
61
+ ASSERT_RESPOND_TO_ERROR = 'Object responds to method'
62
+ ASSERT_NOT_RESPOND_TO_ERROR = 'Object does NOT respond to method'
63
+ ASSERT_METHOD_ERROR = 'Object defines method'
64
+ ASSERT_NOT_METHOD_ERROR = 'Object does NOT define method'
65
+ ASSERT_INSTANCE_METHOD_ERROR = 'Object defines instance method'
66
+ ASSERT_NOT_INSTANCE_METHOD_ERROR = 'Object does NOT define instance method'
67
+ ASSERT_CLASS_METHOD_ERROR = 'Object defines class method'
68
+ ASSERT_NOT_CLASS_METHOD_ERROR = 'Object does NOT define instance method'
69
+ end
70
+ end
@@ -0,0 +1,121 @@
1
+ module RubyUnit
2
+ module Assertions
3
+ include AssertionMessage
4
+
5
+ #
6
+ # Fail the test. This is used when some conditioned outside the test warrants
7
+ # a test failure.
8
+ # * This is likely an indication of something unexpected or missing functionality
9
+ # * raises RubyUnit::AssertionFailure
10
+ #
11
+ # message::
12
+ # The message provided to be reported for a failure
13
+ #
14
+ # data::
15
+ # The data associated with assertion
16
+ #
17
+ # fail "I wasn't expecting the moon to fall into Lake Michigan" # => fail
18
+ #
19
+ def fail message = nil, data = {}
20
+ __wrap_assertion do
21
+ build_message FAILING, message, data
22
+ end
23
+ end
24
+
25
+ #
26
+ # Assert that a test condition is true.
27
+ # * raises RubyUnit::AssertionFailure if _value_ is false or nil
28
+ #
29
+ # value::
30
+ # The value that is being checked by the assertion
31
+ #
32
+ # message::
33
+ # The message provided to be reported for a failure
34
+ #
35
+ # assert false, "This will fail" # => fail
36
+ #
37
+ def assert value, message = nil
38
+ __assert value, ASSERT_ERROR, message, {:value=>value}
39
+ end
40
+
41
+ #
42
+ # Assert that a test condition is false.
43
+ # * raises RubyUnit::AssertionFailure unless _value_ is false or nil
44
+ #
45
+ # value::
46
+ # The value that is being checked by the assertion
47
+ #
48
+ # message::
49
+ # The message provided to be reported for a failure
50
+ #
51
+ # assertNot true, "This will fail" # => fail
52
+ #
53
+ def assertNot value, message = nil
54
+ __reject value, ASSERT_NOT_ERROR, message, {:value=>value}
55
+ end
56
+
57
+ #
58
+ # Assert that a test condition is exactly true.
59
+ # * raises RubyUnit::AssertionFailure unless _value_ is true
60
+ #
61
+ # value::
62
+ # The value that is being checked by the assertion
63
+ #
64
+ # message::
65
+ # The message provided to be reported for a failure
66
+ #
67
+ # assertTrue false, "This will fail" # => fail
68
+ #
69
+ def assertTrue value, message = nil
70
+ __assert (true == value), ASSERT_TRUE_ERROR, message, {:value=>value}
71
+ end
72
+
73
+ #
74
+ # Assert that a test condition is exactly false.
75
+ # * raises RubyUnit::AssertionFailure unless _value_ is false
76
+ #
77
+ # value::
78
+ # The value that is being checked by the assertion
79
+ #
80
+ # message::
81
+ # The message provided to be reported for a failure
82
+ #
83
+ # assertNil true, "This will fail" # => fail
84
+ #
85
+ def assertFalse value, message = nil
86
+ __assert (false == value), ASSERT_FALSE_ERROR, message, {:value=>value}
87
+ end
88
+
89
+ #
90
+ # Assert that a test condition is exactly nil.
91
+ # * raises RubyUnit::AssertionFailure unless _value_ is nil
92
+ #
93
+ # value::
94
+ # The value that is being checked by the assertion
95
+ #
96
+ # message::
97
+ # The message provided to be reported for a failure
98
+ #
99
+ # assertNil true, "This will fail" # => fail
100
+ #
101
+ def assertNil value, message = nil
102
+ __assert value.nil?, ASSERT_NIL_ERROR, message, {:value=>value}
103
+ end
104
+
105
+ #
106
+ # Assert that a test condition is not nil.
107
+ # * raises RubyUnit::AssertionFailure if _value_ is nil
108
+ #
109
+ # value::
110
+ # The value that is being checked by the assertion
111
+ #
112
+ # message::
113
+ # The message provided to be reported for a failure
114
+ #
115
+ # assertNotNil nil, "This will fail" # => fail
116
+ #
117
+ def assertNotNil value, message = nil
118
+ __reject value.nil?, ASSERT_NOT_NIL_ERROR, message, {:value=>value}
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,196 @@
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
+ __assert (descendent < klass), ASSERT_DESCENDENT_ERROR, message, {:klass=>klass, :descendent=>descendent}
107
+ end
108
+
109
+ #
110
+ # Assert that a class is not a descendent of another class
111
+ # * raises RubyUnit::AssertionFailure if _illegal_ is a descendent of _klass_
112
+ #
113
+ # klass::
114
+ # The parent class
115
+ #
116
+ # descendent::
117
+ # The illegal descendent class
118
+ #
119
+ # message::
120
+ # The message provided to be reported for a failure
121
+ #
122
+ # assertDescendent StandardError, Exception, 'It is' # => fail
123
+ #
124
+ def assertNotDescendent klass, illegal, message = nil
125
+ __reject (descendent < klass), ASSERT_NOT_DESCENDENT_ERROR, message, {:klass=>klass, :descendent=>descendent}
126
+ end
127
+
128
+ #
129
+ # Assert that a constant is defined correctly in the correct class
130
+ # * raises RubyUnit::AssertionFailure unless the constant is defined in
131
+ # the specified class and it is the correct type and value
132
+ #
133
+ # expected::
134
+ # The value that is expected for the constant
135
+ #
136
+ # klass::
137
+ # The class where the constant should be defined
138
+ #
139
+ # konstant::
140
+ # The name of the constant
141
+ #
142
+ # message::
143
+ # The message provided to be reported for a failure
144
+ #
145
+ # assertConst 42, Numbers, 'TWENTYFOUR', 'So dyslexic.' # => fail
146
+ #
147
+ def assertConst expected, klass, konstant, message = nil
148
+ __wrap_assertion do
149
+ assertConstDefined klass, konstant, message
150
+ value = klass.const_get konstant
151
+ assertIsA expected.class, value, message
152
+ assertEqual expected, value, message
153
+ end
154
+ end
155
+
156
+ #
157
+ # Assert that a constant is defined in the specified class
158
+ # * raises RubyUnit::AssertionFailure unless the constant is defined in
159
+ # the specified class
160
+ #
161
+ # klass::
162
+ # The class where the constant should be defined
163
+ #
164
+ # konstant::
165
+ # The name of the constant
166
+ #
167
+ # message::
168
+ # The message provided to be reported for a failure
169
+ #
170
+ # assertConstDefined Numbers, 'FORTYTWO', 'Mystery.' # => ??
171
+ #
172
+ def assertConstDefined klass, konstant, message = nil
173
+ __assert (klass.const_defined? konstant), ASSERT_CONST_DEFINED_ERROR, message, {:klass=>klass, :konstant=>konstant}
174
+ end
175
+
176
+ #
177
+ # Assert that a constant is not defined in the specified class
178
+ # * raises RubyUnit::AssertionFailure if the constant is defined in
179
+ # the specified class
180
+ #
181
+ # klass::
182
+ # The class where the constant should not be defined
183
+ #
184
+ # konstant::
185
+ # The name of the constant
186
+ #
187
+ # message::
188
+ # The message provided to be reported for a failure
189
+ #
190
+ # assertConstNotDefined Numbers, 'TWENTYFOUR', 'Mystery.' # => ??
191
+ #
192
+ def assertConstNotDefined klass, konstant, message = nil
193
+ __reject (klass.const_defined? konstant), ASSERT_CONST_NOT_DEFINED_ERROR, message, {:klass=>klass, :konstant=>konstant}
194
+ end
195
+ end
196
+ end
@@ -0,0 +1,80 @@
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