场景是:
Scenario: View welcome page
Given I am on the home page
Then I should see 'Welcome'
步骤的定义是
Then("I should see {string}") do |string|
page.has_content?(string)
end
测试通过,无论欢迎词是否在主页中。我在做什么错?
仅在引发异常时,该步骤才会失败。按照其命名约定,如果内容不在页面中,则has_content?
方法将返回false,因此不会引发异常。如果您打算失败,这将导致您的步骤“通过”。
您需要使用某种单元测试库进行断言(我的Ruby有点生锈)
Then("I should see {string}") do |string|
page.has_content?(string).should_be true
end
您需要RSpec之类的东西才能访问允许我断言的库。