Class: RSpec::Virtus::Matcher
- Inherits:
-
Object
- Object
- RSpec::Virtus::Matcher
- Defined in:
- lib/rspec-virtus/matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(attribute_name) ⇒ Matcher
constructor
A new instance of Matcher.
- #matches?(subject) ⇒ Boolean
- #of_type(type, options = {}) ⇒ Object
Constructor Details
#initialize(attribute_name) ⇒ Matcher
Returns a new instance of Matcher.
4 5 6 7 |
# File 'lib/rspec-virtus/matcher.rb', line 4 def initialize(attribute_name) @attribute_name = attribute_name = {} end |
Instance Method Details
#description ⇒ Object
9 10 11 |
# File 'lib/rspec-virtus/matcher.rb', line 9 def description "have #{@attribute_name} defined" end |
#failure_message ⇒ Object
24 25 26 |
# File 'lib/rspec-virtus/matcher.rb', line 24 def "expected #{@attribute_name} to be defined" end |
#failure_message_when_negated ⇒ Object
28 29 30 |
# File 'lib/rspec-virtus/matcher.rb', line 28 def "expected #{@attribute_name} not to be defined" end |
#matches?(subject) ⇒ Boolean
19 20 21 22 |
# File 'lib/rspec-virtus/matcher.rb', line 19 def matches?(subject) @subject = subject attribute_exists? && type_correct? end |
#of_type(type, options = {}) ⇒ Object
13 14 15 16 17 |
# File 'lib/rspec-virtus/matcher.rb', line 13 def of_type(type, ={}) [:type] = type [:member_type] = .delete(:member_type) self end |