44??дRuby?????????
???????????? ???????[ 2012/3/9 11:14:27 ] ????????
?????????????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?????????????£?
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11