Search code examples
ruby-on-railsrubyshoulda

Shoulda on Rails - should render_with_layout deferred


I would appreciate if someone could help/explain the following please.

I am trying to test a controller with shoulda to see if a correct layout is used.

The method should_render_with_layout throws a NoMethodError whilst should render_with_layout passes but says the function is deferred.

Any help would be appreciated.. Thanks Matt


Solution

  • and thanks to tsdbrown for your response. I am running shoulda 2.10.2. I have manage to resolve the problem. I had not initiated a get request, but after adding get request to setup the below test is now passing. Thanks for help.

     context "getting index" do
       setup do
         get :index
       end
    
       should_respond_with :success
       should_render_with_layout :admin
       should_render_template :index
       should_assign_to :venue, :class => Venue
       should_not_set_the_flash
     end