Skip to content

Commit

Permalink
change assert_tag and assert_no_tag to assert_have_tag and assert_no_…
Browse files Browse the repository at this point in the history
…tag so it won't conflict with rails and so that it will be more like the matchers.
  • Loading branch information
adkron committed Jan 5, 2009
1 parent ff00ae1 commit 021f197
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/webrat/core/matchers/have_tag.rb
Expand Up @@ -55,14 +55,14 @@ def have_tag(name, attributes = {}, &block)

# Asserts that the body of the response contains
# the supplied tag with the associated selectors
def assert_tag(name, attributes = {})
def assert_have_tag(name, attributes = {})
ht = HaveTag.new([name, attributes])
raise Test::Unit::AssertionFailedError.new(ht.failure_message) unless ht.matches?(response_body)
end

# Asserts that the body of the response
# does not contain the supplied string or regepx
def assert_no_tag(name, attributes = {})
def assert_have_no_tag(name, attributes = {})
ht = HaveTag.new([name, attributes])
raise Test::Unit::AssertionFailedError.new(ht.negative_failure_message) if ht.matches?(response_body)
end
Expand Down
20 changes: 10 additions & 10 deletions spec/public/matchers_spec.rb
Expand Up @@ -192,40 +192,40 @@
should_receive(:response_body).and_return @body
require 'test/unit'
end
describe "assert_tag" do
describe "assert_have_tag" do
it "should pass when body contains the tag" do
assert_tag("div")
assert_have_tag("div")
end

it "should pass when finding with additional selectors" do
assert_tag("div", :class => "inner")
assert_have_tag("div", :class => "inner")
end


it "should throw an exception when the body doesnt have matching tag" do
lambda {assert_tag("p")}.should raise_error(Test::Unit::AssertionFailedError)
lambda {assert_have_tag("p")}.should raise_error(Test::Unit::AssertionFailedError)
end

it "should throw an exception when the body doens't have a tag matching the additional selector" do
lambda {assert_tag("div", :class => "nope")}.should raise_error(Test::Unit::AssertionFailedError)
lambda {assert_have_tag("div", :class => "nope")}.should raise_error(Test::Unit::AssertionFailedError)
end
end

describe "assert_no_tag" do
describe "assert_have_no_tag" do
it "should pass when the body doesn't contan the tag" do
assert_no_tag("p")
assert_have_no_tag("p")
end

it "should pass when the body doesn't contain the tag due to additional selectors missing" do
assert_no_tag("div", :class => "nope")
assert_have_no_tag("div", :class => "nope")
end

it "should throw an exception when the body does contain the tag" do
lambda {assert_no_tag("div")}.should raise_error(Test::Unit::AssertionFailedError)
lambda {assert_have_no_tag("div")}.should raise_error(Test::Unit::AssertionFailedError)
end

it "should throw an exception when the body contains the tag with additional selectors" do
lambda {assert_no_tag("div", :class => "inner")}.should raise_error(Test::Unit::AssertionFailedError)
lambda {assert_have_no_tag("div", :class => "inner")}.should raise_error(Test::Unit::AssertionFailedError)
end
end
end
Expand Down

0 comments on commit 021f197

Please sign in to comment.