[LRUG] Cucumber and RSpec on Rails

Murray Steele murray.steele at gmail.com
Mon Feb 8 14:54:07 PST 2010


Joseph Wilk's talk at Scotland On Rails last year is a *really* good intro
into how features and tests (both controller and model) sit together
properly.  I'd highly recommend watch it to get a grip on how you should
approach things, although if you aren't into watching videos, Neil has
pretty much nailed it (although he doesn't mention model tests).

Watch it here:
http://scotland-on-rails.s3.amazonaws.com/1A06_JosephWilk-SOR.mp4

One thing to note is that in most Railscasts Ryan Bates isn't showing you
the golden path of the true developer, just how to use the gem or library
he's covering in that episode.  Accordingly he hardly ever writes tests,
unless it's a testing library or gem he's showing off.  So it's not
surprising that in the cucumber episodes he doesn't do unit tests, as, in
theory, you already know how to write those, what you want to learn is how
to write cucumber features.

Muz

On 8 February 2010 22:12, Neil Edwards <neil at plasticwater.com> wrote:

> Agreed, although it's sometimes still nice to hit the controller steps.
> If you get autospec working with cucumber it's very nice to follow
> something like:
>
> write up your cucumber feature
> watch it fail
> write up your rspec controller test
> watch it fail
> make your rspec test pass
> make your cucumber test pass
>
> autospec won't rerun the cucumber tests until the rspec ones are passing,
> it's quite clever like that.
>
> I'd say most of my controllers don't have test. The integration testing
> that cucumber provides is really nice and done correctly can give you
> massive amounts of confidence your code works like you want. I just like to
> have some controller tests in there every now and again for things that I
> think are a little bit too complex.
>
> Check out the rspec book too from pragprog.com, I quite liked it and has
> lots of cucumber in it too.
>
> On 8 February 2010 22:02, <chat-request at lists.lrug.org> wrote:
>
>> Send Chat mailing list submissions to
>>        chat at lists.lrug.org
>>
>> To subscribe or unsubscribe via the World Wide Web, visit
>>
>>        http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>> or, via email, send a message with subject or body 'help' to
>>        chat-request at lists.lrug.org
>>
>> You can reach the person managing the list at
>>        chat-owner at lists.lrug.org
>>
>> When replying, please edit your Subject line so it is more specific
>> than "Re: Contents of Chat digest..."
>>
>> Today's Topics:
>>
>>   1. Cucumber and RSpec on Rails (Jordi Noguera Leon)
>>   2. Another Recruitment Shout-Out (Hakan ?enol Ensari)
>>   3. Re: Cucumber and RSpec on Rails (Paul Campbell)
>>   4. Re: Cucumber and RSpec on Rails (Steven Mohapi-Banks)
>>
>>
>>
>> ---------- Forwarded message ----------
>> From: Jordi Noguera Leon <jordinoguera83 at gmail.com>
>> To: London Ruby Users Group <chat at lists.lrug.org>
>> Date: Mon, 8 Feb 2010 19:42:48 +0000
>> Subject: [LRUG] Cucumber and RSpec on Rails
>> Hi there!
>>
>> I'm starting with Cucumber but I'm not sure if/when/how to create specs.
>> In the couple of Railscasts I'seen so far, the guy generates rspec_models
>> and rspec_controllers, but he doesn't code anything inside them... In
>> another screencast I've seen, the guy validates uniqueness of some stuff
>> inside the spec, but I guess that's something you could do using a
>>  scenario, right? Basically, do I need to write any spec or I can do all the
>> stuff in the scenario?
>>
>> Regards,
>> Jordi
>>
>>
>> ---------- Forwarded message ----------
>> From: "Hakan Şenol Ensari" <hakan.ensari at papercavalier.com>
>> To: London Ruby Users Group <chat at lists.lrug.org>
>> Date: Mon, 8 Feb 2010 19:51:16 +0000
>> Subject: [LRUG] Another Recruitment Shout-Out
>> Hi everyone,
>>
>> My apologies for spamming.
>>
>> My company is looking for a full-time Ruby dev in London. Here are the
>> details:
>>
>> http://papercavalier.com/jobs
>>
>> Cheers,
>> Hakan
>>
>> http://ultra.bohe.me
>>
>>
>> ---------- Forwarded message ----------
>> From: Paul Campbell <paul at rslw.com>
>> To: London Ruby Users Group <chat at lists.lrug.org>
>> Date: Mon, 8 Feb 2010 19:57:37 +0000
>> Subject: Re: [LRUG] Cucumber and RSpec on Rails
>> Jordi,
>>
>> cucumber can (and will, if you want) cover 90% of the cases.
>>
>> Sometimes you might want to drop down to controller testing for edge
>> cases or redirects to  external services and things.
>>
>> Mostly though, my controller specs remain empty.
>>
>> Model specs are much more frequent though, for testing things like
>> arithmetic, maybe validations, auto-assignment, data transformations
>> etc.
>>
>> Hope this helps,
>>
>> —Paul
>>
>> On Mon, Feb 8, 2010 at 7:42 PM, Jordi Noguera Leon
>> <jordinoguera83 at gmail.com> wrote:
>> > Hi there!
>> > I'm starting with Cucumber but I'm not sure if/when/how to create specs.
>> In
>> > the couple of Railscasts I'seen so far, the guy generates rspec_models
>> and
>> > rspec_controllers, but he doesn't code anything inside them... In
>> another
>> > screencast I've seen, the guy validates uniqueness of some stuff inside
>> the
>> > spec, but I guess that's something you could do using a  scenario,
>> right?
>> > Basically, do I need to write any spec or I can do all the stuff in the
>> > scenario?
>> > Regards,
>> > Jordi
>> > _______________________________________________
>> > Chat mailing list
>> > Chat at lists.lrug.org
>> > http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>> >
>> >
>>
>>
>>
>> --
>>
>>
>> Paul Campbell
>> paul at rushedsunlight.com
>> - - - - - - - - - - - - - - - - - - -
>> blog http://www.pabcas.com
>> twitter http://www.twitter.com/paulca
>> github http://www.github.com/paulca
>> phone +353 87 914 8162
>> - - - - - - - - - - - - - - - - - - -
>>
>>
>>
>> ---------- Forwarded message ----------
>> From: Steven Mohapi-Banks <steven.mohapibanks at me.com>
>> To: London Ruby Users Group <chat at lists.lrug.org>
>> Date: Mon, 08 Feb 2010 21:40:35 +0000
>> Subject: Re: [LRUG] Cucumber and RSpec on Rails
>> I'd pretty much agree with this - my controller specs these days are
>> pretty much for covering access privileges, security edge cases and the
>> like. I also spec out routing rules quite frequently. Everything else goes
>> in Cucumber stories.
>>
>> Steve
>>
>>
>> On Monday, February 08, 2010, at 07:57PM, "Paul Campbell" <paul at rslw.com>
>> wrote:
>> >Jordi,
>> >
>> >cucumber can (and will, if you want) cover 90% of the cases.
>> >
>> >Sometimes you might want to drop down to controller testing for edge
>> >cases or redirects to  external services and things.
>> >
>> >Mostly though, my controller specs remain empty.
>> >
>> >Model specs are much more frequent though, for testing things like
>> >arithmetic, maybe validations, auto-assignment, data transformations
>> >etc.
>> >
>> >Hope this helps,
>> >
>> >—Paul
>> >
>> >On Mon, Feb 8, 2010 at 7:42 PM, Jordi Noguera Leon
>> ><jordinoguera83 at gmail.com> wrote:
>> >> Hi there!
>> >> I'm starting with Cucumber but I'm not sure if/when/how to create
>> specs. In
>> >> the couple of Railscasts I'seen so far, the guy generates rspec_models
>> and
>> >> rspec_controllers, but he doesn't code anything inside them... In
>> another
>> >> screencast I've seen, the guy validates uniqueness of some stuff inside
>> the
>> >> spec, but I guess that's something you could do using a  scenario,
>> right?
>> >> Basically, do I need to write any spec or I can do all the stuff in the
>> >> scenario?
>> >> Regards,
>> >> Jordi
>> >> _______________________________________________
>> >> Chat mailing list
>> >> Chat at lists.lrug.org
>> >> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>> >>
>> >>
>> >
>> >
>> >
>> >--
>> >
>> >
>> >Paul Campbell
>> >paul at rushedsunlight.com
>> >- - - - - - - - - - - - - - - - - - -
>> >blog http://www.pabcas.com
>> >twitter http://www.twitter.com/paulca
>> >github http://www.github.com/paulca
>> >phone +353 87 914 8162
>> >- - - - - - - - - - - - - - - - - - -
>> >_______________________________________________
>> >Chat mailing list
>> >Chat at lists.lrug.org
>> >http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>> >
>> >
>>
>>
>> _______________________________________________
>> Chat mailing list
>> Chat at lists.lrug.org
>> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>>
>>
>
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20100208/64c2450e/attachment-0003.html>


More information about the Chat mailing list