In my RESTful implementation, :new shows a form for @link . When a
user clicks on Create, the value of @link is posted to :create through
params. How do I test the value of params and that :create actually
uses these value to create a new link.
Right now I test :create by by using a link fixture but I want to
actually use the value of params passed in through :new. I suspect
that an integration test is needed but how can I do this?
This will test that the record was created as you wish. Honestly
though, I don't test for this, and I'm more paranoid than most. If
you're passing params[:link] to your Link.new method in the create
action, that's good enough. Since I stub out most database
interaction with Mocha, I actually just test that Link.new was
*called* with the right parameters.
If you want to go nuts on controller tests, I have a pretty detailed
article about it with more to come:
And if you have any questions, contact me through my blog or twitter
(@kconrails) and I'll be glad to help!
In my RESTful implementation, :new shows a form for @link . When a
user clicks on Create, the value of @link is posted to :create through
params. How do I test the value of params and that :create actually
uses these value to create a new link.
Right now I test :create by by using a link fixture but I want to
actually use the value of params passed in through :new. I suspect
that an integration test is needed but how can I do this?
Use Cucumber. It makes this kind of thing pretty easy.