44??дRuby?????????
???????????? ???????[ 2012/3/9 11:14:27 ] ????????
??????????YOW Melbourne?????????????μ????Щ???????Щ?????@coreyhaines?? @rains???????TDD(????????????)??????????????????????????????????????????????(?????????2010????????????)?????????????????????????linux????????????Rspec???????????????????????д????????????(??????????????:))????????????????????????????????????????????????????????????????????д???????????????????
???????С???????????
????????д??????????????????????????????????????????Щ????????????????????:) ?????????д?????????????????????????????????????
1 describe "some test" do
2 it "should be true" do
3 true.should == true
4 end
5
6 it "should show that an expression can be true" do
7 (5 == 5).should == true
8 end
9
10 it "should be failing deliberately" do
11 5.should == 6
12 end
13 end
?? ????????????????????????????Rspec???????????д?Щ?????????????
?????????RSpec ????????? Ruby ????????????????????й??????????淶???ù淶?????????????????????????
?????????????????
?????????????????á?describe????????????μ??????????????????describe?? block?????κε??(???磬???????)???????????Ruby????????????puts????????Kernel block?У??????????κε?????(???Object???????Kernel????Ruby?е?????????????Object??)?????????????describe???Kernel block????????????????)??
1 module Kernel
2 def describe(description?? &block)
3 tests = Dsl.new.parse(description?? block)
4 tests.execute
5 end
6 end
?????Ruby block??Ruby?????block????????????????
?????????????????describe?????????????????????????????????????????block???????????????????????describe?????????(???磬??it?? block)??????????????Dsl????????parse??????????????block???????????????????????????в????????????????????硣Dsl??????????????
1 class Dsl
2 def initialize
3 @tests = {}
4 end
5 def parse(description?? block)
6 self.instance_eval(&block)
7 Executor.new(description?? @tests)
8 end
9 def it(description?? &block)
10 @tests[description] = block
11 end
12 end
??????
???·???
??????????????????
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