黄瓜 + webrat:检查出现两次的文本
我正在开发一个 Rails 应用程序来自学 BDD 和一般测试。使用 cucumber + webrat + rspec,在 Railcasts 视频之后。 在此应用程序中,测验有很多问题。我正在测试的视图应该将问题呈现两次并且不连续。 (这里不测试连续性) 我有一个黄瓜场景,旨在检查此
Given quiz titled "Pearl Jam" has questions named "Corduroy, Dissident"
When I go to the experiment page for quiz titled "Pearl Jam"
Then I should see "Corduroy" twice
And I should see "Dissident" twice
我的步骤是这样定义的:
Then /^I should see "([^\"]*)" twice$/ do |text|
regexp = Regexp.new(text + "(.+)" + text)
response.should contain(regexp)
end
我使用工具测试了正则表达式,它似乎有效,但测试在黄瓜上失败。
我在 google 上搜索了一些文档,但 webrat 唯一的文档是 API 文档;我无法将响应显示为文本。 有什么建议吗?
I am working on a rails app to self teach BDD and testing in general. Using cucumber + webrat + rspec, after railcasts video tuts.
In this app a quiz has_many questions. The view I am testing should render the question twice and non contiguously. (not testing contiguity here)
I have a cucumber scenario aimed at checking this
Given quiz titled "Pearl Jam" has questions named "Corduroy, Dissident"
When I go to the experiment page for quiz titled "Pearl Jam"
Then I should see "Corduroy" twice
And I should see "Dissident" twice
My step is defined like this:
Then /^I should see "([^\"]*)" twice$/ do |text|
regexp = Regexp.new(text + "(.+)" + text)
response.should contain(regexp)
end
I tested the regex with a tool, and it seems to work, but the test fails on cucumber.
I googled for some documentation, but webrat's only documentation is the API docs; I wasn't able to get the response displayed as text.
Any suggestion?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过响应。正文
Have you tried response.body
我必须修改达米安的答案才能使其跨界工作。
I had to modify Damian's answer to get this to work across lines.