[rspec-users] Should I use cucumber or Controller RSpecs or both?
apremdas at gmail.com
Tue Feb 14 04:52:25 EST 2012
On 13 February 2012 22:46, Cathal Curtis <lists at ruby-forum.com> wrote:
> Hi All,
> I'd like to get some other's opinions on testing controllers.
> Say I have a model and I want to prevent deletion of instances of it.
> The controllers's destroy action simply redirects to an error page -
> nothing else.
> Lets assume the relevant views have no links or buttons to delete the
> I want to ensure that on receipt of a DELETE request for an instance of
> that model, that the application does in fact disallow the deletion and
> redirects to an error page.
> Should I create a cucumber test, with a step that would call something
> like: "delete url_for(...)"?
> Or should I leave it to a Controller RSpec?
> I have implemented both, the RSpec is working fine but I'm having
> trouble getting cucumber to follow the redirect and therefore my "Then I
> should be on error page" fails.
> I'd like to know if such a cucumber test is unnecessary.
> Should I even have such a cucumber test if the user cannot generate the
> condition/action/event through normal use of the application?
> If the controller RSpec proves that the controller responds with a
> redirect response to the correct page, is that all I need?
> Thanks in advance, Cathal.
> Posted via http://www.ruby-forum.com/.
> rspec-users mailing list
> rspec-users at rubyforge.org
Why do you want to ensure that the instance cannot be deleted. If its a
business concern then you should write a cuke for it. If you just want to
specify as a dev that it can't be deleted then perhaps you could write a
routing spec that says there is no route for delete, though are you going
to write specs that say you can't foo_it or bar_it?
There are lots of security concerns that a business can have about users
doing things that have no interaction in the UI. These are generally very
easy to implement in cucumber e.g - after all you just need to visit a url
to generate the request. The only issue is that in Rails you may not get
the error page you expect because you are running in test mode. You can
address that by using an @allow-rescue tag on the feature.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rspec-users