Browse files

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

  • Loading branch information...
1 parent aa6a0e0 commit 7c00c53a5a7caa561c397df94ebc7d55cf2be46b @abotalov abotalov committed Mar 11, 2013
Showing with 9 additions and 9 deletions.
  1. +3 −3 lib/capybara/node/matchers.rb
  2. +3 −3 lib/capybara/rspec/matchers.rb
  3. +3 −3 spec/rspec/matchers_spec.rb
View
6 lib/capybara/node/matchers.rb
@@ -461,9 +461,9 @@ def ==(other)
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
6 lib/capybara/rspec/matchers.rb
@@ -36,9 +36,9 @@ class HaveText < Matcher
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
6 spec/rspec/matchers_spec.rb
@@ -344,10 +344,10 @@
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

0 comments on commit 7c00c53

Please sign in to comment.