Created
July 6, 2011 01:20
-
-
Save mikbe/1066328 to your computer and use it in GitHub Desktop.
What's a better way to test if a block is passed on?
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
it "should pass along blocks if given" do | |
class Baz3 | |
def initialize(attributes = nil, &block) | |
yield if block_given? | |
end | |
end | |
class Qiz3 < Baz3 | |
include Eventable | |
end | |
@cheesy = nil | |
Qiz3.new() { @cheesy = "but it works" } | |
@cheesy.should == "but it works" | |
end |
I'm testing that my library can accept a block and passes it along properly. My library doesn't actually use a block but it needs to support a class that inherits from a class that does.
Since my library doesn't actually use a block I need to fabricate a situation where one is used to test that I pass it along properly.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Coming from #rmu, I'm not sure why you'd directly test if a block was given. You should only be testing the results of calling
Qiz3#new
with and without a block.