Created
August 18, 2010 22:35
-
-
Save nbibler/536411 to your computer and use it in GitHub Desktop.
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
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) } |
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
describe Foo do | |
my_context('something special') do | |
it "always wins" do | |
subject.should be_win | |
end | |
end | |
end |
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
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) } |
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
# 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