-
-
Save tenderlove/191243 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
class SomeClass | |
def initialize(options = {}) | |
load_config | |
set_options(options) | |
end | |
def load_config | |
end | |
def set_options(options) | |
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
require 'test/unit' | |
require 'some_class' | |
class TestSomeClass < Test::Unit::TestCase | |
def test_initialize_calls_stuff | |
foo = Class.new(SomeClass) { | |
attr_reader :shit_called | |
def initialize *args | |
@shit_called = [] | |
super | |
end | |
def load_config; @shit_called << 'load_config'; end | |
def set_options(*args); @shit_called << 'set_options'; end | |
}.new | |
assert_equal %w{ load_config set_options }, foo.shit_called | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment