我需要测试一个只有在用户使用Devise登录后才能使用的系统。每次使用“它”时,我都必须包含注册码。如何计算Capybara rspec测试代码?
有没有办法将以下代码考虑进去,以便"let's me make a new post"
测试和类似测试不必包含注册?
describe "new post process" do
before :all do
@user = FactoryGirl.create(:user)
@post = FactoryGirl.create(:post)
end
it "signs me in" do
visit '/users/sign_in'
within(".new_user") do
fill_in 'Email', :with => '[email protected]'
fill_in 'Password', :with => 'password'
end
click_button 'Log in'
expect(page).to have_content 'Signed in successfully'
end
it "let's me make a new post" do
visit '/users/sign_in'
within(".new_user") do
fill_in 'Email', :with => '[email protected]'
fill_in 'Password', :with => 'password'
end
click_button 'Log in'
visit '/posts/new'
expect(find(:css, 'select#post_id').value).to eq('1')
end
end
https://github.com/plataformatec/devise/wiki/How-To:-Test-with-Capybara – Jon
你想“让我做一个新的职位”测试不运行注册,对吧? – fabersky
@fabersky我希望它记住之前注册过的用户,这样我就不必在每次测试时都包含该代码 – Tom