I don't like specs, should I change my point of view ?

Z

Zouplaz

Hello, I'm not trolling. I don't like specs (RSpec) : everytime I had a
look to specs I felt it was only syntaxic sugar driven by a big
machinery and I continued to write classic unit tests.

But I've seen more and more projects using rspec - So I consider beeing
wrong about this software.

Do you have any link to articles that advocates for or against specs ?
Or do you have any argument in favor of specs compared with plain old
test suites ?

Thanks
 
P

Peter Szinek

[Note: parts of this message were removed to make it a legal post.]


Hello, I'm not trolling. I don't like specs (RSpec) : everytime I
had a look to specs I felt it was only syntaxic sugar driven by a
big machinery and I continued to write classic unit tests.

But I've seen more and more projects using rspec - So I consider
beeing wrong about this software.

Do you have any link to articles that advocates for or against
specs ? Or do you have any argument in favor of specs compared with
plain old test suites ?

Not really... but you could check out shoulda (http://www.thoughtbot.com/projects/shoulda/
) - it's closer to Test::Unit (basically a set of macros on top of
Test::Unit), but server a similar purpose as rSpec. You have to solve
the mock question (if you want to use mocks at all) - I'd recommend to
check out Mocha.

Cheers,
Peter
___
http://www.rubyrailways.com
http://scrubyt.org
 
J

James Gray

Hello, I'm not trolling. I don't like specs (RSpec) : everytime I
had a look to specs I felt it was only syntaxic sugar driven by a
big machinery and I continued to write classic unit tests.

But I've seen more and more projects using rspec - So I consider
beeing wrong about this software.

Do you have any link to articles that advocates for or against specs ?

I think this is a great read:

http://pragdave.blogs.pragprog.com/pragdave/2008/03/the-language-in.html

James Edward Gray II
 
L

Larz

Hello, I'm not trolling. I don't like specs (RSpec) : everytime I had a
look to specs I felt it was only syntaxic sugar driven by a big
machinery and I continued to write classic unit tests.

But I've seen more and more projects using rspec - So I consider beeing
wrong about this software.

Do you have any link to articles that advocates for or against specs ?
Or do you have any argument in favor of specs compared with plain old
test suites ?

Thanks

I wasn't crazy about what I had read about rspec, but then the
management side of agile, scrums etc hasn't appealed to me either and
I can't say I've had much of any positive experiences with it thus
far.
 
B

Brian Candler

Peter said:
Not really... but you could check out shoulda
(http://www.thoughtbot.com/projects/shoulda/
)

+1 for Shoulda.

You can keep using all the existing assert_xxx macros of Test::Unit, but
wrap up groups of tests in a logical and hierarchical way.

I also find it much clearer to write

assert_equal "foo", @bar # required value, actual value

rather than whatever_the.rspec.equivalent_is?

FWIW, I use Shoulda with mocha. I previously used flexmock, but I found
its error messages when expectations are not met to be very unhelpful in
locating the problem.
 
Y

Yossef Mendelssohn

I also find it much clearer to write

=A0 =A0 assert_equal "foo", @bar =A0 =A0# required value, actual value

rather than whatever_the.rspec.equivalent_is?

@bar.should =3D=3D "foo"

Which I find tons clearer because you're operating on the actual value
and comparing it to the expected.
 
A

Avdi Grimm

I've never found that syntax clear or natural, despite doing it for
years. I always have to look up the exact wording of any assertion
other than assert_equal, and I can never seem to remember which side
the "expected value" is conventionally placed on. Using RSpec has
been like finally being able to write expectations the way my fingers
have been *wanting* to write them all these years.
 
J

Joshua Ballanco

H

hemant

+1 for Shoulda.

You can keep using all the existing assert_xxx macros of Test::Unit, but
wrap up groups of tests in a logical and hierarchical way.

I have been using test/spec for same thing. What advantages shoulda
have over test/spec ?

I also find it much clearer to write

assert_equal "foo", @bar # required value, actual value

rather than whatever_the.rspec.equivalent_is?

FWIW, I use Shoulda with mocha. I previously used flexmock, but I found
its error messages when expectations are not met to be very unhelpful in
locating the problem.



--
Let them talk of their oriental summer climes of everlasting
conservatories; give me the privilege of making my own summer with my
own coals.

http://gnufied.org
 
J

James Gray

I've read that before. Can anyone defend rspec against that attack?
What
does rspec do better? I want to get a better idea of why they invented
this quasi-English framework.

I think RSpec does some things well.

* I love the normal strings used for test naming as opposed to wearing
out your underscore key with test/unit
* I have found contexts to be generally an improvement, despite the
negative break down from the shoulda author
* Despite the jokes about how they just changed a T to a B, I do think
BDD has improved awareness of key testing concepts

James Edward Gray II
 
E

Erik Hollensbe

Joshua said:
...and yet Dan Croak of Thoughtbot just recently wrote up a rather
refreshing (and mildly scathing) look at Shoulda:

http://giantrobots.thoughtbot.com/2008/11/7/a-critical-look-at-the-current-state-of-ruby-testing

If you haven't yet, look at MiniTest. It claims to be a foundation for
building other test suites, but I rather like it on it's own. Small,
simple, fast...and I really like their Mock strategy. Very clean...
like Ruby!

It's kind of misleading. Many of the assertions he uses in the
Test::Unit example are rails-specific, and don't work with the standard
library (1.8 test/unit or miniunit/minitest/bfts compat layer) like he
claims.

I've dealt with this struggle a bit recently... I think I can safely
comment on Test::Unit and Miniunit.

Miniunit is good for simple situations. Most situations are simple.
There's nothing wrong with that. Unless you want the BDD stuff, use it.

If you need to do anything unorthodox, you will not find (or be capable
of doing without extensive monkeypatching) that support in miniunit. One
of the nice things in particular about Test::Unit is that it takes a
very OOP nature to testing; Miniunit is very top-down and the parts are
harder to deal with individually than with Test::Unit, and miniunit is
small and light as a result.

QA and Testing is one thing Perl really excels at. I think it would be
wise to look at how they're doing it and consider adapting ruby's
environment to deal with it in a similar way. TAP and Test::Harness mean
that you can write the test suite with print statements if you really
want to, that's a powerful abstraction I don't think is transferring
well between language communities due to perl's pariah status here.

-Erik
 
J

James Gray

Unless you want the BDD stuff, use it.

Doesn't miniunit come with minispec? Besides, even the RSpec team has
admitted you can do BDD with test/unit, right?

I'm not understanding what you are saying, clearly.

James Edward Gray II
 
G

Gaspard Bucher

There are 1360 tests in zena. I have a post about why we do not use
rspec: http://zenadmin.org/261.

What we *do* use a lot is yaml testing:

nodes_in_site:
src: "<r:nodes in='site' limit='3'><r:each join=', ' do='show'
attr='name'/></r:nodes>"
res: "anonymous, ant, art"

Gaspard
 
E

Erik Hollensbe

James said:
Doesn't miniunit come with minispec? Besides, even the RSpec team has
admitted you can do BDD with test/unit, right?

I'm not understanding what you are saying, clearly.

Correct, I forgot about that, as personally I never use it.

-Erik
 
A

Avdi Grimm

I've read that before. Can anyone defend rspec against that attack? What
does rspec do better? I want to get a better idea of why they invented
this quasi-English framework.

There's information about the "why" here:
http://behaviour-driven.org/BehaviourDrivenDevelopment

BDD is, as you've identified, just testing with a slightly different
vocabulary. But vocabulary is important: it influences how you think
about the problem.

I've seen a lot of TDD code fall into the rut of "let's test method A,
now let's test method B, now let's test method C". BDD encourages a
different focus and a different organization: "let's talk about how
this object should behave in situation A. Now let's talk about how
the object should behave in situation B." The granularity is based on
contextual behavior, rather than on methods.

The very best TDD unit tests I've seen have provided a well-organized
breakdown of the expected inputs and outputs of each method in a
class, and were usable as documentation by a programmer.
Documentation, not a document. By contrast, the very best BDD specs
I've seen have read almost like a prose document describing the
system's behavior, one you could read aloud to a client and have them
understand and either agree or disagree.
 
G

Gaspard Bucher

There's information about the "why" here:
http://behaviour-driven.org/BehaviourDrivenDevelopment

BDD is, as you've identified, just testing with a slightly different
vocabulary. But vocabulary is important: it influences how you think
about the problem.

I've seen a lot of TDD code fall into the rut of "let's test method A,
now let's test method B, now let's test method C". BDD encourages a
different focus and a different organization: "let's talk about how
this object should behave in situation A. Now let's talk about how
the object should behave in situation B." The granularity is based on
contextual behavior, rather than on methods.

The very best TDD unit tests I've seen have provided a well-organized
breakdown of the expected inputs and outputs of each method in a
class, and were usable as documentation by a programmer.
Documentation, not a document. By contrast, the very best BDD specs
I've seen have read almost like a prose document describing the
system's behavior, one you could read aloud to a client and have them
understand and either agree or disagree.
Depending on what I am doing, I start by writing the end-user
documentation (prose, phrases, examples, drawings, pictures)
explaining the behaviour of an object, with the different possible
approaches, etc. This document is refined until everything seems to
fall naturally in place. Then I divide the problem into small
objectives by writing unit tests. And finally I write the code. I
think this approach is very close to BDD with one simple but important
difference: I can write *nice*, searchable, illustrated documentation
with real, sometimes funny, phrases.

I find RSpec to be a poor middle man: not good enough for literature,
too verbose/intrusive for simple tests.

gaspard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,189
Messages
2,571,016
Members
47,618
Latest member
Leemorton01

Latest Threads

Top