Skip to content

Instantly share code, notes, and snippets.

@nbibler
Created August 18, 2010 22:35
Show Gist options
  • Save nbibler/536411 to your computer and use it in GitHub Desktop.
Save nbibler/536411 to your computer and use it in GitHub Desktop.
module ClassMethods
def my_context(description, options = {}, &block)
context(description) do
before(:each) do
puts "omg!"
end
after(:each) do
puts "win!"
end
yield
end
end
end
RSpec.configure { |config| config.extend(ClassMethods) }
describe Foo do
my_context('something special') do
it "always wins" do
subject.should be_win
end
end
end
module ClassMethods
def my_context(description, options = {}, &block)
context(description) do
before(:each) do
puts "omg!"
end
after(:each) do
puts "win!"
end
end.context(&block)
end
end
RSpec.configure { |config| config.extend(ClassMethods) }
# Whereas.. this one seems to work correctly (not yielding).
module ClassMethods
def my_context(description, options = {}, &block)
context(description) do
before(:each) do
puts "omg!"
end
after(:each) do
puts "win!"
end
it "always wins" do
subject.should be_win
end
end
end
end
RSpec.configure { |config| config.extend(ClassMethods) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment