Module: Defekt::Assertions
- Included in:
- Base
- Defined in:
- lib/defekt/assertions.rb
Instance Method Summary collapse
- #equal_to!(expected, actual) ⇒ Object
- #identical_to!(expected, actual) ⇒ Object
- #included_in!(collection, member) ⇒ Object
- #instance_of!(klass, instance) ⇒ Object
- #kind_of!(klass, instance) ⇒ Object
- #nil!(value) ⇒ Object
- #not_equal_to!(expected, actual) ⇒ Object
- #not_identical_to!(expected, actual) ⇒ Object
- #not_included_in!(collection, member) ⇒ Object
- #not_instance_of!(klass, instance) ⇒ Object
- #not_kind_of!(klass, instance) ⇒ Object
- #not_nil!(value) ⇒ Object
- #not_respond_to!(object, methot) ⇒ Object
- #not_true!(value) ⇒ Object
- #respond_to!(object, methot) ⇒ Object
- #true!(value) ⇒ Object
- #verify!(mock) ⇒ Object
Instance Method Details
#equal_to!(expected, actual) ⇒ Object
27 28 29 30 31 |
# File 'lib/defekt/assertions.rb', line 27 def equal_to!(expected, actual) unless actual == expected raise Errors::EqualToError, (actual, 'is not equal to', expected) end end |
#identical_to!(expected, actual) ⇒ Object
39 40 41 42 43 |
# File 'lib/defekt/assertions.rb', line 39 def identical_to!(expected, actual) unless actual.equal?(expected) raise Errors::IdenticalToError, (actual, 'is not identical to', expected) end end |
#included_in!(collection, member) ⇒ Object
51 52 53 54 55 |
# File 'lib/defekt/assertions.rb', line 51 def included_in!(collection, member) unless collection.include?(member) raise Errors::IncludedInError, (member, 'is not included in', collection) end end |
#instance_of!(klass, instance) ⇒ Object
63 64 65 66 67 |
# File 'lib/defekt/assertions.rb', line 63 def instance_of!(klass, instance) unless instance.instance_of?(klass) raise Errors::InstanceOfError, (instance, 'is not an instance of', klass) end end |
#kind_of!(klass, instance) ⇒ Object
75 76 77 78 79 |
# File 'lib/defekt/assertions.rb', line 75 def kind_of!(klass, instance) unless instance.kind_of?(klass) raise Errors::KindOfError, (instance, 'is not a kind of', klass) end end |
#nil!(value) ⇒ Object
15 16 17 18 19 |
# File 'lib/defekt/assertions.rb', line 15 def nil!(value) unless value.nil? raise Errors::NilError, (value, 'is not', nil) end end |
#not_equal_to!(expected, actual) ⇒ Object
33 34 35 36 37 |
# File 'lib/defekt/assertions.rb', line 33 def not_equal_to!(expected, actual) if actual == expected raise Errors::NotEqualToError, (actual, 'is equal to', expected) end end |
#not_identical_to!(expected, actual) ⇒ Object
45 46 47 48 49 |
# File 'lib/defekt/assertions.rb', line 45 def not_identical_to!(expected, actual) if actual.equal?(expected) raise Errors::NotIdenticalToError, (actual, 'is identical to', expected) end end |
#not_included_in!(collection, member) ⇒ Object
57 58 59 60 61 |
# File 'lib/defekt/assertions.rb', line 57 def not_included_in!(collection, member) if collection.include?(member) raise Errors::NotIncludedInError, (member, 'is included in', collection) end end |
#not_instance_of!(klass, instance) ⇒ Object
69 70 71 72 73 |
# File 'lib/defekt/assertions.rb', line 69 def not_instance_of!(klass, instance) if instance.instance_of?(klass) raise Errors::NotInstanceOfError, (instance, 'is an instance of', klass) end end |
#not_kind_of!(klass, instance) ⇒ Object
81 82 83 84 85 |
# File 'lib/defekt/assertions.rb', line 81 def not_kind_of!(klass, instance) if instance.kind_of?(klass) raise Errors::NotKindOfError, (instance, 'is a kind of', klass) end end |
#not_nil!(value) ⇒ Object
21 22 23 24 25 |
# File 'lib/defekt/assertions.rb', line 21 def not_nil!(value) if value.nil? raise Errors::NotNilError, (value, 'is', nil) end end |
#not_respond_to!(object, methot) ⇒ Object
93 94 95 96 97 |
# File 'lib/defekt/assertions.rb', line 93 def not_respond_to!(object, methot) if object.respond_to?(methot) raise Errors::NotRespondToError, (object, 'does respond to', methot) end end |
#not_true!(value) ⇒ Object
9 10 11 12 13 |
# File 'lib/defekt/assertions.rb', line 9 def not_true!(value) if value raise Errors::NotTrueError, (value, 'is', true) end end |
#respond_to!(object, methot) ⇒ Object
87 88 89 90 91 |
# File 'lib/defekt/assertions.rb', line 87 def respond_to!(object, methot) unless object.respond_to?(methot) raise Errors::RespondToError, (object, 'does not respond to', methot) end end |