public
Description: have_tag() without Rails' assert_select()
Clone URL: git://github.com/pd/rspec_hpricot_matchers.git
Search Repo:
support have_tag(".foo", :count => 0)
pd (author)
Mon Mar 10 17:47:05 -0700 2008
commit  54f6522b2c0be754131ce1ee491c6245a34a174d
tree    d9669a12fddb59ea9e24ee56688584c3155e7238
parent  72534eab4d7154f790c97fb35a309e1a5a31cc5f
...
16
17
18
19
 
 
 
20
21
22
...
16
17
18
 
19
20
21
22
23
24
0
@@ -16,7 +16,9 @@
0
       @hdoc = hdoc_for(@actual)
0
 
0
       matched_elements = @hdoc.search(@selector)
0
- return false if matched_elements.empty?
0
+ if matched_elements.empty?
0
+ return @options[:count] == 0
0
+ end
0
 
0
       if @inner_text
0
         matched_elements = filter_on_inner_text(matched_elements)
...
157
158
159
 
 
 
 
160
161
162
...
157
158
159
160
161
162
163
164
165
166
0
@@ -157,6 +157,10 @@
0
     @html.should_not have_tag('li', :count => 2..3)
0
   end
0
 
0
+ it "should treat a :count of zero as if a negative match were expected" do
0
+ @html.should have_tag('dd', :count => 0)
0
+ end
0
+
0
   it "should treat :minimum as expecting at least n matched elements" do
0
     (0..4).each { |n| @html.should have_tag('li', :minimum => n) }
0
     @html.should_not have_tag('li', :minimum => 5)

Comments

    No one has commented yet.