问题
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.
回答1:
It appears it was a problem that there was no active migration for the model. Beginner mistake.
来源:https://stackoverflow.com/questions/5836014/view-spec-fails-with-query-does-not-return-resultset