Re: RSpec and nested routes behavior

The rendering of "diagnostics.rhtml" means there was an error raised in the controller and it's trying to display the error page. You should override this so it outputs the stack trace to rspec so you can see what's going on. See this post (and the rest of the thread) for details.

This should tell you more about what part of the code is causing problems.

Re: RSpec and nested routes behavior

I still have anotherproblem. Most of my failures are gone, but I still have three left:

1)Spec::Mocks::MockExpectationError in 'PostsController handling GET/posts/1;edit should find the posts requested'Post expected :find with (any args) once, but received it twice./spec/controllers/posts_controller_spec.rb:217:

2)Spec::Mocks::MockExpectationError in 'PostsController handling POST/posts should create a new posts'Mock 'Post_1027' received unexpected message :user_id= with (202018)/Users/sparta/Projects/work/idastudios/podff_machine/config/../app/controllers/posts_controller.rb:36:in`create'/Users/sparta/Projects/work/idastudios/podff_machine/config/../vendor/plugins/haml/lib/sass/plugin.rb:116:in`process_without_test'./spec/controllers/posts_controller_spec.rb:250:in `do_post'./spec/controllers/posts_controller_spec.rb:256:

3)Spec::Mocks::MockExpectationError in 'PostsController handling POST/posts should redirect to the new posts'Mock 'Post_1028' received unexpected message :user_id= with (202018)/Users/sparta/Projects/work/idastudios/podff_machine/config/../app/controllers/posts_controller.rb:36:in`create'/Users/sparta/Projects/work/idastudios/podff_machine/config/../vendor/plugins/haml/lib/sass/plugin.rb:116:in`process_without_test'./spec/controllers/posts_controller_spec.rb:250:in `do_post'./spec/controllers/posts_controller_spec.rb:260:

Finished in 0.697209 seconds

38 examples, 3 failures

I don't understand the first one, but I do have an idea on thesecond/third one. I am setting the @post.user_id to the current userin the controller, I'm trying to mock that behavior but whatever I trydoesn't work. What would be the proper way? Right now I am doing this:

it "should create a new posts" do Post.should_receive(:user_id).and_return(1) Post.should_receive(:new).with({'name' => 'Post'}).and_return(@post) do_post end