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
Post a Comment