You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shared_context "logged in" do
# before hook that logs in
end
shared_context "logged in as" do |user|
# before hook to log in as the given user
end
RSpec.configure do |c|
c.include_shared_context "logged in", :logged_in => true
end
describe "something" do
with_shared_context "logged in"
end
describe "something else", :logged_in => true do
end
describe "a third thing" do
with_shared_context "logged in as", "[email protected]"
end
Benefits, as I see them:
The declaration of a shared context mirrors the declaration of a shared example group.
You can use shared contexts in the same way you can use shared example groups (even with arguments!).
You can leverage metadata to include a shared context using configuration.
Instead, how about this?
Benefits, as I see them: