Module: Test::Unit::Assertions
- Defined in:
- lib/xqsr3/extensions/test/unit/assert_eql.rb,
lib/xqsr3/extensions/test/unit/assert_not.rb,
lib/xqsr3/extensions/test/unit/assert_true.rb,
lib/xqsr3/extensions/test/unit/assert_false.rb,
lib/xqsr3/extensions/test/unit/assert_not_eql.rb,
lib/xqsr3/extensions/test/unit/assert_subclass_of.rb,
lib/xqsr3/extensions/test/unit/assert_superclass_of.rb,
lib/xqsr3/extensions/test/unit/assert_raise_with_message.rb
Instance Method Summary collapse
- #assert_eql(expected, actual, failure_message = '') ⇒ Object
- #assert_false(expression, failure_message = '') ⇒ Object
- #assert_not(test, failure_message = '') ⇒ Object
- #assert_not_eql(expected, actual, failure_message = '') ⇒ Object
- #assert_raise_with_message(type_spec, message_spec, failure_message = nil) ⇒ Object
- #assert_subclass_of(parent_class, tested_class, failure_message = nil) ⇒ Object
- #assert_superclass_of(child_class, tested_class, failure_message = nil) ⇒ Object
- #assert_true(expression, failure_message = '') ⇒ Object
Instance Method Details
#assert_eql(expected, actual, failure_message = '') ⇒ Object
9 10 11 12 |
# File 'lib/xqsr3/extensions/test/unit/assert_eql.rb', line 9 def assert_eql(expected, actual, = '') assert expected.eql?(actual), end |
#assert_false(expression, failure_message = '') ⇒ Object
9 10 11 12 |
# File 'lib/xqsr3/extensions/test/unit/assert_false.rb', line 9 def assert_false(expression, = '') assert ::FalseClass === (expression), end |
#assert_not(test, failure_message = '') ⇒ Object
9 10 11 12 |
# File 'lib/xqsr3/extensions/test/unit/assert_not.rb', line 9 def assert_not(test, = '') assert !(test), end |
#assert_not_eql(expected, actual, failure_message = '') ⇒ Object
9 10 11 12 |
# File 'lib/xqsr3/extensions/test/unit/assert_not_eql.rb', line 9 def assert_not_eql(expected, actual, = '') assert !(expected.eql?(actual)), end |
#assert_raise_with_message(type_spec, message_spec, failure_message = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 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 |
# File 'lib/xqsr3/extensions/test/unit/assert_raise_with_message.rb', line 9 def (type_spec, , = nil) unless block_given? msg = "WARNING: no block_given to assert_raise_with_message() called from: #{caller[0]}" warn "\n#{msg}" assert false, msg end case type_spec when ::Array, nil ; else type_spec = [ type_spec ] end case when ::Array, nil ; else = [ ] end begin yield assert false, "expected did not throw an exception" rescue Exception => x if type_spec assert false, "exception not of any of required types (#{type_spec.join(', ')}); #{x.class} given" unless type_spec.any? { |c| x.is_a? c} end if assert false, "exception message not of any of required messages; '#{x.}' given" unless .any? do |m| case m when ::Regexp x. =~ m when ::String x. == m else warn "\nunsupported message_spec entry '#{m}' (#{m.class})" end end end assert true end end |
#assert_subclass_of(parent_class, tested_class, failure_message = nil) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/xqsr3/extensions/test/unit/assert_subclass_of.rb', line 9 def assert_subclass_of(parent_class, tested_class, = nil) ||= "#{tested_class} is not a subclass of #{parent_class}" assert (tested_class < parent_class), end |
#assert_superclass_of(child_class, tested_class, failure_message = nil) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/xqsr3/extensions/test/unit/assert_superclass_of.rb', line 9 def assert_superclass_of(child_class, tested_class, = nil) ||= "#{tested_class} is not a superclass of #{child_class}" assert (child_class < tested_class), end |
#assert_true(expression, failure_message = '') ⇒ Object
9 10 11 12 |
# File 'lib/xqsr3/extensions/test/unit/assert_true.rb', line 9 def assert_true(expression, = '') assert ::TrueClass === (expression), end |