Module: Spec::Matchers::FormMatcher::REXML

Defined in:
lib/rspec_form_matcher.rb

Instance Method Summary collapse

Instance Method Details

#check_xpath!Object



112
113
114
# File 'lib/rspec_form_matcher.rb', line 112

def check_xpath!
  !@document.elements[@xpath].nil?
end

#document(subject) ⇒ Object



116
117
118
119
120
121
122
123
124
125
126
# File 'lib/rspec_form_matcher.rb', line 116

def document(subject)
  if String === subject
    ::REXML::Document.new(subject).root
  elsif subject.respond_to?(:body)
    ::REXML::Document.new(subject.body).root
  elsif ::REXML::Element === subject
    subject
  else
    raise "Cannot handle this XML input type"
  end
end