Merge commit 'gaffo/lh_116_selenium_asserts' into lh_116
Conflicts: History.txt
This commit is contained in:
commit
ebd9d8ed52
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
* Support passing an ActiveRecord model to #within when in Rails mode [#68] (Luke Melia)
|
* Support passing an ActiveRecord model to #within when in Rails mode [#68] (Luke Melia)
|
||||||
* Make assert_* matchers in rails mode increment the assertions count [#123] (Amos King)
|
* Make assert_* matchers in rails mode increment the assertions count [#123] (Amos King)
|
||||||
|
* Added assert_* matchers to selenium matchers [#110] (Amos King)
|
||||||
* Added assert_contain, assert_not_contain [#86] (Mike Gaffney, Amos King)
|
* Added assert_contain, assert_not_contain [#86] (Mike Gaffney, Amos King)
|
||||||
* Add configuration options for the Selenium environment and port (Kieran Pilkington)
|
* Add configuration options for the Selenium environment and port (Kieran Pilkington)
|
||||||
* Maximize the browser window after initializing Selenium (Luke Melia)
|
* Maximize the browser window after initializing Selenium (Luke Melia)
|
||||||
|
@ -30,6 +30,16 @@ module Webrat
|
|||||||
HaveXpath.new(xpath)
|
HaveXpath.new(xpath)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def assert_have_xpath(expected)
|
||||||
|
hs = HaveXpath.new(expected)
|
||||||
|
assert hs.matches?(response), hs.failure_message
|
||||||
|
end
|
||||||
|
|
||||||
|
def assert_have_no_xpath(expected)
|
||||||
|
hs = HaveXpath.new(expected)
|
||||||
|
assert !hs.matches?(response), hs.negative_failure_message
|
||||||
|
end
|
||||||
|
|
||||||
class HaveSelector
|
class HaveSelector
|
||||||
def initialize(expected)
|
def initialize(expected)
|
||||||
@expected = expected
|
@expected = expected
|
||||||
@ -58,6 +68,20 @@ module Webrat
|
|||||||
HaveSelector.new(content)
|
HaveSelector.new(content)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Asserts that the body of the response contains
|
||||||
|
# the supplied selector
|
||||||
|
def assert_have_selector(expected)
|
||||||
|
hs = HaveSelector.new(expected)
|
||||||
|
assert hs.matches?(response), hs.failure_message
|
||||||
|
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)
|
||||||
|
assert !hs.matches?(response), hs.negative_failure_message
|
||||||
|
end
|
||||||
|
|
||||||
class HasContent #:nodoc:
|
class HasContent #:nodoc:
|
||||||
def initialize(content)
|
def initialize(content)
|
||||||
@content = content
|
@content = content
|
||||||
@ -103,6 +127,20 @@ module Webrat
|
|||||||
HasContent.new(content)
|
HasContent.new(content)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Asserts that the body of the response contain
|
||||||
|
# the supplied string or regexp
|
||||||
|
def assert_contain(content)
|
||||||
|
hc = HasContent.new(content)
|
||||||
|
assert hc.matches?(response), hc.failure_message
|
||||||
|
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)
|
||||||
|
assert !hc.matches?(response), hc.negative_failure_message
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user