1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Raise the correct exeception type for minitest assertions

This commit is contained in:
Thomas Walpole 2017-06-14 11:57:22 -07:00
parent 2cce7eb4d3
commit 21844c783c
2 changed files with 9 additions and 3 deletions

View file

@ -49,7 +49,7 @@ module Capybara
subject, *args = determine_subject(args)
subject.#{assertion_name}(*args)
rescue Capybara::ExpectationNotMet => e
raise ::Minitest::Assertions, e.message
raise ::Minitest::Assertion, e.message
end
EOM
end
@ -88,7 +88,7 @@ module Capybara
subject, *args = determine_subject(args)
subject.#{assertion_name}(*args, &optional_filter_block)
rescue Capybara::ExpectationNotMet => e
raise ::Minitest::Assertions, e.message
raise ::Minitest::Assertion, e.message
end
EOM
end

View file

@ -102,6 +102,10 @@ class MinitestSpecTest < Minitest::Spec
find(:select, 'form_title').must_match_xpath('.//select[@id="form_title"]')
find(:select, 'form_title').wont_match_xpath('.//select[@id="not_on_page"]')
end
it "handles failures" do
page.must_have_select('non_existing_form_title')
end
end
RSpec.describe 'capybara/minitest/spec' do
@ -116,6 +120,8 @@ RSpec.describe 'capybara/minitest/spec' do
reporter.start
MinitestSpecTest.run reporter, {}
reporter.report
expect(output.string).to include("15 runs, 38 assertions, 0 failures, 0 errors, 0 skips")
expect(output.string).to include("16 runs, 39 assertions, 1 failures, 0 errors, 0 skips")
#Make sure error messages are displayed
expect(output.string).to include('expected to find select box "non_existing_form_title" but there were no matches')
end
end