Hi All,
We have many specs like the pattern given below.
The problem is that it’s slow, because each inner context block will
execute
the before(:all) in the outer describe block.
Is there a way to setup an inner context block that does not execute the
before(:all) and after(:all), but does execute the before(:each) and
after(:each) ?
Based on some playing around (removing inner context blocks) we think
this
would speed up our tests by a factor of 10.
Cheers,
Jimmy
describe Project do
before(:all) do
# statements that set up an object graph, relatively slow
end
after(:all) do
# tear down object graph
end
it { should … }
it { should … }
it { should … }
it { should … }
context “target calculations” do
before(:each) do
# non-expensive statements, just setting up for example the
subject,
Time.zone, locale, etc.
end
it { should ... }
it { should ... }
it { should ... }
end
context “duration calculations” do
before(:each) do
# non-expensive statements
end
it { should ... }
it { should ... }
it { should ... }
end
context …
context …
[ etc. ]
end