SharedExampleGroup should respect nested scope
Reported by Brian Takita | May 27th, 2008 @ 09:46 PM | in No-Milestone-Assigned
There are times when we would like reference the SharedExampleGroup's not in the global context, but within the context of its ExampleGroup.
Here is a toy example:
describe User do
describe "when male" do
describe "goes out on the town", :shared => true do
it "calls bar buddies" do
end
describe "when straight" do
it "hits on women" do
end
end
describe "when gay" do
it "hits on men" do
end
end
it "ends up in drunken stupor on some street drain" do
end
end
describe "when a good boy" do
it "leads a boring life" do
end
describe "when influenced by bad boys" do
it_should_behave_like "goes out on the town"
end
end
describe "when a bad boy" do
it_should_behave_like "goes out on the town"
end
end
describe "when female" do
describe "goes out on the town", :shared => true do
it "dresses up in new dress" do
end
describe "when straight" do
it "hits on men" do
end
end
describe "when gay" do
it "hits on women" do
end
end
it "happily goes home happy" do
end
end
describe "when a good girl" do
it "leads a boring life" do
end
describe "when influenced by bad girls" do
it_should_behave_like "goes out on the town"
end
end
describe "when a bad girl" do
it_should_behave_like "goes out on the town"
end
end
end
The output looks like:
User
when male
when a good boy
leads a boring life
when influenced by bad boys
calls bar buddies
when straight
hits on women
when gay
hits on men
ends up in drunken stupor on some street drain
when a bad boy
calls bar buddies
when straight
hits on women
when gay
hits on men
ends up in drunken stupor on some street drain
when female
when a good girl
leads a boring life
when influenced by bad girls
dresses up in new dress
when straight
hits on men
when gay
hits on women
happily goes home happy
when a bad girl
dresses up in new dress
when straight
hits on men
when gay
hits on women
happily goes home happy
Comments and changes to this ticket
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Behaviour Driven Development for Ruby.
