Convert count, minimum, and maximum to integers
This commit is contained in:
parent
47dbcdfdf0
commit
4ef81348a4
|
@ -43,11 +43,11 @@ module Capybara
|
|||
when options[:between]
|
||||
options[:between] === results.size
|
||||
when options[:count]
|
||||
options[:count] == results.size
|
||||
options[:count].to_i == results.size
|
||||
when options[:maximum]
|
||||
options[:maximum] >= results.size
|
||||
options[:maximum].to_i >= results.size
|
||||
when options[:minimum]
|
||||
options[:minimum] <= results.size
|
||||
options[:minimum].to_i <= results.size
|
||||
else
|
||||
results.size > 0
|
||||
end
|
||||
|
@ -75,11 +75,11 @@ module Capybara
|
|||
when options[:between]
|
||||
not(options[:between] === results.size)
|
||||
when options[:count]
|
||||
not(options[:count] == results.size)
|
||||
not(options[:count].to_i == results.size)
|
||||
when options[:maximum]
|
||||
not(options[:maximum] >= results.size)
|
||||
not(options[:maximum].to_i >= results.size)
|
||||
when options[:minimum]
|
||||
not(options[:minimum] <= results.size)
|
||||
not(options[:minimum].to_i <= results.size)
|
||||
else
|
||||
results.empty?
|
||||
end
|
||||
|
|
|
@ -54,6 +54,11 @@ shared_examples_for "has_css" do
|
|||
@session.should_not have_css("abbr", :count => 2)
|
||||
@session.should_not have_css("p a.doesnotexist", :count => 1)
|
||||
end
|
||||
|
||||
it "should coerce count to an integer" do
|
||||
@session.should have_css("p", :count => "3")
|
||||
@session.should have_css("p a#foo", :count => "1")
|
||||
end
|
||||
end
|
||||
|
||||
context "with maximum" do
|
||||
|
@ -72,6 +77,11 @@ shared_examples_for "has_css" 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")
|
||||
end
|
||||
end
|
||||
|
||||
context "with minimum" do
|
||||
|
@ -90,6 +100,11 @@ shared_examples_for "has_css" do
|
|||
@session.should_not have_css("abbr", :minimum => 2)
|
||||
@session.should_not have_css("p a.doesnotexist", :minimum => 7)
|
||||
end
|
||||
|
||||
it "should coerce minimum to an integer" do
|
||||
@session.should have_css("h2.head", :minimum => "5") # edge case
|
||||
@session.should have_css("h2", :minimum => "3")
|
||||
end
|
||||
end
|
||||
|
||||
context "with text" do
|
||||
|
@ -160,6 +175,11 @@ shared_examples_for "has_css" do
|
|||
@session.should have_no_css("abbr", :count => 2)
|
||||
@session.should have_no_css("p a.doesnotexist", :count => 1)
|
||||
end
|
||||
|
||||
it "should coerce count to an integer" do
|
||||
@session.should_not have_no_css("p", :count => "3")
|
||||
@session.should_not have_no_css("p a#foo", :count => "1")
|
||||
end
|
||||
end
|
||||
|
||||
context "with maximum" do
|
||||
|
@ -178,6 +198,11 @@ shared_examples_for "has_css" 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")
|
||||
end
|
||||
end
|
||||
|
||||
context "with minimum" do
|
||||
|
@ -196,6 +221,11 @@ shared_examples_for "has_css" do
|
|||
@session.should have_no_css("abbr", :minimum => 5)
|
||||
@session.should have_no_css("p a.doesnotexist", :minimum => 10)
|
||||
end
|
||||
|
||||
it "should coerce minimum to an integer" do
|
||||
@session.should_not have_no_css("h2.head", :minimum => "4") # edge case
|
||||
@session.should_not have_no_css("h2", :minimum => "3")
|
||||
end
|
||||
end
|
||||
|
||||
context "with text" do
|
||||
|
|
Loading…
Reference in New Issue