Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Forked from ymendel/gist:191227
Created September 22, 2009 17:24
Show Gist options
  • Save tenderlove/191243 to your computer and use it in GitHub Desktop.
Save tenderlove/191243 to your computer and use it in GitHub Desktop.
class SomeClass
def initialize(options = {})
load_config
set_options(options)
end
def load_config
end
def set_options(options)
end
end
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