Class: Locator::Matcher::HaveTag
- Inherits:
-
Object
- Object
- Locator::Matcher::HaveTag
- Defined in:
- lib/locator/matcher/have_tag.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#selector ⇒ Object
readonly
Returns the value of attribute selector.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
-
#failure_message ⇒ Object
TODO.
-
#initialize(*args, &block) ⇒ HaveTag
constructor
A new instance of HaveTag.
- #match_count ⇒ Object
- #match_element ⇒ Object
- #matches?(target = nil) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
4 5 6 |
# File 'lib/locator/matcher/have_tag.rb', line 4 def block @block end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
4 5 6 |
# File 'lib/locator/matcher/have_tag.rb', line 4 def count @count end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/locator/matcher/have_tag.rb', line 4 def @options end |
#selector ⇒ Object (readonly)
Returns the value of attribute selector.
4 5 6 |
# File 'lib/locator/matcher/have_tag.rb', line 4 def selector @selector end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
4 5 6 |
# File 'lib/locator/matcher/have_tag.rb', line 4 def target @target end |
Instance Method Details
#failure_message ⇒ Object
TODO
29 30 31 |
# File 'lib/locator/matcher/have_tag.rb', line 29 def # TODO "expected following text to match selector #{selector.inspect} and #{.inspect}:\n#{target}" end |
#match_count ⇒ Object
18 19 20 21 22 |
# File 'lib/locator/matcher/have_tag.rb', line 18 def match_count elements = Locator.all(target, selector, ) elements = elements.select(&block) if block elements.size == count.to_i end |
#match_element ⇒ Object
24 25 26 27 |
# File 'lib/locator/matcher/have_tag.rb', line 24 def match_element element = Locator.locate(target, selector, ) element && block ? Locator.within(element) { block.call(element) } : element end |
#matches?(target = nil) ⇒ Boolean
13 14 15 16 |
# File 'lib/locator/matcher/have_tag.rb', line 13 def matches?(target = nil) @target = target count ? match_count : !!match_element end |
#negative_failure_message ⇒ Object
33 34 35 |
# File 'lib/locator/matcher/have_tag.rb', line 33 def "expected following text to not match selector #{selector.inspect} and #{.inspect}:\n#{target}" end |