iterate text_found?'s args from first to last, not from last to first

This commit is contained in:
Andrey Botalov 2013-03-11 01:55:32 +03:00
parent aa6a0e037f
commit 7c00c53a5a
3 changed files with 9 additions and 9 deletions

View File

@ -461,9 +461,9 @@ module Capybara
private
def text_found?(*args)
options = (args.last.is_a?(Hash))? args.pop : {}
content = (args.last.is_a?(Regexp))? args.pop : args.pop.to_s
type = args.first
type = args.shift if args.first.is_a?(Symbol) or args.first.nil?
content = args.shift
options = (args.first.is_a?(Hash))? args.first : {}
count = Capybara::Helpers.normalize_whitespace(text(type)).scan(Capybara::Helpers.to_regexp(content)).count
Capybara::CountHelpers.matches_count?(count, options)

View File

@ -36,9 +36,9 @@ module Capybara
attr_reader :type, :content, :options
def initialize(*args)
@options = (args.last.is_a?(Hash))? args.pop : {}
@content = args.pop
@type = args.first
@type = args.shift if args.first.is_a?(Symbol)
@content = args.shift
@options = (args.first.is_a?(Hash))? args.first : {}
end
def matches?(actual)

View File

@ -344,10 +344,10 @@ describe Capybara::RSpecMatchers do
end.to raise_error(/expected to find text "No such Text" in "Text"/)
end
it "casts has_text? argument to string" do
it "casts Fixnum to string" do
expect do
"<h1>Text</h1>".should have_text(:cast_me)
end.to raise_error(/expected to find text "cast_me" in "Text"/)
"<h1>Text</h1>".should have_text(3)
end.to raise_error(/expected to find text "3" in "Text"/)
end
it "fails if matched text count does not equal to expected count" do