diff --git a/lib/capybara/node/matchers.rb b/lib/capybara/node/matchers.rb index c4abdfe2..ab95a6c6 100644 --- a/lib/capybara/node/matchers.rb +++ b/lib/capybara/node/matchers.rb @@ -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) diff --git a/lib/capybara/rspec/matchers.rb b/lib/capybara/rspec/matchers.rb index 826cf023..626285de 100644 --- a/lib/capybara/rspec/matchers.rb +++ b/lib/capybara/rspec/matchers.rb @@ -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) diff --git a/spec/rspec/matchers_spec.rb b/spec/rspec/matchers_spec.rb index f14578e5..cb6a9779 100644 --- a/spec/rspec/matchers_spec.rb +++ b/spec/rspec/matchers_spec.rb @@ -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 - "

Text

".should have_text(:cast_me) - end.to raise_error(/expected to find text "cast_me" in "Text"/) + "

Text

".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