Skip to content

Instantly share code, notes, and snippets.

@adamhunter
Created February 17, 2010 14:49
Show Gist options
  • Save adamhunter/306672 to your computer and use it in GitHub Desktop.
Save adamhunter/306672 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'test/unit'
module Hi
def say_hi
'hi'
end
end
class Form
def self.say_bye
'bye'
end
end
class TestForm < Test::Unit::TestCase
@@form = Form
@@formd = Form.dup
Form.send :extend, Hi
def test_form_class_has_method_say_hi
assert_equal 'hi', Form.say_hi
end
def test_form_var_has_method_say_hi
assert_equal 'hi', @@form.say_hi
end
def test_formd_var_does_not_have_method_say_hi
assert_raises(NoMethodError) { @@formd.say_hi }
end
def test_form_has_method_say_bye
assert_equal 'bye', @@form.say_bye
end
def test_formd_has_method_say_bye
assert_equal 'bye', @@formd.say_bye
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment