44??дRuby?????????
???????????? ???????[ 2012/3/27 10:36:28 ] ????????
??????????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??????????????????????
??????
???·???
??????????????????
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