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
|
end
|
||||||
alias_method :match_xpath, :have_xpath
|
alias_method :match_xpath, :have_xpath
|
||||||
|
|
||||||
def assert_xpath(expected, &block)
|
def assert_have_xpath(expected, &block)
|
||||||
hs = HaveXpath.new(expected, &block)
|
hs = HaveXpath.new(expected, &block)
|
||||||
raise Test::Unit::AssertionFailedError.new(hs.failure_message) unless hs.matches?(response_body)
|
raise Test::Unit::AssertionFailedError.new(hs.failure_message) unless hs.matches?(response_body)
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_no_xpath(expected, &block)
|
def assert_have_no_xpath(expected, &block)
|
||||||
hs = HaveXpath.new(expected, &block)
|
hs = HaveXpath.new(expected, &block)
|
||||||
raise Test::Unit::AssertionFailedError.new(hs.negative_failure_message) if hs.matches?(response_body)
|
raise Test::Unit::AssertionFailedError.new(hs.negative_failure_message) if hs.matches?(response_body)
|
||||||
end
|
end
|
||||||
|
@ -59,24 +59,24 @@ describe Webrat::Matchers do
|
|||||||
should_receive(:response_body).and_return @body
|
should_receive(:response_body).and_return @body
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
end
|
end
|
||||||
describe "assert_xpath" do
|
describe "assert_have_xpath" do
|
||||||
it "should pass when body contains the selection" do
|
it "should pass when body contains the selection" do
|
||||||
assert_xpath("//div")
|
assert_have_xpath("//div")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should throw an exception when the body doesnt have matching xpath" do
|
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
|
||||||
|
|
||||||
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
|
it "should pass when the body doesn't contan the xpath" do
|
||||||
assert_no_xpath("//p")
|
assert_have_no_xpath("//p")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should throw an exception when the body does contain the xpath" do
|
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
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user