2012-09-13 276 views
0

我在功能以下情形:黃瓜軌失敗的情況下

@home 
Feature: Home page 

@home 
Scenario: User launches home page 
    Given a user visits the home page 
    And user is not signed in 
    Then he should see user signin information 

上午看到2個問題: 1)當我運行rake cucumber --tags @home,它拋出一個錯誤:invalid option: --tags

所以,我跑與cucumber --tags @home 2)它拋出以下錯誤:

Given a user visits the home page    # features/step_definitions/home_steps.rb:2 
And user is not signed in      # features/step_definitions/home_steps.rb:23 
Then he should see user signin information # features/step_definitions/home_steps.rb:6 
    expected link "User Sign In" to return something (RSpec::Expectations::ExpectationNotMetError) 
    ./features/step_definitions/home_steps.rb:8:in `/^he should see user signin information$/' 
    features/home.feature:8:in `Then he should see user signin information' 

然而,當我啓動並查看瀏覽器,我可以看到並單擊該鏈接,然後驗證該步驟以確保沒有拼寫錯誤或多餘的空格。

Can some one help me how I can debug this?

步驟:

Given /^a user visits the home page$/ do 
    visit home_path 
end 
Given /^user is not signed in$/ do 

end 

Then /^he should see user signin information$/ do 
    page.should have_link('User Sign In', href: user_signin_path) 
end 
+0

您可以嘗試通過在page.should has_link子句之前添加'save_and_open_page'來調試您的應用程序。這將打開一個瀏覽器頁面,你會看到什麼黃瓜'看到'之前,它會檢查您的期望。 – corroded

+0

謝謝,這解決了案件失敗的原因。順便說一句,你能告訴我爲什麼用rake執行失敗嗎? – Kiran

+0

耙是不同於黃瓜。耙子任務基本上只是叫黃瓜 - 你可以運行黃瓜本身。 Rake是運行所有測試的便捷/簡捷方法。如果您需要將選項傳遞給黃瓜(標籤,特定文件),只需調用黃瓜本身即可。我希望清理它:) – corroded

回答

1

您可以嘗試通過page.should have_link子句前右加save_and_open_page調試您的應用程序。這將打開一個瀏覽器頁面,你會看到什麼黃瓜'看到'之前,它會檢查你的期望。