James Byrne
2009-Jan-14 19:44 UTC
[rspec-users] Please clarify test / step definition return value?
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. 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. -- Posted via http://www.ruby-forum.com/.
David Chelimsky
2009-Jan-14 20:50 UTC
[rspec-users] Please clarify test / step definition return value?
On Wed, Jan 14, 2009 at 1: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. > > 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.Seems like you''ve answered your own question. I''m not sure where it''s laid out in the docs, but I''m also unsure as to where you got the impression you had :) Never-the-less - steps will remain quiet unless some error is raised. David> -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
aslak hellesoy
2009-Jan-14 21:20 UTC
[rspec-users] Please clarify test / step definition return value?
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>
James Byrne
2009-Jan-14 21:38 UTC
[rspec-users] Please clarify test / step definition return value?
David Chelimsky wrote:> > Seems like you''ve answered your own question. I''m not sure where it''s > laid out in the docs, but I''m also unsure as to where you got the > impression you had :) >Well, the impression came from my unconscious mental mapping of pass=true and fail=false. "should_be something" or "assert something_else" seem, on the surface, to be a simple true or false, yes or no, type conditionals. I mapped that impression, in the absence of any information to the contrary, to my personal expectations of my own tests. I have exerted myself to learn this stuff and even have taken the Pragmatic Programmers course on testing. Somehow I missed the distinction between fail and false. I am not likely to forget it however... Regards, -- Posted via http://www.ruby-forum.com/.
James Byrne
2009-Jan-14 22:30 UTC
[rspec-users] Please clarify test / step definition return value?
Aslak Helles?y wrote:> > Since this is such a common idiom I guess noone thought it required a > specific mention. >Probably. This is what happens when a dinosaur is brought forceably forward in time.> 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. >I do not know where it belongs Aslak because it never occurred to me to look for it. It is just one of those cases where one thinks that one understand something but does not. However, all ones experience is congruent with ones faulty understanding nonetheless, until it is not and realization dawns. I have added a small note regarding fail and false to the bottom of my own document on Cucumber in case others get caught in the same mind trap that I set for myself. -- Posted via http://www.ruby-forum.com/.