Class: RSpec::Virtus::Matcher
- Inherits:
-
Object
- Object
- RSpec::Virtus::Matcher
- Defined in:
- lib/rspec-virtus/matcher.rb
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(attribute_name) ⇒ Matcher
constructor
A new instance of Matcher.
- #matches?(subject) ⇒ Boolean
- #negative_failure_message ⇒ Object
- #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 @options = {} end |
Instance Method Details
#failure_message ⇒ Object
20 21 22 |
# File 'lib/rspec-virtus/matcher.rb', line 20 def "expected #{@attribute_name} to be defined" end |
#matches?(subject) ⇒ Boolean
15 16 17 18 |
# File 'lib/rspec-virtus/matcher.rb', line 15 def matches?(subject) @subject = subject attribute_exists? && type_correct? end |
#negative_failure_message ⇒ Object
24 25 26 |
# File 'lib/rspec-virtus/matcher.rb', line 24 def "expected #{@attribute_name} not to be defined" end |
#of_type(type, options = {}) ⇒ Object
9 10 11 12 13 |
# File 'lib/rspec-virtus/matcher.rb', line 9 def of_type(type, ={}) @options[:type] = type @options[:member_type] = .delete(:member_type) self end |