我有以下规格:
# MUST BE TESTED WITH JAVASCRIPT. As you can see before, it is allowing
# the Log Out link. On a real page, that element is hidden.
it "logs out a user" do
user = login_user
click_link user.email
click_link "Log Out"
assert page.has_content?('Logged out')
assert page.has_content?('Company Profile')
end
我的login_user
方法在我的spec_helper.rb
文件中,如下所示:
def login_user(admin = false)
user = FactoryGirl.create(:user, :admin => admin)
visit login_path
fill_in 'Email', :with => user.email
fill_in 'Password', :with => user.password
click_button 'Go'
assert page.has_content?('Logged in')
user
end
当我添加到我的规范时,最后一次assert
失败。, js: true
当我save_and_open_page
在它之前做一个正确的事情时,页面出现了零 CSS 和大概没有 JS 的页面。由于某种原因,它没有读取资产。我认为当您运行测试时,它会像在开发模式下一样读取资产。我真的需要帮助。