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

andyl akleak at gmail.com
Sun Jan 16 14:35:06 EST 2011


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




More information about the rspec-users mailing list