Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/webrat/core/matchers/have_xpath.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def nokogiri_matches(stringlike)
add_options_conditions_to(@query)

@document = Webrat::XML.document(stringlike)
@document.xpath(*@query)
@document.xpath(@query)
end

def add_options_conditions_to(query)
Expand Down
7 changes: 6 additions & 1 deletion spec/public/matchers/have_xpath_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<li>Second</li>
<li><a href="http://example.org">Third</a></li>
</ul>
<pre>line\nbroken</pre>
</div>
HTML
end
Expand All @@ -31,6 +32,10 @@
@body.should have_xpath("//div", :content => "hello, world!")
end

it "should be able to match an XPATH with content with line breaks" do
@body.should have_xpath("//pre", :content => "line\nbroken")
end

it "should not match an XPATH without content" do
@body.should_not have_xpath("//div", :content => "not present")
end
Expand Down Expand Up @@ -88,7 +93,7 @@
end
}.should raise_error(Spec::Expectations::ExpectationNotMetError)
end

it "should match negative expectations in the block" do
@body.should have_xpath("//div") do |node|
node.should_not have_xpath("//div[@id='main']")
Expand Down