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

1 self.instance_eval(&block)

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

??????describe block?У???it??????????????it?? block??????Ρ???ε??????????????block????????????????洢???????С??????Щ????????????????Executor????????????????е????block???е????????????????????н????Executor???????£?

1  class Executor
2  def initialize(description?? tests)
3   @description = description
4   @tests = tests
5    @success_count = 0
6     @failure_count = 0
7    end
8    def execute
9     puts "#{@description}"
10     @tests.each_pair do |name?? block|
11     print " - #{name}"
12      result = self.instance_eval(&block)
13    result ? @success_count += 1 : @failure_count += 1
14    puts result ? " SUCCESS" : " FAILURE"
15    end
16    summary
17     end
18    def summary
19   puts " #{@tests.keys.size} tests?? #{@success_count} success?? #{@failure_count} failure"
20   end
21   end

?????????executor???????????????describe?? block?????????????????д洢???it?? block??????executor??????????????????????????????????????ζ??executor???????????????????????????????????it?? block???????????????????(???磬????dsl??????????????executor?????????)????磬?????????executor????????к?????

1  def should_be_five(x)
2  5 == x
3    end 
 ???????????????????it?? block??????????????????????????????????????

?????????it?? block??????洢???????????????it?? block?????????????(????????Ruby)???????????????????????????????????????(????????????????)??????????????????Щ???????????

???????????????????should?????????????£?