Skip to content

Instantly share code, notes, and snippets.

@mattraibert
Created April 16, 2011 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mattraibert/923184 to your computer and use it in GitHub Desktop.
Save mattraibert/923184 to your computer and use it in GitHub Desktop.
require 'minitest/autorun'
require 'properties'
class PropertiesTest < MiniTest::Unit::TestCase
class Foo
extend Properties
property :bar
end
def setup
@p = Foo.new
end
def test_property
@p.bar = 123
assert_equal 123, @p.bar
end
def test_crazy_method_missing
@p.set_foo 100
assert_equal 100, @p.get_foo
end
def test_only_matches_beginning
assert_raises(NoMethodError){ @p.please_set_foo 100}
assert_raises(NoMethodError){ @p.please_get_foo}
end
def test_method_missing_if_not_in_hash
assert_raises(NoMethodError){ @p.get_bang }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment