[rspec-users] How to test index method of a controller ?

David Chelimsky dchelimsky at gmail.com
Thu Jul 1 15:28:59 EDT 2010


On Jun 29, 2010, at 5:08 PM, marcioa1 wrote:

> Hi,
> 
> My index methods
> 
>     def index
> 		@galleries = Gallery.filtered_by(params.reverse_merge!(:per_page =>
> 10))
>      end
> 
> 
> My spec:
> 
>    it "should list all galleries" do
>      get :index
>      response.should render_template("index")
>    end
> 
> And the error message
> 
> should list all galleries
>   can't convert Spec::Mocks::Mock into Array
> 
> The problem is with the filtered_by method. What should I pass ?

Please post the full spec. There is some code assigning a mock somewhere, but it's not in the code you provided.

Thanks,
David


More information about the rspec-users mailing list