Skip to content

Instantly share code, notes, and snippets.

@cjbottaro
Created August 5, 2011 17:50
Show Gist options
  • Save cjbottaro/1128091 to your computer and use it in GitHub Desktop.
Save cjbottaro/1128091 to your computer and use it in GitHub Desktop.
DRY'ed rspec using shared_context with a block
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