[rspec-users] Testing Layout
loop at superinfinite.com
Wed Apr 16 11:20:00 EDT 2008
On 16-apr-2008, at 16:53, Andy Croll wrote:
> Bart Zonneveld wrote:
>> On 16-apr-2008, at 13:57, Andy Croll wrote:
>>> Is there a way to specify which layout an action should use in a
>> Off the top of my head, not tested:
>> describe MyController do
>> it "should use the foo layout" do
>> but I'm sure there's a more BDD way to do it (TIMTOWTDI goes
>> BDDWTDI ?).
> Tried it. No dice it seems
> So I then tried:
> it "should use the admin layout" do
> And I get...
> Spec::Mocks::MockExpectationError in 'Admin::ProductsController should
> use the admin layout'
> Mock 'Admin::ProductsController' expected :layout with ("admin") once,
> but received it 0 times
> I'm not doing the load ... command you suggested. What is the thinking
> behind that? I'm finding that testing using RSpec demands you
> a lot more of what is going on inside the framework!
That kind of makes sense, since should_receive's should be defined
*before* something happens. So, slightly diverting here, but say a
Post should receive find(:all) when you go to index/, it would look
describe PostsController do
it "should find all posts" do
The "trick" I gave you above was based on this one: http://
Perhaps you should try giving the full path to load, eg. load
(RAILS_ROOT + "/app/controllers/my_controller.rb").
More information about the rspec-users