Class: SubstitutionContext

Inherits:
Object
  • Object
show all
Defined in:
lib/rails/dom/testing/assertions/selector_assertions/substitution_context.rb

Instance Method Summary collapse

Constructor Details

#initializeSubstitutionContext

Returns a new instance of SubstitutionContext.


2
3
4
# File 'lib/rails/dom/testing/assertions/selector_assertions/substitution_context.rb', line 2

def initialize
  @substitute = '?'
end

Instance Method Details

#match(matches, attribute, matcher) ⇒ Object


12
13
14
# File 'lib/rails/dom/testing/assertions/selector_assertions/substitution_context.rb', line 12

def match(matches, attribute, matcher)
  matches.find_all { |node| node[attribute] =~ Regexp.new(matcher) }
end

#substitute!(selector, values) ⇒ Object


6
7
8
9
10
# File 'lib/rails/dom/testing/assertions/selector_assertions/substitution_context.rb', line 6

def substitute!(selector, values)
  while !values.empty? && substitutable?(values.first) && selector.index(@substitute)
    selector.sub! @substitute, matcher_for(values.shift)
  end
end