查看规范失败并显示“查询不返回结果集”
只是想做一个简单的视图规范。当我第一次创建这个规范并运行它时,它运行得很好。但后来当我需要创建模型类(app/models/request.rb)时,它开始失败并出现以下错误:
失败/错误:渲染 ActionView::模板::错误: 查询不返回结果集
这是我的视图规范:
require 'spec_helper'
describe "requests/new.html.erb" do
it "renders a form to reate a request" do
assign(:request, mock_model("Request"))
render
rendered.should have_selector("form",
:method => "post",
:action => requests_path
) do |form|
form.should have_selector("input",:type=>"submit")
end
end
end
这是视图:
<%= form_for @request do |f| %>
<%= f.submit "Submit" %>
<% end %>
我似乎无法找出问题所在,Google 也没有提供任何帮助。
Just trying to do a simple view spec. When I first create this spec and run it, it worked great. But later on when I needed to create the model class (app/models/request.rb) it starts failing with the following error:
Failure/Error: render
ActionView::Template::Error:
query does not return ResultSet
Here is my view spec:
require 'spec_helper'
describe "requests/new.html.erb" do
it "renders a form to reate a request" do
assign(:request, mock_model("Request"))
render
rendered.should have_selector("form",
:method => "post",
:action => requests_path
) do |form|
form.should have_selector("input",:type=>"submit")
end
end
end
Here is the view:
<%= form_for @request do |f| %>
<%= f.submit "Submit" %>
<% end %>
I can't seem to track down what is wrong and Google offers no help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来问题是模型没有主动迁移。初学者的错误。
It appears it was a problem that there was no active migration for the model. Beginner mistake.