From d4008ebc06ab59d8b13d643b2a62994130c28509 Mon Sep 17 00:00:00 2001 From: Amos King Date: Fri, 9 Jan 2009 23:13:57 -0600 Subject: [PATCH] oops didn't notice I was using the wrong matchers. Matchers now using Selenium mode. --- lib/webrat/selenium/matchers.rb | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/lib/webrat/selenium/matchers.rb b/lib/webrat/selenium/matchers.rb index a3d38f8..753ae72 100644 --- a/lib/webrat/selenium/matchers.rb +++ b/lib/webrat/selenium/matchers.rb @@ -30,6 +30,16 @@ module Webrat HaveXpath.new(xpath) end + def assert_have_xpath(expected) + hs = HaveXpath.new(expected) + raise Test::Unit::AssertionFailedError.new(hs.failure_message) unless hs.matches?(response) + end + + def assert_have_no_xpath(expected) + hs = HaveXpath.new(expected) + raise Test::Unit::AssertionFailedError.new(hs.negative_failure_message) if hs.matches?(response) + end + class HaveSelector def initialize(expected) @expected = expected @@ -58,6 +68,20 @@ module Webrat HaveSelector.new(content) end + # Asserts that the body of the response contains + # the supplied selector + def assert_have_selector(expected) + hs = HaveSelector.new(expected) + raise Test::Unit::AssertionFailedError.new(hs.failure_message) unless hs.matches?(response) + end + + # Asserts that the body of the response + # does not contain the supplied string or regepx + def assert_have_no_selector(expected) + hs = HaveSelector.new(expected) + raise Test::Unit::AssertionFailedError.new(hs.negative_failure_message) if hs.matches?(response) + end + class HasContent #:nodoc: def initialize(content) @content = content @@ -103,6 +127,20 @@ module Webrat HasContent.new(content) end + # Asserts that the body of the response contain + # the supplied string or regexp + def assert_contain(content) + hc = HasContent.new(content) + raise Test::Unit::AssertionFailedError.new(hc.failure_message) unless hc.matches?(response) + end + + # Asserts that the body of the response + # does not contain the supplied string or regepx + def assert_not_contain(content) + hc = HasContent.new(content) + raise Test::Unit::AssertionFailedError.new(hc.negative_failure_message) if hc.matches?(response) + end + end end end \ No newline at end of file