For easy editing, I love one-line specs, like this:
specify { 1.should == 1 }
But when using ''--format documentation'', one-line specs
don''t always
render useful documentation.
A solution is to write one-line specs using do/end:
it "succeeds with do/end" do 1.should == 1 end
That''s ok - but its difficult to visually parse. One-line specs with
braces would be better IMHO.
Here''s a first example with braces ( this doesn''t work ):
it "should work this way, but doesn''t" { 1.should == 1 }
Here''s a second example with braces ( this works ):
it("works this way") { 1.should == 1 }
Is there any way to make the first ''braces'' format work??
( I''m using Ruby 1.8.7 / Rspec 2.4.0 / Ubuntu 10.10 )
Thanks, Andy
David Chelimsky
2011-Jan-16 21:53 UTC
[rspec-users] formatting of one-line specs - question
On Jan 16, 2011, at 1:35 PM, andyl wrote:> For easy editing, I love one-line specs, like this: > > specify { 1.should == 1 } > > But when using ''--format documentation'', one-line specs don''t always > render useful documentation. > > A solution is to write one-line specs using do/end: > > it "succeeds with do/end" do 1.should == 1 end > > That''s ok - but its difficult to visually parse. One-line specs with > braces would be better IMHO. > > Here''s a first example with braces ( this doesn''t work ): > > it "should work this way, but doesn''t" { 1.should == 1 } > > Here''s a second example with braces ( this works ): > > it("works this way") { 1.should == 1 } > > Is there any way to make the first ''braces'' format work??AFAIK, no. That''s just the way the Ruby parser works.