test/test_plugin.rb in ddplugin-1.0.1 vs test/test_plugin.rb in ddplugin-1.0.2

- old
+ new

@@ -1,8 +1,10 @@ +# frozen_string_literal: true + require 'helper' -class DDPlugin::PluginTest < Minitest::Test +class PluginTest < Minitest::Test class IdentifierSample extend DDPlugin::Plugin end class NamedSample @@ -26,21 +28,40 @@ klass.identifier :bar assert_equal :foo, klass.identifier end + def test_identifier_with_string + klass = Class.new(IdentifierSample) + assert_nil klass.identifier + + klass.identifier 'asdf' + assert_equal :asdf, klass.identifier + end + def test_identifiers klass = Class.new(IdentifierSample) assert_empty klass.identifiers klass.identifiers :foo1, :foo2 - assert_equal [:foo1, :foo2], klass.identifiers + assert_equal %i[foo1 foo2], klass.identifiers klass.identifiers :bar1, :bar2 - assert_equal [:foo1, :foo2, :bar1, :bar2], klass.identifiers + assert_equal %i[foo1 foo2 bar1 bar2], klass.identifiers end + def test_identifiers_with_string + klass = Class.new(IdentifierSample) + assert_empty klass.identifiers + + klass.identifiers 'foo1', 'foo2' + assert_equal %i[foo1 foo2], klass.identifiers + + klass.identifiers 'bar1', 'bar2' + assert_equal %i[foo1 foo2 bar1 bar2], klass.identifiers + end + def test_root superklass = Class.new(InheritanceSample) superklass.identifier :super subklass = Class.new(superklass) @@ -48,11 +69,11 @@ assert_equal superklass, InheritanceSample.named(:super) assert_equal subklass, InheritanceSample.named(:sub) assert_equal :sub, subklass.identifier - assert_equal [:sub, :also_sub], subklass.identifiers + assert_equal %i[sub also_sub], subklass.identifiers assert_equal InheritanceSample, superklass.root_class assert_equal InheritanceSample, subklass.root_class end @@ -60,9 +81,17 @@ klass = Class.new(NamedSample) klass.identifier :named_test assert_nil NamedSample.named(:unknown) assert_equal klass, NamedSample.named(:named_test) + end + + def test_named_with_string + klass = Class.new(NamedSample) + klass.identifier :named_test + + assert_nil NamedSample.named('unknown') + assert_equal klass, NamedSample.named('named_test') end def test_all klass1 = Class.new(AllSample) klass1.identifier :one