Skip to content

Instantly share code, notes, and snippets.

@xymbol
Created July 22, 2017 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xymbol/ed8312b1ae6c02dee06bf17e9c7b4f0f to your computer and use it in GitHub Desktop.
Save xymbol/ed8312b1ae6c02dee06bf17e9c7b4f0f to your computer and use it in GitHub Desktop.
require "minitest/autorun"
class Foo
@option = "default"
def self.build(value)
klass = Class.new self
klass.instance_variable_set :@option, value
klass
end
def self.option
@option
end
end
def Foo(value)
Foo.build value
end
class FooTest < Minitest::Test
def test_builds_a_subclass
klass = Foo "foo"
assert klass < Foo, "is not a subclass"
end
def test_sets_option
klass = Foo "bar"
assert_equal "bar", klass.option
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment