Confused about testing options for rails

Hi,

I am confused about the amount of different programs/suites/gems
involved in testing in RoR. So far I have a list of:

Webrat, Capybara, Rspec, built in integration tests, cucumber, guard,
spork, testunit (I get this one!), factory girl etc bloody etc.

It seems to me that the authors (like Michael H.) I am following hop
about and use a lot of different programs to test with, but with little
explanation of why they choose a particular setup. In fact, I bought a
book on Rspec only to find out that he is changing to cucumber later??
This confusion exists on other tutorials too.

It seems like testing is really fragmented and constantly changing.

I would be grateful if anyone has the time to explain maybe what is
going on with testing in Rails as I am really confused. I understand the
basics of TDD/BDD (and why BDD etc) but I feel like I am lost on a
sinking ship, the (web)rats are leaving, Capybara’s fleeing, with
flotsam and jetsam of cucumbers and ®spectacles all around…

It just isn’t making sense and I cannot seem to pick out any logical
thrust behind the choice of testing methodology.

Many thanks,

Kevin McCaughey

You would either use RSpec or Test::Unit. Test unit built into rails
while rspec seems to be the flavor of the day. I use capybara for
cucumber testing, when you want human-readable output as part of your
test suite. factory girl is a replacement to rails fixtures, which are
unreliable.

Are Capybara and cucumber different to Rspec?

On Saturday, July 28, 2012 7:20:19 PM UTC+1, Ruby-Forum.com User wrote:

Are Capybara and cucumber different to Rspec?

Capybara (and webrat before it) are tools for simulating (or driving)
browsers with lots of methods for executing common actions, interacting
with the DOM.

rspec, cucumber and test::unit are all libraries (or DSLs) for writing
tests. Capybara is commonly paired with cucumber, but you can easily use
capybara with rspec and there’s an adapter for test::unit too.

There are a lot of tools, but they serve different purposes - I think
you’d
be less confused if you understood their nuances: there aren’t 10
different
approaches to testing, but there are 2-3 approaches to the web
acceptance
side (webrat/capybara), fixtures (fixtures or factory girl), basic
testing
setup (cucumber, rspec, test::unit). Spork, guard, autotest are more
infrastructury things: guard helps you run tests automatically when
related
files have changed whereas spork (or spin) help making running small
amounts of tests fast by caching the loading of the rails app.

So lots of things where there are 2-3 approaches which multiplied
together
do make for a larger number of total possibilities.

As to why there are several alternatives to most components, that’s
pretty
simple: People don’t agree on the best way to do things. Some people
love
fixtures, other people hate it, the same goes for rspec. Sometimes
projects
just fall by the wayside slightly and lose momentum, eg capybara has
pretty
much superseded webrat.

Fred

Dear Frederick,

Thank you x 1000 !! You are the first person to actually explain what
they do and I now understand what is going on. If only all these blogs
and books had spent 10 seconds just saying what these programs were for
before just using them :wink:

I think the “teach by example” paradigm has been taken way to far, and
teachers need to cover the basics better before showing stuff. I
actually am finding Obie F. book much easier going than the
others now. I picked it up from my pile in the corner last night, where
I had been saving it as “advanced”.

Regards,

Kevin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs