shared examples
Reported by Brian Takita | May 27th, 2008 @ 08:46 PM | in No-Milestone-Assigned
There already are SharedExampleGroups, which allow groupings of Examples and callbacks.
There are situations when only one Example needs to be shared. Unfortunately, creating an ExampleGroup construct is a little too heavyweight for those cases.
For those situations, it would be useful to have a shared Example.
describe UserController do
describe "#create" do
describe "when logged in" do
it "renders 'username created another user'", :shared => true do # or have a shared_it method
end
describe "when creating an Admin" do
it "renders 'username created another user'"
end
describe "when creating a normal User" do
it "renders 'username created another user'"
end
end
end
end
Another method name can be substituted if the proposed implementation is too confusing.
Comments and changes to this ticket
-
David Chelimsky May 28th, 2008 @ 07:07 AM
I'd prefer share_as if we add this (there is a similar method for creating example group modules).
I like the "when/then" feel this supports.
Side note - #describe is aliased by #context, so you can do this:
describe UserController do describe "#create" do context "when logged in" doI like that because it breaks up all those nested describe blocks.
-
David Chelimsky October 3rd, 2008 @ 01:28 PM
- → Tag changed from to featurerequest
(from [848280c3d3a4f91de7baa7d5c94250758b395712]) Restore colorized output in windows w/ autotest [#415] http://github.com/dchelimsky/rsp...
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.
