Skip to content

Commit

Permalink
Merge pull request #2365 from eileencodes/fix-assert_text-for-ruby-2-7
Browse files Browse the repository at this point in the history
Fix Ruby 2.7 warning in minitest assert_text
  • Loading branch information
twalpole authored Jun 15, 2020
2 parents 8440bd2 + 1b0dfa4 commit 8f86f46
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions lib/capybara/minitest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,14 @@ module Assertions

%w[text no_text title no_title current_path no_current_path].each do |assertion_name|
class_eval <<-ASSERTION, __FILE__, __LINE__ + 1
def assert_#{assertion_name} *args
def assert_#{assertion_name}(*args, **kwargs)
self.assertions +=1
subject, args = determine_subject(args)
subject.assert_#{assertion_name}(*args)
subject.assert_#{assertion_name}(*args, **kwargs)
rescue Capybara::ExpectationNotMet => e
raise ::Minitest::Assertion, e.message
end
ASSERTION
ruby2_keywords "assert_#{assertion_name}" if respond_to?(:ruby2_keywords)
end

alias_method :refute_title, :assert_no_title
Expand Down
2 changes: 1 addition & 1 deletion spec/minitest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def teardown
end

def test_assert_text
assert_text('Form')
assert_text('Form', normalize_ws: false)
assert_no_text('Not on the page')
refute_text('Also Not on the page')
end
Expand Down

0 comments on commit 8f86f46

Please sign in to comment.