I'm Rails 5.1 and testing using the default System Tests
I've the following code in a class RetreatTest:
test "Create a new Retreat" do
visit retreats_url
click_on 'Create a new Retreat'
fill_in "Title", with: "Retreat Title"
fill_in "Tagline", with: "Retreat tagline"
select('Individual', from: 'Type')
fill_in "Description", with: "Retreat Description"
attach_file('Image', Rails.root.join('test', 'images', 'test-1.jpg'))
click_on "Submit"
assert_text("Retreat was successfully saved.")
end
I can't understand why I keep getting this error:
Error:
RetreatsTest#test_Create_a_new_Retreat:
TypeError: exception class/object expected
test/system/retreats_test.rb:36:in `block in <class:RetreatsTest>'
If I write assert find('.alert').has_content?('Retreat was successfully saved.')
instead of assert_text
all my tests pass.
Can someone help me with this?
edit 1: On running the test with the backtrace option, I get the following:
Error:
RetreatsTest#test_Create_a_new_Retreat:
TypeError: exception class/object expected
/Users/dhaliman/.rvm/gems/ruby-2.3.1/gems/capybara-2.14.2/lib/capybara/minitest.rb:52:in `raise'
/Users/dhaliman/.rvm/gems/ruby-2.3.1/gems/capybara-2.14.2/lib/capybara/minitest.rb:52:in `rescue in assert_text'
/Users/dhaliman/.rvm/gems/ruby-2.3.1/gems/capybara-2.14.2/lib/capybara/minitest.rb:48:in `assert_text'
/Users/dhaliman/Code/Workspace AVR WebApp/avr/test/system/retreats_test.rb:36:in `block in <class:RetreatsTest>'
Upgrade to the latest Capybara (2.14.4) You’re currently using 2.14.2 and there was a fix in 2.14.3 for mini test asserts that should fix the incorrect error, and have it return the correct error (that it can’t find the text)