我是 Rails 5.1 并使用默认系统测试进行测试
我在 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
我不明白为什么我不断收到此错误:
Error:
RetreatsTest#test_Create_a_new_Retreat:
TypeError: exception class/object expected
test/system/retreats_test.rb:36:in `block in <class:RetreatsTest>'
如果我写assert find('.alert').has_content?('Retreat was successfully saved.')
而不是assert_text
我所有的测试都通过了。
有人可以帮我弄这个吗?
编辑1:在使用回溯选项运行测试时,我得到以下信息:
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>'