我正在使用watir-cucumber进行测试自动化。我在单独的.rb
中编写了以下方法,此方法不在步骤定义中。如何在黄瓜步骤定义之外使用rspec-expectations
def has_logged_in?
$browser.text.should include("t788")
end
当我打电话从步骤定义这个错误出现这种方法,
wrong argument type String (expected Module) (TypeError)
相同的代码工作步骤定义的罚款。我四处搜索,发现include
方法用于包含模块,但这是ruby-include
方法和should include
在rspec\expectations
下。那么如何在上面的步骤定义之外调用should include
方法。 我使用的Watir黄瓜上的Linux
你在哪里和为什么写这个方法? –
你可以做'text.should =〜/ t788 /'就像 – froderik
@IsmaelAbreu我想测试用户是否已经登录,所以不是为每一步我想调用这个函数写它,然后它会决定步骤通过或失败。这是为了避免代码 –