Created
August 5, 2011 17:50
-
-
Save cjbottaro/1128091 to your computer and use it in GitHub Desktop.
DRY'ed rspec using shared_context with a block
This file contains 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 "for_extending" do | |
context "extended with MyModule" do | |
before(:all){ subject.extend(MyModule) } | |
it "should define #some_method" do | |
subject.should respond_to(:some_method) | |
end | |
yield | |
end | |
end | |
describe Object do | |
execute_context("for_extending") | |
end | |
describe Class do | |
execute_context("for_extending") do | |
it "should also define #special_method_for_class" do | |
subject.should respond_to(:special_method_for_class) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment