[rspec-users] Please clarify test / step definition return value?

aslak hellesoy aslak.hellesoy at gmail.com
Wed Jan 14 16:20:22 EST 2009


On Wed, Jan 14, 2009 at 8:44 PM, James Byrne <lists at ruby-forum.com> wrote:

> I have been working under the impression that that tests/step
> definitions worked on a simple boolean logic and behaved like ruby
> methods, the last value is returned.  Thus, in my understanding, if the
> return value is true then the step definition passed.  if it was false,
> then the step definition failed.
>

The return value from a step definition means nothing. Where did you get the
impression that it did? Is there anywhere in the Wiki that hints to this
that we need to fix?


>
> However, in trying to determine why a simple boolean value returned from
> the database did not seem to influence the test result I discovered
> this:
>
> # This always passes!!!
> When /any matcher you want/ do
>  false
> end
>
> # This, on the other hand, always fails.
> When /any matcher you want/ do
>  fail
> end.
>
> Was I truly fundamentally wrong in my previous belief that test results
> are boolean true and false values?  If so, where exactly is this laid
> out in the API because I missed it entirely.


Return values aren't mentioned anywhere in the Wiki as far as I know, which
means they are not significant. Step definitions fail for precisely the same
reason that Test::Unit, JUnit, NUnit, xUnit methods and RSpec "it" blocks do
- when an exception is raised.

Since this is such a common idiom I guess noone thought it required a
specific mention.

Please give me a pointer to a relevant page where you'd expect to see this
mentioned explicitly and I'll make it clear in the Wiki.

Aslak


> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090114/c1b3d116/attachment-0001.html>


More information about the rspec-users mailing list