added code, working on specs
This commit is contained in:
parent
ee86067829
commit
fbcd509097
|
@ -51,5 +51,17 @@ 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)
|
||||||
|
assert(contain(content))
|
||||||
|
end
|
||||||
|
|
||||||
|
# Asserts that the body of the response
|
||||||
|
# does not contain the supplied string or regepx
|
||||||
|
def assert_not_contain(content)
|
||||||
|
assert(!contain(content))
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -155,8 +155,51 @@ describe Webrat::Matchers do
|
||||||
@body.should contain(/hello, world/)
|
@body.should contain(/hello, world/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "asserts for contains," do
|
||||||
|
describe "assert_contain" do
|
||||||
|
it "should pass when containing the text" do
|
||||||
|
assert_contain("hello, world")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should pass when containing the regexp" do
|
||||||
|
assert_contain(/hello, world/)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should throw an exception when it the body doesnt contain the text" do
|
||||||
|
require 'test/unit'
|
||||||
|
lambda {assert_contain("monkeys")}.should raise_error(Test::Unit::AssertionFailure)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should throw an exception when it the body doesnt contain the regexp" do
|
||||||
|
require 'test/unit'
|
||||||
|
lambda {assert_contain(/monkeys/)}.should raise_error(Test::Unit::AssertionFailure)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "assert_not_contain" do
|
||||||
|
it "should pass when not containing the text" do
|
||||||
|
assert_not_contain("hello, world")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should pass when not containing the regexp" do
|
||||||
|
assert_not_contain(/monkeys/)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should throw an exception when it the body does contain the text" do
|
||||||
|
require 'test/unit'
|
||||||
|
lambda {assert_not_contain("hello, world")}.should raise_error(Test::Unit::AssertionFailure)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should throw an exception when it the body does contain the regexp" do
|
||||||
|
require 'test/unit'
|
||||||
|
lambda {assert_not_contain(/hello, world/)}.should raise_error(Test::Unit::AssertionFailure)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "#failure_message" do
|
describe "#failure_message" do
|
||||||
|
|
||||||
it "should include the content string" do
|
it "should include the content string" do
|
||||||
hc = Webrat::Matchers::HasContent.new("hello, world!")
|
hc = Webrat::Matchers::HasContent.new("hello, world!")
|
||||||
hc.matches?(@body)
|
hc.matches?(@body)
|
||||||
|
|
Loading…
Reference in New Issue