Hey all, I see examples showing up that look like this: describe Thing do before(:each) do @thing = Thing.new end it do @thing.should be_something end end This will produce output like this: Thing - should be something But "it do" is driving me mad :( We need a better word. Of course, ''specify'' has not been completely removed, so you can still do this: describe Thing do before(:each) { @thing = Thing.new } specify { @thing.should be_something } end Consise? Yes. But I''m not psyched about ''specify'' either. There IS a perfect word for this situation. What is it? Suggestions? Thanks, David
On 7/19/07, David Chelimsky <dchelimsky at gmail.com> wrote:> > Hey all, > > I see examples showing up that look like this: > > describe Thing do > before(:each) do > @thing = Thing.new > end > > it do > @thing.should be_something > end > end > > This will produce output like this: > > Thing > - should be something > > But "it do" is driving me mad :( > > We need a better word. Of course, ''specify'' has not been completely > removed, so you can still do this: > > describe Thing do > before(:each) { @thing = Thing.new } > specify { @thing.should be_something } > end > > Consise? Yes. But I''m not psyched about ''specify'' either. There IS a > perfect word for this situation. What is it? Suggestions? > > Thanks, > DavidWhat about conform describe Thing do before(:each) { @thing = Thing.new } conform { @thing.should be_something } end -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070719/433a2be1/attachment.html
David Chelimsky wrote:> Consise? Yes. But I''m not psyched about ''specify'' either. There IS a > perfect word for this situation. What is it? Suggestions?Personally, I disagree. For examples like that, I think ''specify'' is a pretty ideal word. It reads exactly as I want it to. Depending on what I''m describing, I tend to use either ''it'' or ''specify'' exclusively, but I definitely do mix them throughout my projects. (I always use ''describe,'' though.) The only problem I ever have is when the specify block needs to be larger than a line, and ''specify do'' reads poorly -- which may be what you have against it, too. So far, I''ve just tried to avoid that... Of course, I say that now, and then someone will have a great suggestion for a word that makes tons more sense. Kyle
On 7/19/07, David Chelimsky <dchelimsky at gmail.com> wrote:> > Hey all, > > I see examples showing up that look like this: > > describe Thing do > before(:each) do > @thing = Thing.new > end > > it do > @thing.should be_something > end > end > > This will produce output like this: > > Thing > - should be something > > But "it do" is driving me mad :( > > We need a better word. Of course, ''specify'' has not been completely > removed, so you can still do this: > > describe Thing do > before(:each) { @thing = Thing.new } > specify { @thing.should be_something } > end > > Consise? Yes. But I''m not psyched about ''specify'' either. There IS a > perfect word for this situation. What is it? Suggestions?I like "should" or "spec" the best. While I''m at it why not "given" instead of "describe"? Cheers, Robert Feldt -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070719/b3a44391/attachment.html
Well in that specific case, please seems like a good choice please do @thing.should be_somthing end But If you had text in between then it wouldn''t seem the same: please "whatever text" do @thing.should be_something end Quoting David Chelimsky <dchelimsky at gmail.com>:> Hey all, > > I see examples showing up that look like this: > > describe Thing do > before(:each) do > @thing = Thing.new > end > > it do > @thing.should be_something > end > end > > This will produce output like this: > > Thing > - should be something > > But "it do" is driving me mad :( > > We need a better word. Of course, ''specify'' has not been completely > removed, so you can still do this: > > describe Thing do > before(:each) { @thing = Thing.new } > specify { @thing.should be_something } > end > > Consise? Yes. But I''m not psyched about ''specify'' either. There IS a > perfect word for this situation. What is it? Suggestions? > > Thanks, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program.
I like the it "should..." do end calls, specifiy as well makes sense. So what is the problem? I think we should take a look at what comments are for. Essentially the "should blah" text acts as a comment on the spec. One that is then picked up by RSpec and inserted to make our specifications more readable in one line. So, if we treat these "shoulds..." as essentially comments, it then opens the door to a resolution as the only place you should use comments is when the code itself is not immediately self documenting. In the Spec world, this really means anything that is more than say one or two lines of code. Why? Well, that''s just an opinion. But we could make the following best practice: If your spec utilizes one matcher and fits on one line, then use: specify { target.should == blah } if your spec can not be succinctly and clearly described in one line of code, then you should add a spec "comment" and so use it "should accept an XML feed" do xml = mock(XMLFeed) target.handle_feed(xml).should == true end The point of specs is their readability and clarity. By making that simple distinction as a "best practice" you handle the situation. That way reading down the spec code would be almost as clear as looking at the RSpec doc html page. then again, with text editors typing "it<tab>" and writing a spec is really not THAT hard is it? Regards Mikel On 7/19/07, Robert Feldt <robert.feldt at bth.se> wrote:> > > On 7/19/07, David Chelimsky <dchelimsky at gmail.com> wrote: > > Hey all, > > > > I see examples showing up that look like this: > > > > describe Thing do > > before(:each) do > > @thing = Thing.new > > end > > > > it do > > @thing.should be_something > > end > > end > > > > This will produce output like this: > > > > Thing > > - should be something > > > > But "it do" is driving me mad :( > > > > We need a better word. Of course, ''specify'' has not been completely > > removed, so you can still do this: > > > > describe Thing do > > before(:each) { @thing = Thing.new } > > specify { @thing.should be_something } > > end > > > > Consise? Yes. But I''m not psyched about ''specify'' either. There IS a > > perfect word for this situation. What is it? Suggestions? > > I like "should" or "spec" the best. > > While I''m at it why not "given" instead of "describe"? > > Cheers, > > Robert Feldt > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >