On Sat, Apr 18, 2009 at 6:47 PM, Bob Sanders
<[email protected]> wrote:
>
> I watched the Railscasts video about Cucumber and BDD testing and he
> mentions to also do unit testing.
>
> I figure if the application functions how I want it by passing the
> functional tests through Cucumber's BDD testing method, is it really
> that necessary to do unit testing as well?

You could test your app using something like Cucumber only and I
believe that's a good start but consider the following:

You have an authentication system that protects the administration of
some resource.
You would have Cucumber scenarios that check your login form, that
administrators can see and edit the resource and that
non-administrators can't see the edit buttons or load the edit
resource page
In order to improve security, you should ensure that people can't
issue the  POST and PUT requests directly (which completely by-passes
the browser and therefore is not testable by Cucumber (in it's
traditional usage)
Enter controller tests that can issue specific calls against the
create and update methods covering all sad paths that are achievable
directly against the controller ensuring there is no way to change the
resource if you are not an admin.
It doesn't stop there, your entire application relies on some methods
on your model such as authenticate and admin? etc. Unit tests are your
friend here because you can write specific tests to ensure that
authenticate works correctly and that no-one can inject their admin
status.

Andrew Timberlake
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake

"I have never let my schooling interfere with my education" - Mark Twain

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to