public
Rubygem
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
fixed specs for viewmatchers

Signed-off-by: Michael S. Klishin <michael@novemberain.com>
mholub (author)
Sat Oct 11 07:21:59 -0700 2008
michaelklishin (committer)
Sat Oct 11 21:31:08 -0700 2008
commit  d4739e7620f2f553578009c859de2dae4863c8a4
tree    607f8165a7abae6bf04d4a1884a023e5b858f0de
parent  ef6092a6ee79d112eccbea1b8862c21d46d51b99
...
37
38
39
40
 
41
42
43
44
45
46
 
47
48
49
 
50
51
52
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
55
56
57
58
 
59
60
61
62
 
63
64
65
...
95
96
97
98
 
99
100
101
102
 
103
104
105
106
 
107
108
109
...
113
114
115
116
117
118
119
120
121
122
123
 
 
124
125
126
127
 
 
128
129
130
...
37
38
39
 
40
41
42
43
 
 
 
44
45
46
 
47
48
49
50
 
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
 
71
72
73
74
 
75
76
77
78
...
108
109
110
 
111
112
113
114
 
115
116
117
118
 
119
120
121
122
...
126
127
128
 
 
 
 
 
 
 
 
129
130
131
132
 
 
133
134
135
136
137
0
@@ -37,29 +37,42 @@ describe Merb::Test::Rspec::ViewMatchers do
0
           Hpricot.should_receive(:parse).and_return @document
0
         end
0
       
0
-        it "should should pass all found elements to the block" do
0
+        it "should pass all found elements to the block" do
0
           @block_called = false
0
         
0
           @document.should_receive(:search).and_return [""]
0
-          HasTag.new("tag").matches?("") {|e| @block_called = true}
0
-        
0
-          @block_called.should be_true
0
+          HasTag.new("tag").matches?("") {|e| e.should == "" }
0
         end
0
       
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
           lambda {
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
+        end
0
+
0
+        it 'should raise ExpectationNotMetError when there are no matched elements' do
0
+          @document.should_receive(:search).and_return [""]
0
+          lambda {
0
+            @document.should have_tag(:tag) {|e| true.should be_false }
0
+          }.should raise_error(Spec::Expectations::ExpectationNotMetError, "tag:\nexpected false, got true")
0
+        end
0
+
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
+          lambda {
0
+            @document.should have_tag(:tag) { |tag| tag.should == "b" }
0
+          }.should_not raise_error(Spec::Expectations::ExpectationNotMetError)
0
         end
0
       end
0
     
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
         
0
-          outer.selector.should include(inner.selector)
0
+          inner.selector.should include(outer.selector)
0
         end
0
       end
0
     
0
@@ -95,15 +108,15 @@ describe Merb::Test::Rspec::ViewMatchers do
0
     
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
         end
0
       
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
         end
0
       
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
         end
0
       
0
         it "should include the tag's custom attributes" do
0
@@ -113,18 +126,12 @@ describe Merb::Test::Rspec::ViewMatchers do
0
       end
0
     
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
-        end
0
-      
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
         end
0
       
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")
0
         end
0
       end
0
     end

Comments