[rspec-users] formatting of one-line specs - question

David Chelimsky dchelimsky at gmail.com
Sun Jan 16 16:53:09 EST 2011


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.


More information about the rspec-users mailing list