gpt4 book ai didi

ruby-on-rails - Cucumber table.diff 说表不相同 - Rails

转载 作者:行者123 更新时间:2023-11-28 21:14:57 24 4
gpt4 key购买 nike

我对 Rails 和 Cucumber 还很陌生,所以这可能是也可能不是快速解决方案。

我有一个加载模型集合的 cucumber 场景,然后检查它们是否全部呈现到表中。 Cucumber 返回一个结果说“表不相同”。我在这里错过了什么?我试图在第二步定义中添加 header ,但这无济于事。谢谢。

调试 rails 和 rails 测试的任何其他提示和技巧也会有所帮助。

这是我的场景..

Scenario: View all the clients
Given I am on the clients page
And the following clients exist:
|name|mobile|address|
|Bob|93838383|21 Test Street|
|Ian|87232878|1 Test Road|
|Matt|23762327367|55 Rails Drive|
Then I should see the following clients:
|Bob|93838383|21 Test Street|
|Ian|87232878|1 Test Road|
|Matt|23762327367|55 Rails Drive|

和我的步骤定义...

Given /^the following clients exist:$/ do |table|
table.hashes.each do |client|
Client.create!(client)
end
end

Then /^I should see the following clients:$/ do |table|
table.diff!(tableish('table tr', 'td'))
end

还有我的 View 文件..

<h1>Clients</h1>
<table>
<% for client in @clients %>
<tr>
<td><%= client.name %></td>
<td><%= client.mobile %></td>
<td><%= client.address %></td>
</tr>
<% end %>
</table>

和 Controller Action ..

 def index
@clients = Client.find(:all)
end

最佳答案

尝试将调试步骤添加到您的 cucumber 中:

And show me the page

应该创建一个临时文件来转储响应内容并在浏览器中打开它。

编辑:我很确定这应该由 webrat 在 features/steps/web_steps.rb 中定义

关于ruby-on-rails - Cucumber table.diff 说表不相同 - Rails,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3206928/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com