현재 rspec을 사용하여 통합 테스트를 작성 중입니다. 나는에 문제가있는 시험은 상당히 symple입니다 :테스트 환경에서 깜박임이 표시되지 않음
문제는 개발하는 알았어 플래시 메시지입니다
require 'rails_helper'
feature 'Accounts' do
scenario 'creating an account' do
visit root_path
click_link 'Get Started'
fill_in 'Name', with: 'Test'
click_button 'Create account'
save_and_open_page
success_message = 'Your account has been successfully created'
expect(page).to have_content(success_message)
end
end
sign_up_spec.rb
def create
@account = Account.new(account_params)
authorize @account
if @account.save
flash[:notice] = 'Your account has been successfully created'
redirect_to :root
else
render :new
end
accounts_controller.rb 성공적인 계정 생성 은이 나타나지만 테스트 스위트를 시작하면 rspec에서 오류가 발생합니다. 성공 메시지를 발견하고 참으로 save_and_open_page
사용 후, 아무것도
Started POST "/accounts" for 127.0.0.1 at 2017-05-04 18:27:20 +0200
Processing by AccountsController#create as HTML
Parameters: {"utf8"=>"✓", "account"=>{"name"=>"Test"}, "commit"=>"Create account"}
[1m[36m (0.1ms)[0m [1mSAVEPOINT active_record_1[0m
[1m[35mSQL (0.3ms)[0m INSERT INTO "accounts" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Test"], ["created_at", "2017-05-04 16:27:20.224700"], ["updated_at", "2017-05-04 16:27:20.224700"]]
[1m[36m (0.1ms)[0m [1mRELEASE SAVEPOINT active_record_1[0m
Redirected to http://localhost/
Completed 302 Found in 6ms (ActiveRecord: 0.7ms)
Started GET "/" for 127.0.0.1 at 2017-05-04 18:27:20 +0200
Processing by PagesController#home as HTML
Rendered pages/home.html.erb within layouts/home (5.0ms)
Rendered shared/_navbar_home.html.erb (1.1ms)
Rendered shared/_flashes.html.erb (0.1ms)
Rendered shared/_footer.html.erb (0.6ms)
Completed 200 OK in 10ms (Views: 9.4ms | ActiveRecord: 0.0ms)
실패한 테스트에 대한 test.log 출력을 질문에 추가하십시오. –
로그와 함께 내 질문을 편집했습니다. – Viro
로그에 루트로 리다이렉트되어 있으므로 계정 생성이 성공적 일 수 있습니다. 플래시가 실제로 표시되는 방법 (페이지에 JS가 나타나야합니까?) –