更新时间:2023-10-28 15:04:58
在我的功能顶部添加 require 'rails_helper'
最终解决了我的问题:
Adding require 'rails_helper'
at the top of my feature ended up fixing my problem:
require 'rails_helper'
describe "security", :type => :feature do
it "signs users in" do
visit new_sessions_path
fill_in "username", :with => "user"
fill_in "password", :with => "pass"
click_button "Sign In"
page.should have_content('Login Successful')
end
end
这对我来说似乎很奇怪,因为我看到的每个 rspec 和水豚的例子都没有那个要求,但是哦.问题解决了.
This seems odd to me since every example I've seen for rspec and capybara didn't have that require, but oh well. Problem solved.
require 'spec_helper'
被旧版本的 RSpec 使用.更好的答案是 require 'rails_helper'
.
require 'spec_helper'
is used by older versions of RSpec. The better answer would be require 'rails_helper'
.