Created
January 27, 2012 16:31
-
-
Save kornypoet/1689638 to your computer and use it in GitHub Desktop.
Rspec #initialize behavior
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
# Arbitrary class illustrating desired implementation of init options for a class | |
# How do I spec this behavior? especially if there are many attrs and conditions? | |
class Foo | |
attr_accessor :bar | |
def initialize(bar) | |
# call an exiting method unless some condition is met by the variable passed in. Foo is an outward-facing class | |
log_and_fail unless bar | |
@bar = bar | |
end | |
def log_and_fail | |
Log.fatal "fail" ; exit | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment