ruby - rspec - how to have examples without both 'describe' and 'it' -


given following working code:

require 'rspec' require_relative 'dec_to_hex' describe "should convert 20 32"   "should convert correctly"     converter("20").should == 32   end  end 

why can't have actual test either

describe "should convert 20 32"     converter("20").should == 32 end # doesn't run test, gets ignored! 

or

it "should convert correctly"   converter("20").should == 32 end  # gives undefined method `it' 

you must use both 'describe' , 'it' blocks when using rspec. internal reason described in docs (http://rubydoc.info/gems/rspec-core/frames) follows:

"the describe method creates examplegroup. within block passed describe can declare examples using method.

under hood, example group class in block passed describe evaluated. blocks passed evaluated in context of instance of class."


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -