我需要測試一個只有在用戶使用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