view spec fails with “Query does not return ResultSet”

喜欢而已 提交于 2019-12-11 07:29:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!