Class: Dommy::RSpec::Matchers::HaveDomAttribute Private
- Inherits:
-
Object
- Object
- Dommy::RSpec::Matchers::HaveDomAttribute
- Defined in:
- lib/dommy/rspec/matchers.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #description ⇒ Object private
- #does_not_match?(element) ⇒ Boolean private
- #failure_message ⇒ Object private
- #failure_message_when_negated ⇒ Object private
-
#initialize(name, value) ⇒ HaveDomAttribute
constructor
private
A new instance of HaveDomAttribute.
- #matches?(element) ⇒ Boolean private
Constructor Details
#initialize(name, value) ⇒ HaveDomAttribute
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of HaveDomAttribute.
122 123 124 125 |
# File 'lib/dommy/rspec/matchers.rb', line 122 def initialize(name, value) @name = name.to_s @value = value end |
Instance Method Details
#description ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
139 140 141 142 143 144 145 |
# File 'lib/dommy/rspec/matchers.rb', line 139 def description if unset?(@value) "have DOM attribute #{@name.inspect}" else "have DOM attribute #{@name.inspect} = #{@value.inspect}" end end |
#does_not_match?(element) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
135 136 137 |
# File 'lib/dommy/rspec/matchers.rb', line 135 def does_not_match?(element) !matches?(element) end |
#failure_message ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
147 148 149 150 151 152 153 |
# File 'lib/dommy/rspec/matchers.rb', line 147 def if unset?(@value) "expected element to have attribute #{@name.inspect}, but it was missing" else "expected attribute #{@name.inspect} to equal #{@value.inspect}, got #{@actual.inspect}" end end |
#failure_message_when_negated ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
155 156 157 158 159 160 161 |
# File 'lib/dommy/rspec/matchers.rb', line 155 def if unset?(@value) "expected element NOT to have attribute #{@name.inspect}, but it was present (#{@actual.inspect})" else "expected attribute #{@name.inspect} not to equal #{@value.inspect}" end end |
#matches?(element) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
127 128 129 130 131 132 133 |
# File 'lib/dommy/rspec/matchers.rb', line 127 def matches?(element) @element = element return false unless element.has_attribute?(@name) @actual = element.get_attribute(@name) unset?(@value) ? true : @actual.to_s == @value.to_s end |