Ich erhalte den folgenden Fehler in rspec + Capybara + Poltergeist:Capybara nicht Ajax-Request warten
given!(:user_owner) { create(:user) }
given!(:second_user) { create(:user) }
given!(:question) { create(:question, user: user_owner) }
describe 'as not question owner' do
before do
login_as(second_user, scope: :user, run_callbacks: false)
visit question_path(question)
end
scenario 'can upvote just one time', js: true do
first('a#question-upvote').click
expect(first('div#question-score').text).to eq '1'
first('a#question-upvote').click
expect(first('div#question-score').text).to eq '1'
end
Ausfall/Fehler: erwarten (page.first ('div # Frage-score') Text.) .to eq '-1'
expected: "-1"
got: "0"
Wenn ich einfügen Schlaf 1:
scenario 'can upvote just one time', js: true do
first('a#question-upvote').click
sleep 1
expect(first('div#question-score').text).to eq '1'
first('a#question-upvote').click
sleep 1
expect(first('div#question-score').text).to eq '1'
end
Test.
Ich habe verstanden, dass Seite nicht auf asynchrone Anfrage gewartet. Wie kann ich den Test umschreiben, damit er gut funktioniert, ohne zu schlafen?
P.S. Entschuldigung für Englisch.
Danke Thomas. Du hast mir wieder geholfen. –