Hello, I found a solution that makes this test pass and it was simply to
mock out the controller's find method as such:
Herd.stub(:find).with(@persist_herd.id) { mock_herd }
I am probably not fully understanding RSpec but this feels strange to
me. In my understanding of writing tests, you want to first prepare
the test environment by creating the proper database/objects relevant to
the testing environment, pass the relevant parameters and test the
results of method you are testing. Mocking out this controller code
@herd = Herd.find(params[:herd_id]) with this
Herd.stub(:find).with(@persist_herd.id) { mock_herd } doesn't seem to
let the controller test it's own code? Why can't the parameters I'm
passing to the controller be enough to test Herd.find(params[:herd_id])
?
Please help me understand this?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.