I can test my controller to render a certain layout with
expect { get :index }.to render_template(layout: 'my_layout')
But how can I test the controller to render NO layout?
The following first expectation passes, but be careful: the second expectation also passes! (testing the same code)
expect { get :index }.to render_template(layout: false)
expect { get :index }.to render_template(layout: true)
In Nov 2008, @david-chelimsky said:
One way I've handled this successfully is to integrate_views for this one example (in its own group) and specify that html elements from the layout are not present in the form. It's a brittle example, but it's only one.
I dont want to check the rendered view, but I did not find any better solution so far.
Does someone has a good approach?
In my tests when there is no layout I just check if it is not loading "application" layout
expect { get :index }.to_not render_template(layout: "application")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With