【发布时间】:2014-05-16 13:32:01
【问题描述】:
我有以下页面
<ul class="account_menu dropdown-menu">
<li class="divider"></li>
<li class="current"><span>My account</span></li>
<li class="account"><a href="#">account-1 (Editor)</a></li>
</ul>
使用此步骤用 Cucumber 对其进行测试
within(scope) do
page.should have_content(content)
end
测试在 content = 'account-1' 时通过,而在 content = 'My account' 时失败。范围是两种情况都是'account_menu'
And he should see "My account" within account menu
expected to find text "My account" in "My Accountaccount-1 (Editor)"
(RSpec::Expectations::ExpectationNotMetError)
- 导轨 3.2.17
- rspec-rails 2.14.1
- 水豚2.1.0
为什么找不到“我的帐户”文本?谢谢
【问题讨论】:
-
你正在使用
within(scope);你申请的是什么范围? -
范围是 account_menu
-
大写?帐户中的“A”在页面中大写,而不是在您的测试中。我不认为默认的正则表达式不区分大小写,所以它不匹配。
-
在测试和“我的帐户”页面中
-
我可以在“My Accountaccount-1 (Editor)”中清楚地看到“我的帐户” - 从错误消息中 - 尽管 RSpec 由于某种原因不能
标签: ruby-on-rails rspec cucumber