2012-12-19 41 views
2

我有這些測試步驟。 app_host指向「google.com」。水豚與黃瓜給假陽性

Given /^I am on google\.com$/ do 
     visit("/") 
    end 

    Then /^I should see something$/ do 
     has_css?('a#something') 
    end 

無論我在第二步中有什麼,測試都通過了。我只是想知道我是否在這裏失去了一些東西。

+0

找到了答案。需要'rspec/expectations'和assertion應該是這樣的has_css?('a#something')。應該是__true – 3coins

回答

5

如果斷言失敗,黃瓜步驟將失敗。如果最後一行是真或假,它們不會失敗。

要使用has_css?在斷言可以執行下列操作之一:

#If you are using RSpec assertions 
page.should have_css('a#something') 

#If you are using Test::Unit assertions 
assert page.has_css?('a#something') 
+0

沒錯。我發佈後在文檔中找到了我的問題的答案。 https://github.com/cucumber/cucumber/wiki/Step-Definitions – 3coins