Merge commit 'gaffo/lh_123' into lh_123

Conflicts:
	History.txt
This commit is contained in:
Bryan Helmkamp 2009-01-17 16:27:39 -05:00
commit 55bc6b8e00
6 changed files with 13 additions and 8 deletions

View File

@ -23,6 +23,7 @@
* Minor enhancements * Minor enhancements
* 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)
* 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)

View File

@ -55,14 +55,14 @@ module Webrat
# the supplied string or regexp # the supplied string or regexp
def assert_contain(content) def assert_contain(content)
hc = HasContent.new(content) hc = HasContent.new(content)
raise Test::Unit::AssertionFailedError.new(hc.failure_message) unless hc.matches?(response_body) assert hc.matches?(response_body), hc.failure_message
end end
# Asserts that the body of the response # Asserts that the body of the response
# does not contain the supplied string or regepx # does not contain the supplied string or regepx
def assert_not_contain(content) def assert_not_contain(content)
hc = HasContent.new(content) hc = HasContent.new(content)
raise Test::Unit::AssertionFailedError.new(hc.negative_failure_message) if hc.matches?(response_body) assert !hc.matches?(response_body), hc.negative_failure_message
end end
end end

View File

@ -38,14 +38,14 @@ module Webrat
# the supplied selector # the supplied selector
def assert_have_selector(expected) def assert_have_selector(expected)
hs = HaveSelector.new(expected) hs = HaveSelector.new(expected)
raise Test::Unit::AssertionFailedError.new(hs.failure_message) unless hs.matches?(response_body) assert hs.matches?(response_body), hs.failure_message
end end
# Asserts that the body of the response # Asserts that the body of the response
# does not contain the supplied string or regepx # does not contain the supplied string or regepx
def assert_have_no_selector(expected) def assert_have_no_selector(expected)
hs = HaveSelector.new(expected) hs = HaveSelector.new(expected)
raise Test::Unit::AssertionFailedError.new(hs.negative_failure_message) if hs.matches?(response_body) assert !hs.matches?(response_body), hs.negative_failure_message
end end
end end

View File

@ -57,14 +57,14 @@ module Webrat
# the supplied tag with the associated selectors # the supplied tag with the associated selectors
def assert_have_tag(name, attributes = {}) def assert_have_tag(name, attributes = {})
ht = HaveTag.new([name, attributes]) ht = HaveTag.new([name, attributes])
raise Test::Unit::AssertionFailedError.new(ht.failure_message) unless ht.matches?(response_body) assert ht.matches?(response_body), ht.failure_message
end end
# Asserts that the body of the response # Asserts that the body of the response
# does not contain the supplied string or regepx # does not contain the supplied string or regepx
def assert_have_no_tag(name, attributes = {}) def assert_have_no_tag(name, attributes = {})
ht = HaveTag.new([name, attributes]) ht = HaveTag.new([name, attributes])
raise Test::Unit::AssertionFailedError.new(ht.negative_failure_message) if ht.matches?(response_body) assert !ht.matches?(response_body), ht.negative_failure_message
end end
end end

View File

@ -81,12 +81,12 @@ module Webrat
def assert_have_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) assert hs.matches?(response_body), hs.failure_message
end end
def assert_have_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) assert !hs.matches?(response_body), hs.negative_failure_message
end end
end end

View File

@ -55,6 +55,7 @@ describe Webrat::Matchers do
end end
describe 'asserts for xpath' do describe 'asserts for xpath' do
include Test::Unit::Assertions
before(:each) do before(:each) do
should_receive(:response_body).and_return @body should_receive(:response_body).and_return @body
require 'test/unit' require 'test/unit'
@ -114,6 +115,7 @@ describe Webrat::Matchers do
end end
describe "asserts for selector," do describe "asserts for selector," do
include Test::Unit::Assertions
before(:each) do before(:each) do
should_receive(:response_body).and_return @body should_receive(:response_body).and_return @body
require 'test/unit' require 'test/unit'
@ -188,6 +190,7 @@ describe Webrat::Matchers do
end end
describe "asserts for tags," do describe "asserts for tags," do
include Test::Unit::Assertions
before(:each) do before(:each) do
should_receive(:response_body).and_return @body should_receive(:response_body).and_return @body
require 'test/unit' require 'test/unit'
@ -254,6 +257,7 @@ describe Webrat::Matchers do
end end
describe "asserts for contains," do describe "asserts for contains," do
include Test::Unit::Assertions
before(:each) do before(:each) do
should_receive(:response_body).and_return @body should_receive(:response_body).and_return @body
require 'test/unit' require 'test/unit'