0
我可以用我的瀏覽器登錄,但Cucumbe無法登錄。黃瓜登錄無效
我的用戶/ sign_out路由接受GET。
特徵/ step_denfinitions/home_page_steps.rb:
When(/^I am on the homepage$/) do
visit root_path
end
Then (/^I should see "(.*?)"$/) do |t|
assert page.has_content?(t)
end
Given (/^I am signed in$/) do
visit ('/users/sign_out')
email = '[email protected]'
password = 'password'
visit '/users/sign_in'
fill_in "user_email", :with => email
fill_in "user_password", :with => password
click_button "Sign in"
end
And(/^I go to home page$/) do
visit root_path
end
特徵/ home_page.feature:
Feature: Home page
Scenario: Viewing home page
Given I am on the homepage
Then I should see "Hello"
Scenario: Signed in can create a game
Given I am signed in
Then I should see "Create Game"
/app/views/welcome/index.html(我的根路徑):
<h1>Welcome#index</h1>
"Hello"
<p>Find me in app/views/welcome/index.html.erb</p>
<% if user_signed_in? %> <<< This works in my browser but not for cucumber
<%= link_to "Create Game", new_game_path %>
<% end %>
放在最低線'100'睡在你的腳步,你認爲你拿的。當你運行Cuke時,當你在那條線上時瀏覽器會顯示什麼。 (你的文章不包含任何症狀,只包含無害的代碼,而且,在你使用Rails和RSpec工作,往返旅程之前,你不應該打擾Capybara,大多數Cucumber測試應該直接訪問你的Ruby代碼,而不需要通過瀏覽器。 ...) – Phlip
@Philip黃瓜正在無頭奔跑。通過「瀏覽器」我的意思是我的導軌和自己加載頁面來看看。 – quantumpotato
在我的瀏覽器中測試,如果我已經登錄了,sign_in頁面將不會加載。但是如果我登錄了,我就會看到「創建遊戲」.. – quantumpotato