您是否知道使用系统测试测试Flash消息的语法?
这就是我目前正在撰写的内容......
test 'New User signup' do
# ...
click_button 'Create User'
assert_equal 'User was successfully created.', flash[:notice]
end
失败的测试屏幕截图显示闪存存在,但测试失败并带有
NoMethodError: NoMethodError: undefined method `flash' for nil:NilClass
感谢您的帮助!
答案 0 :(得分:1)
我最终改变了断言:
assert_equal 'User was successfully created.', flash[:notice]
为:
assert_selector "#notice", text: 'User was successfully created.'
似乎可以解决问题。