Sto usando minitest con factory girl e capybara per i test di integrazione. Capybara funziona bene quando non lo faccio fabbrica utente ragazza per creare un oggetto utente, in questo modo:Capybara non funziona con factory girl
it "logs in a user successfully" do
visit signup_path
fill_in "Email", :with => "[email protected]"
fill_in "Password", :with => "rockawaybeach"
fill_in "Password confirmation", :with => "rockawaybeach"
click_button "Create User"
current_path == "/"
page.text.must_include "Signed up!"
visit login_path
fill_in "Email", :with => "[email protected]"
fill_in "Password", :with => "rockawaybeach"
check "Remember me"
click_button "Log in"
current_path == "/dashboard"
page.text.must_include "Logged in!"
page.text.must_include "Your Dashboard"
end
Ma non appena provo a creare un utente con la ragazza fabbrica cose strane cominciano ad accadere, come ad esempio il metodo di visita e i metodi click_button smettono di funzionare. Per esempio, non sembra essere qualcosa di sbagliato in questo test:
require "test_helper"
describe "Password resets" do
before(:each) do
@user = FactoryGirl.create(:user)
end
it "emails user when requesting password reset" do
visit login_path
click_link "password"
fill_in "Email", :with => user.email
click_button "Reset my password"
end
end
Ed ecco il mio factories.rb:
FactoryGirl.define do
factory :user do |f|
f.sequence(:email) { |n| "foo#{n}@example.com" }
f.password "secret"
f.password_confirmation "secret"
end
end
Ecco l'errore effettivo che sto ricevendo:
est_0001_emails user when requesting password reset 0:00:01.624 ERROR
undefined local variable or method `login_path' for #<#<Class:0x007fc2db48d820>:0x007fc2df337e40>
Ma, visit login_path
funziona bene se tolgo @user = FactoryGirl.create(:user)
Is ° è un bug con Capybara? O sto facendo qualcosa di sbagliato qui?
cosa succede se si sostituisce il blocco precedente nel test con let (: user) {Factory (: user)}? – shicholas
Questo ha lo stesso errore. Sembra che Capybara non stia semplicemente sottomettendo il modulo. –
Questa linea è un problema? 'fill_in" Email ",: con => user.email' Non dovrebbe essere' @ user.email'? –