0
@@ -37,29 +37,42 @@ describe Merb::Test::Rspec::ViewMatchers do
0
Hpricot.should_receive(:parse).and_return @document
0
- it "should
should pass all found elements to the block" do
0
+ it "should
pass all found elements to the block" do
0
@document.should_receive(:search).and_return [""]
0
- HasTag.new("tag").matches?("") {|e| @block_called = true}
0
- @block_called.should be_true
0
+ HasTag.new("tag").matches?("") {|e| e.should == "" }
0
- it
"should not intercept any errors raised in the block" do
0
+ it
'should intercept errors raised in the block' do
0
@document.should_receive(:search).and_return [""]
0
HasTag.new("tag").matches?("") {|e| true.should be_false }
0
- }.should raise_error(Spec::Expectations::ExpectationNotMetError)
0
+ }.should_not raise_error(Spec::Expectations::ExpectationNotMetError)
0
+ it 'should raise ExpectationNotMetError when there are no matched elements' do
0
+ @document.should_receive(:search).and_return [""]
0
+ @document.should have_tag(:tag) {|e| true.should be_false }
0
+ }.should raise_error(Spec::Expectations::ExpectationNotMetError, "tag:\nexpected false, got true")
0
+ #part of bugfix for #329
0
+ it 'should not raise error if block for first of matched elements by xpath expression fails' do
0
+ @document.should_receive(:search).and_return ["a", "b"]
0
+ @document.should have_tag(:tag) { |tag| tag.should == "b" }
0
+ }.should_not raise_error(Spec::Expectations::ExpectationNotMetError)
0
describe "#with_tag" do
0
- it "should set @
inner_tag" do
0
+ it "should set @
outer_has_tag" do
0
outer = HasTag.new("outer")
0
inner = outer.with_tag("inner")
0
-
outer.selector.should include(inner.selector)
0
+
inner.selector.should include(outer.selector)
0
@@ -95,15 +108,15 @@ describe Merb::Test::Rspec::ViewMatchers do
0
describe "#failure_message" do
0
it "should include the tag name" do
0
- HasTag.new("anytag").failure_message.should include("
<anytag")
0
+ HasTag.new("anytag").failure_message.should include("
anytag")
0
it "should include the tag's id" do
0
- HasTag.new("div", :id => :spacer).failure_message.should include("
<div id=\"spacer\"")
0
+ HasTag.new("div", :id => :spacer).failure_message.should include("
div#spacer")
0
it "should include the tag's class" do
0
- HasTag.new("div", :class => :header).failure_message.should include("
<div class=\"header\"")
0
+ HasTag.new("div", :class => :header).failure_message.should include("
div.header")
0
it "should include the tag's custom attributes" do
0
@@ -113,18 +126,12 @@ describe Merb::Test::Rspec::ViewMatchers do
0
describe "id, class, and attributes for error messages" do
0
- it "should start with a space for a class, id, or custom attribute" do
0
- HasTag.new("tag", :id => "identifier").id_for_error.should =~ /^ /
0
- HasTag.new("tag", :class => "classifier").class_for_error.should =~ /^ /
0
- HasTag.new("tag", :rand => "attr").attributes_for_error.should =~ /^ /
0
- it "should have 'class=\"classifier\"' in class_for_error" do
0
- HasTag.new("tag", :class => "classifier").class_for_error.should include("class=\"classifier\"")
0
+ it "should have '.classifier' in class_for_error" do
0
+ HasTag.new("tag", :class => "classifier").class_for_error.should include(".classifier")
0
- it "should have 'id=\"identifier\" in id_for_error" do
0
- HasTag.new("tag", :id => "identifier").id_for_error.should include("id=\"identifier\"")
0
+ it "should have '#identifier' in id_for_error" do
0
+ HasTag.new("tag", :id => "identifier").id_for_error.should include("#identifier")