0

我想对具有给定 id 的标签的 Calabash 查询结果进行断言。但是 Calabash 中似乎不存在“断言”方法。我测试了一个 iOS 应用程序。

我的代码:

Then(/^arrival date has been changed to day after departure date$/) do
    departure_date_day = query("label marked:'departure_date_day'", :text).first
    arrival_date_day = query("label marked:'arrival_date_day'", :text ()).first
    # assert arrival_date_day.to_i == departure_date_day.to_i + 1
end

这个怎么做?

问候,

米哈乌

4

1 回答 1

1

这些方法存在于基础 Ruby 堆栈而不是 Calabash 中。你可以在这里找到 Ruby 的断言方法: http ://ruby-doc.org/stdlib-2.0/libdoc/minitest/rdoc/MiniTest/Assertions.html

更多信息在这里: https ://github.com/seattlerb/minitest

我个人喜欢 Ruby 的“应该”语法,而不是使用断言。首先安装这个gem:

gem install rspec-expectations

然后在 features/support/env.rb 中:

require 'rspec/expectations'

最后,您可以这样断言:

departure_date_day.should eq query("label marked:'departure_date_day'", :text).first

应该已被弃用,取而代之的是 expect()。我还是更喜欢应该...更多信息在这里:http ://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/

于 2015-03-13T21:35:04.003 回答