change assert_xpath and assert_no_xpath to be assert_have_xpath and assert
_have_no_xpath to be closer to the rspec matcher.
This commit is contained in:
parent
4e0845c8db
commit
f814b79ac1
|
@ -79,12 +79,12 @@ module Webrat
|
|||
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
|
||||
|
|
|
@ -59,24 +59,24 @@ describe Webrat::Matchers do
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue