Fixing issue with have_xpath and have_css when count is 0
This commit is contained in:
parent
48166e14ad
commit
8117598927
|
@ -48,8 +48,6 @@ module Capybara
|
|||
|
||||
def matches_count?(count)
|
||||
case
|
||||
when count.zero?
|
||||
false
|
||||
when options[:between]
|
||||
options[:between] === count
|
||||
when options[:count]
|
||||
|
|
|
@ -31,21 +31,18 @@ Capybara::SpecHelper.spec '#has_css?' do
|
|||
it "should be true if the content occurs within the range given" do
|
||||
@session.should have_css("p", :between => 1..4)
|
||||
@session.should have_css("p a#foo", :between => 1..3)
|
||||
@session.should have_css("p a.doesnotexist", :between => 0..8)
|
||||
end
|
||||
|
||||
it "should be false if the content occurs more or fewer times than range" do
|
||||
@session.should_not have_css("p", :between => 6..11 )
|
||||
@session.should_not have_css("p a#foo", :between => 4..7)
|
||||
end
|
||||
|
||||
it "should be false if the content isn't on the page at all" do
|
||||
@session.should_not have_css("abbr", :between => 1..8)
|
||||
@session.should_not have_css("p a.doesnotexist", :between => 3..8)
|
||||
end
|
||||
end
|
||||
|
||||
context "with count" do
|
||||
it "should be true if the content is on the page the given number of times" do
|
||||
it "should be true if the content occurs the given number of times" do
|
||||
@session.should have_css("p", :count => 3)
|
||||
@session.should have_css("p a#foo", :count => 1)
|
||||
@session.should have_css("p a.doesnotexist", :count => 0)
|
||||
|
@ -54,10 +51,6 @@ Capybara::SpecHelper.spec '#has_css?' do
|
|||
it "should be false if the content occurs a different number of times than the given" do
|
||||
@session.should_not have_css("p", :count => 6)
|
||||
@session.should_not have_css("p a#foo", :count => 2)
|
||||
end
|
||||
|
||||
it "should be false if the content isn't on the page at all" do
|
||||
@session.should_not have_css("abbr", :count => 2)
|
||||
@session.should_not have_css("p a.doesnotexist", :count => 1)
|
||||
end
|
||||
|
||||
|
@ -71,6 +64,8 @@ Capybara::SpecHelper.spec '#has_css?' do
|
|||
it "should be true when content occurs same or fewer times than given" do
|
||||
@session.should have_css("h2.head", :maximum => 5) # edge case
|
||||
@session.should have_css("h2", :maximum => 10)
|
||||
@session.should have_css("p a.doesnotexist", :maximum => 1)
|
||||
@session.should have_css("p a.doesnotexist", :maximum => 0)
|
||||
end
|
||||
|
||||
it "should be false when content occurs more times than given" do
|
||||
|
@ -79,11 +74,6 @@ Capybara::SpecHelper.spec '#has_css?' do
|
|||
@session.should_not have_css("p", :maximum => 1)
|
||||
end
|
||||
|
||||
it "should be false if the content isn't on the page at all" do
|
||||
@session.should_not have_css("abbr", :maximum => 2)
|
||||
@session.should_not have_css("p a.doesnotexist", :maximum => 1)
|
||||
end
|
||||
|
||||
it "should coerce maximum to an integer" do
|
||||
@session.should have_css("h2.head", :maximum => "5") # edge case
|
||||
@session.should have_css("h2", :maximum => "10")
|
||||
|
@ -94,17 +84,14 @@ Capybara::SpecHelper.spec '#has_css?' do
|
|||
it "should be true when content occurs same or more times than given" do
|
||||
@session.should have_css("h2.head", :minimum => 5) # edge case
|
||||
@session.should have_css("h2", :minimum => 3)
|
||||
@session.should have_css("p a.doesnotexist", :minimum => 0)
|
||||
end
|
||||
|
||||
it "should be false when content occurs fewer times than given" do
|
||||
@session.should_not have_css("h2.head", :minimum => 6) # edge case
|
||||
@session.should_not have_css("h2", :minimum => 8)
|
||||
@session.should_not have_css("p", :minimum => 10)
|
||||
end
|
||||
|
||||
it "should be false if the content isn't on the page at all" do
|
||||
@session.should_not have_css("abbr", :minimum => 2)
|
||||
@session.should_not have_css("p a.doesnotexist", :minimum => 7)
|
||||
@session.should_not have_css("p a.doesnotexist", :minimum => 1)
|
||||
end
|
||||
|
||||
it "should coerce minimum to an integer" do
|
||||
|
@ -159,15 +146,12 @@ Capybara::SpecHelper.spec '#has_no_css?' do
|
|||
it "should be false if the content occurs within the range given" do
|
||||
@session.should_not have_no_css("p", :between => 1..4)
|
||||
@session.should_not have_no_css("p a#foo", :between => 1..3)
|
||||
@session.should_not have_no_css("p a.doesnotexist", :between => 0..2)
|
||||
end
|
||||
|
||||
it "should be true if the content occurs more or fewer times than range" do
|
||||
@session.should have_no_css("p", :between => 6..11 )
|
||||
@session.should have_no_css("p a#foo", :between => 4..7)
|
||||
end
|
||||
|
||||
it "should be true if the content isn't on the page at all" do
|
||||
@session.should have_no_css("abbr", :between => 1..8)
|
||||
@session.should have_no_css("p a.doesnotexist", :between => 3..8)
|
||||
end
|
||||
end
|
||||
|
@ -176,15 +160,12 @@ Capybara::SpecHelper.spec '#has_no_css?' do
|
|||
it "should be false if the content is on the page the given number of times" do
|
||||
@session.should_not have_no_css("p", :count => 3)
|
||||
@session.should_not have_no_css("p a#foo", :count => 1)
|
||||
@session.should_not have_no_css("p a.doesnotexist", :count => 0)
|
||||
end
|
||||
|
||||
it "should be true if the content is on the page the given number of times" do
|
||||
@session.should have_no_css("p", :count => 6)
|
||||
@session.should have_no_css("p a#foo", :count => 2)
|
||||
end
|
||||
|
||||
it "should be true if the content isn't on the page at all" do
|
||||
@session.should have_no_css("abbr", :count => 2)
|
||||
@session.should have_no_css("p a.doesnotexist", :count => 1)
|
||||
end
|
||||
|
||||
|
@ -198,6 +179,7 @@ Capybara::SpecHelper.spec '#has_no_css?' do
|
|||
it "should be false when content occurs same or fewer times than given" do
|
||||
@session.should_not have_no_css("h2.head", :maximum => 5) # edge case
|
||||
@session.should_not have_no_css("h2", :maximum => 10)
|
||||
@session.should_not have_no_css("p a.doesnotexist", :maximum => 0)
|
||||
end
|
||||
|
||||
it "should be true when content occurs more times than given" do
|
||||
|
@ -206,11 +188,6 @@ Capybara::SpecHelper.spec '#has_no_css?' do
|
|||
@session.should have_no_css("p", :maximum => 1)
|
||||
end
|
||||
|
||||
it "should be true if the content isn't on the page at all" do
|
||||
@session.should have_no_css("abbr", :maximum => 5)
|
||||
@session.should have_no_css("p a.doesnotexist", :maximum => 10)
|
||||
end
|
||||
|
||||
it "should coerce maximum to an integer" do
|
||||
@session.should_not have_no_css("h2.head", :maximum => "5") # edge case
|
||||
@session.should_not have_no_css("h2", :maximum => "10")
|
||||
|
@ -221,17 +198,14 @@ Capybara::SpecHelper.spec '#has_no_css?' do
|
|||
it "should be false when content occurs same or more times than given" do
|
||||
@session.should_not have_no_css("h2.head", :minimum => 5) # edge case
|
||||
@session.should_not have_no_css("h2", :minimum => 3)
|
||||
@session.should_not have_no_css("p a.doesnotexist", :minimum => 0)
|
||||
end
|
||||
|
||||
it "should be true when content occurs fewer times than given" do
|
||||
@session.should have_no_css("h2.head", :minimum => 6) # edge case
|
||||
@session.should have_no_css("h2", :minimum => 8)
|
||||
@session.should have_no_css("p", :minimum => 15)
|
||||
end
|
||||
|
||||
it "should be true if the content isn't on the page at all" do
|
||||
@session.should have_no_css("abbr", :minimum => 5)
|
||||
@session.should have_no_css("p a.doesnotexist", :minimum => 10)
|
||||
@session.should have_no_css("p a.doesnotexist", :minimum => 1)
|
||||
end
|
||||
|
||||
it "should coerce minimum to an integer" do
|
||||
|
|
|
@ -34,21 +34,17 @@ Capybara::SpecHelper.spec '#has_xpath?' do
|
|||
end
|
||||
|
||||
context "with count" do
|
||||
it "should be true if the content is on the page the given number of times" do
|
||||
it "should be true if the content occurs the given number of times" do
|
||||
@session.should have_xpath("//p", :count => 3)
|
||||
@session.should have_xpath("//p//a[@id='foo']", :count => 1)
|
||||
@session.should have_xpath("//p[contains(.,'est')]", :count => 1)
|
||||
@session.should have_xpath("//p//a[@id='doesnotexist']", :count => 0)
|
||||
end
|
||||
|
||||
it "should be false if the content is on the page the given number of times" do
|
||||
it "should be false if the content occurs a different number of times than the given" do
|
||||
@session.should_not have_xpath("//p", :count => 6)
|
||||
@session.should_not have_xpath("//p//a[@id='foo']", :count => 2)
|
||||
@session.should_not have_xpath("//p[contains(.,'est')]", :count => 5)
|
||||
end
|
||||
|
||||
it "should be false if the content isn't on the page at all" do
|
||||
@session.should_not have_xpath("//abbr", :count => 2)
|
||||
@session.should_not have_xpath("//p//a[@id='doesnotexist']", :count => 1)
|
||||
end
|
||||
end
|
||||
|
@ -102,20 +98,17 @@ Capybara::SpecHelper.spec '#has_no_xpath?' do
|
|||
end
|
||||
|
||||
context "with count" do
|
||||
it "should be false if the content is on the page the given number of times" do
|
||||
it "should be false if the content occurs the given number of times" do
|
||||
@session.should_not have_no_xpath("//p", :count => 3)
|
||||
@session.should_not have_no_xpath("//p//a[@id='foo']", :count => 1)
|
||||
@session.should_not have_no_xpath("//p[contains(.,'est')]", :count => 1)
|
||||
@session.should_not have_no_xpath("//p//a[@id='doesnotexist']", :count => 0)
|
||||
end
|
||||
|
||||
it "should be true if the content is on the page the wrong number of times" do
|
||||
it "should be true if the content occurs a different number of times than the given" do
|
||||
@session.should have_no_xpath("//p", :count => 6)
|
||||
@session.should have_no_xpath("//p//a[@id='foo']", :count => 2)
|
||||
@session.should have_no_xpath("//p[contains(.,'est')]", :count => 5)
|
||||
end
|
||||
|
||||
it "should be true if the content isn't on the page at all" do
|
||||
@session.should have_no_xpath("//abbr", :count => 2)
|
||||
@session.should have_no_xpath("//p//a[@id='doesnotexist']", :count => 1)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue