Rspec中对describe方法是这么说的:
[quote] describe(*args, &block)
Creates and returns a class that includes the ExampleGroupMethods module. Which ExampleGroup type is created depends on the directory of the file calling this method. For example, Spec::Rails will use different classes for specs living in spec/models, spec/helpers, spec/views and spec/controllers. [/quote]
我在看Rspec附带的example时候发现用到describe的时候很多都是这么写的:describe 类名,"描述" {BLOCK}
例如:
[code="java"]describe Stack, " (with one item)" do
before(:each) do
@stack = Stack.new
@stack.push 3
@last_item_added = 3
end
it_should_behave_like "non-empty Stack"
it_should_behave_like "non-full Stack"
end
[/code]
我想请教的是,为什么describe后面要加被测类的类名?有什么作用么?
谢谢!
[b]问题补充:[/b]
谢谢nan1nan1。
补充一下:
期待更满意的答复。