Christian Hølmer
2007-Jun-28 08:21 UTC
[rspec-users] Custom report outputting text, expected and actual on succes?
I would like to output the following information when running a spec (_also_ on success): - the description text - the expected value - the actual value After looking through the documentation I thought custom formatters might be the way to go, but unfortunately it does not look like all variables are accessible from there? I need this for an academic report where all testing needs to be documented with expected and actual values. This will probably be one of the only times I need this, so I am prepared for a quick and dirty hack to get it working. Before diving deeper into the code I would like to hear if anyone can think of a clever solution? I thought of creating custom matchers that outputs the information but this seems dumb? Any ideas?
I''m looking through my specs and they work great, but they don''t read as English. I''m wondering how others are phrasing these. Here are some examples: describe Agent do it ''should be possible to create one'' do end end This reads as "Agent should be possible to create one". Any suggestions how the describe/it might better be worded? Thx
Edward Ocampo-Gooding
2007-Jul-05 19:19 UTC
[rspec-users] Wording describe/it so specdocs look good
> I''m looking through my specs and they work great, but they don''t read > as English. I''m wondering how others are phrasing these. Here are > some examples: > > describe Agent do > it ''should be possible to create one'' do > end > endDoes describe Agent do it ''should be createable'' do # stuff end end work for you?
For that simple case, yes. But how about the case where I specify: Agent "should not be possible for the same user to rate the same agent twice with same kind of transaction" The English grammar gets a bit twisty. Perhaps: Agent "should not allow the same user to rate the same agent twice with the same kind of transaction" Thoughts? On Jul 5, 2007, at 12:19 PM, Edward Ocampo-Gooding wrote:>> I''m looking through my specs and they work great, but they don''t read >> as English. I''m wondering how others are phrasing these. Here are >> some examples: >> >> describe Agent do >> it ''should be possible to create one'' do >> end >> end > > Does > > describe Agent do > it ''should be createable'' do > # stuff > end > end > > work for you? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
David Chelimsky
2007-Jul-05 19:52 UTC
[rspec-users] Wording describe/it so specdocs look good
On 7/5/07, s.ross <cwdinfo at gmail.com> wrote:> For that simple case, yes. But how about the case where I specify: > > Agent "should not be possible for the same user to rate the same > agent twice with same kind of transaction" > > The English grammar gets a bit twisty. Perhaps: > > Agent "should not allow the same user to rate the same agent twice > with the same kind of transaction" > > Thoughts?How would you phrase all this with context/specify? Or, a bit further off target, TestCase/test_method?> > > On Jul 5, 2007, at 12:19 PM, Edward Ocampo-Gooding wrote: > > >> I''m looking through my specs and they work great, but they don''t read > >> as English. I''m wondering how others are phrasing these. Here are > >> some examples: > >> > >> describe Agent do > >> it ''should be possible to create one'' do > >> end > >> end > > > > Does > > > > describe Agent do > > it ''should be createable'' do > > # stuff > > end > > end > > > > work for you? > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On Jul 5, 2007, at 12:52 PM, David Chelimsky wrote:>> Agent "should not allow the same user to rate the same agent twice >> with the same kind of transaction" >> >> Thoughts? > > How would you phrase all this with context/specify? Or, a bit further > off target, TestCase/test_method? >I wouldn''t phrase it differently with context/specify and with TestCase/test_method, I''d probably care less because I wouldn''t have been trained to create beautiful, self-documenting example descriptions :) I''m just thinking there must be a nicer way to express what I mean.
Edward Ocampo-Gooding
2007-Jul-05 20:24 UTC
[rspec-users] Wording describe/it so specdocs look good
Does this work? describe Agent, "rated by a user with the same kind of transaction" do it ''should not be rated twice'' do # stuff end end s.ross wrote:> For that simple case, yes. But how about the case where I specify: > > Agent "should not be possible for the same user to rate the same > agent twice with same kind of transaction" > > The English grammar gets a bit twisty. Perhaps: > > Agent "should not allow the same user to rate the same agent twice > with the same kind of transaction" > > Thoughts? > > > On Jul 5, 2007, at 12:19 PM, Edward Ocampo-Gooding wrote: > >>> I''m looking through my specs and they work great, but they don''t read >>> as English. I''m wondering how others are phrasing these. Here are >>> some examples: >>> >>> describe Agent do >>> it ''should be possible to create one'' do >>> end >>> end >> Does >> >> describe Agent do >> it ''should be createable'' do >> # stuff >> end >> end >> >> work for you? >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Don Petersen
2007-Jul-05 20:25 UTC
[rspec-users] Wording describe/it so specdocs look good
I have no idea what the business logic is, but I guess I see a few words there which could be more concise. "should not allow" could become "disallows". Not much shorter, but I don''t think it''s written anywhere that everything must to start with "should"? "the same user to rate the same agent twice" could become "duplicate ratings" So maybe: Agent disallows duplicate ratings of the same transaction type Again I''m just taking a wild shot in the dark about your business logic from that description. I don''t mention "user" or "agent" in mine. But we''re already describing Agent, and can anything but a User rate an agent? If only a User can, do you even need to specify that it''s a User who is doing the rating? I do find exercises like this where you have to try and describe your problem domain succinctly helps to understand it, and to be able to talk to another developer or your customer intelligently about it. Don On Jul 5, 2007, at 3:06 PM, s.ross wrote:> > On Jul 5, 2007, at 12:52 PM, David Chelimsky wrote: > >>> Agent "should not allow the same user to rate the same agent twice >>> with the same kind of transaction" >>> >>> Thoughts? >> >> How would you phrase all this with context/specify? Or, a bit further >> off target, TestCase/test_method? >> > > I wouldn''t phrase it differently with context/specify and with > TestCase/test_method, I''d probably care less because I wouldn''t have > been trained to create beautiful, self-documenting example > descriptions :) > > I''m just thinking there must be a nicer way to express what I mean. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users