Skip to content

Commit

Permalink
change assert_xpath and assert_no_xpath to be assert_have_xpath and a…
Browse files Browse the repository at this point in the history
…ssert

_have_no_xpath to be closer to the rspec matcher.
  • Loading branch information
adkron committed Jan 5, 2009
1 parent 4e0845c commit f814b79
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/webrat/core/matchers/have_xpath.rb
Expand Up @@ -79,12 +79,12 @@ def have_xpath(expected, &block)
end
alias_method :match_xpath, :have_xpath

def assert_xpath(expected, &block)
def assert_have_xpath(expected, &block)
hs = HaveXpath.new(expected, &block)
raise Test::Unit::AssertionFailedError.new(hs.failure_message) unless hs.matches?(response_body)
end

def assert_no_xpath(expected, &block)
def assert_have_no_xpath(expected, &block)
hs = HaveXpath.new(expected, &block)
raise Test::Unit::AssertionFailedError.new(hs.negative_failure_message) if hs.matches?(response_body)
end
Expand Down
12 changes: 6 additions & 6 deletions spec/public/matchers_spec.rb
Expand Up @@ -59,24 +59,24 @@
should_receive(:response_body).and_return @body
require 'test/unit'
end
describe "assert_xpath" do
describe "assert_have_xpath" do
it "should pass when body contains the selection" do
assert_xpath("//div")
assert_have_xpath("//div")
end

it "should throw an exception when the body doesnt have matching xpath" do
lambda {assert_xpath("//p")}.should raise_error(Test::Unit::AssertionFailedError)
lambda {assert_have_xpath("//p")}.should raise_error(Test::Unit::AssertionFailedError)
end

end

describe "assert_no_xpath" do
describe "assert_have_no_xpath" do
it "should pass when the body doesn't contan the xpath" do
assert_no_xpath("//p")
assert_have_no_xpath("//p")
end

it "should throw an exception when the body does contain the xpath" do
lambda {assert_no_xpath("//div")}.should raise_error(Test::Unit::AssertionFailedError)
lambda {assert_have_no_xpath("//div")}.should raise_error(Test::Unit::AssertionFailedError)
end
end
end
Expand Down

0 comments on commit f814b79

Please sign in to comment.