??????????YOW Melbourne?????????????μ????Щ???????Щ???????coreyhaines??rains???????TDD????????????????????????????????????????????????????????????????????????2010?????????????????????????????????????linux????????????Rspec???????????????????????д?????????????????????????????????????????????????????????????????????????????????????????????????????д???????????????????

???????С???????????

????????д??????????????????????????????????????????Щ??????????????????????? ?????????д?????????????????????????????????????

describe"some test"do
  it"should be true"do
    true.should ==true
  end
 
  it"should show that an expression can be true"do
    (5==5).should ==true
  end
 
  it"should be failing deliberately"do
    5.should ==6
  end
end


????????????????????????????????Rspec???????????д?Щ?????????????

?????????RSpec ????????? Ruby ????????????????????й??????????淶???ù淶?????????????????????????

?????????????????

?????????????????á?describe????????????μ??????????????????describe?? block?????κε???????磬???????????????????Ruby????????????puts????????Kernel block?У??????????κε?????????Object???????Kernel????Ruby?е?????????????Object???????????????describe???Kernel block????????????????????

moduleKernel
  defdescribe(description?? &block)
    tests = Dsl.new.parse(description?? block)
    tests.execute
  end
end
 


?????????Ruby block??Ruby?????block????????????????

?????????????????describe?????????????????????????????????????????block???????????????????????describe????????????磬??it?? block????????????????Dsl????????parse??????????????block???????????????????????????в????????????????????硣Dsl??????????????

classDsl
  definitialize
    @tests= {}
  end
  defparse(description?? block)
    self.instance_eval(&block)
    Executor.new(description??@tests)
  end
  defit(description?? &block)
    @tests[description] = block
  end
end
 


?????????????????Dsl??????????????block?????

self.instance_eval(&block)


?????????Dsl???????????it????????????????????????????block???????describe block???????????????£???ж????еú??????磬??????????????????????????á?it??????????ζ?????????????????block???????????????Dsl?????ж????????????????????Щ???????????????describe?? block??????????????????????