Created
July 22, 2017 18:13
-
-
Save xymbol/ed8312b1ae6c02dee06bf17e9c7b4f0f 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
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