[rspec-devel] names for setup and teardown methods
David Chelimsky
dchelimsky at gmail.com
Wed Apr 11 08:49:11 EDT 2007
We're going to rename context_setup and context_teardown because they
no longer read well when using "describe/id". There are two ideas
floating around about this. The first:
setup :each #default - works like setup does now
setup :all #replaces context_setup
teardown :each #default - works like teardown does now
teardown :all #replaces context teardown
The second uses "before" and "after" in the same way:
before :each #default - works like setup does now
before :all #replaces context_setup
after :each #default - works like teardown does now
after :all #replaces context teardown
In both cases, the default is :each, so you can just say "setup do" or
"before do" instead of "setup :each do" or "before :each do".
== Examples
describe Thing do
setup :all { ... }
setup :each { ... }
it "should do something" { ... }
it "should do something else" { ... }
teardown :each { ... }
teardown :all { ... }
end
describe Thing do
before :all { ... }
before :each { ... }
it "should do something" { ... }
it "should do something else" { ... }
after :each { ... }
after :all { ... }
end
describe Thing do
before { ... } # works like before :each
it "should do something" { ... }
it "should do something else" { ... }
after { ... } # works like after :each
end
One other thing that occurs to me is that "before :each" really means
"before each example" - so perhaps it should be "before :each_example"
and "before :all_examples" (or :each and :each_example could both be
supported, etc).
WDYT?
More information about the rspec-devel
mailing list