If in the previous section (: each) a custom method should be used
1 answer
You need to split your examples into two groups of examples, one group where before (: each) is called with create_main, and you use that to test everything except create_main. Then you have another subset where before (: each) does not call create_main, and this is where you check create_main.
In your case, I think you could try something like the following:
describe Category, " without a main category" do
before(:each) do
# No call to create_main here
end
it "should create the main category" do
# Here we test that create_main is working
end
end
describe Category, " with a main category already created" do
before(:each) do
# This time, we do call create_main to set up the object as necessary
end
# More examples go here that depend on create_main
end
Give it a shot. I'm not 100% sure if it works, but I've seen similar settings in the past.
+2
source to share