From 3255c9edf0deb5275b8f316b1daeae21d390adde Mon Sep 17 00:00:00 2001 From: Michael Christenson II Date: Thu, 27 Aug 2009 11:54:03 -0400 Subject: [PATCH] Forces an integer to fix Issue #18 --- lib/webrat/core/matchers/have_xpath.rb | 2 +- spec/public/matchers/have_selector_spec.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/webrat/core/matchers/have_xpath.rb b/lib/webrat/core/matchers/have_xpath.rb index 58b2fff..7256109 100644 --- a/lib/webrat/core/matchers/have_xpath.rb +++ b/lib/webrat/core/matchers/have_xpath.rb @@ -15,7 +15,7 @@ module Webrat matched = matches(stringlike) if @options[:count] - matched.size == @options[:count] && (!@block || @block.call(matched)) + matched.size == @options[:count].to_i && (!@block || @block.call(matched)) else matched.any? && (!@block || @block.call(matched)) end diff --git a/spec/public/matchers/have_selector_spec.rb b/spec/public/matchers/have_selector_spec.rb index 79e9e74..46f6452 100644 --- a/spec/public/matchers/have_selector_spec.rb +++ b/spec/public/matchers/have_selector_spec.rb @@ -61,6 +61,10 @@ describe "have_selector" do @body.should have_selector("li", :count => 4) }.should raise_error(Spec::Expectations::ExpectationNotMetError) end + + it "should convert a string to an integer for count" do + @body.should have_selector("li", :count => "3") + end end describe "specifying nested elements" do