Sha256: 9dc1468e9641ae0541db6544aeb98c9bf0074ff6311b4661c204636f25e71f5a
Contents?: true
Size: 1.77 KB
Versions: 3
Compression:
Stored size: 1.77 KB
Contents
require 'assert' module NsOptions::HasOptions class BaseTest < Assert::Context desc "NsOptions::HasOptions" setup do @class = Class.new do include NsOptions::HasOptions def configs_key "random_class_#{self.object_id}" end end @instance = @class.new end subject{ @instance } should have_class_methods :options end class OptionsTest < BaseTest desc "options method" class WithAKeyTest < OptionsTest desc "with a key" setup do @key = "configs-key" @class.options(:configs, @key) do option :something end @instance = @class.new end subject{ @instance } should have_class_method :configs should have_instance_method :configs should "have used the provided key when creating the namespace" do assert_kind_of NsOptions::Namespace, subject.class.configs assert_kind_of NsOptions::Namespace, subject.configs assert_equal @key, subject.class.configs.options.key assert_match @key, subject.configs.options.key end should "have used the provided block to define the namespace" do assert_respond_to :something, subject.configs assert_respond_to :something=, subject.configs assert subject.configs.options.fetch(:something) end end class WithoutAKeyTest < OptionsTest desc "without a key" setup do @name = "configs" @class.options(@name.to_sym) @instance = @class.new end subject{ @instance } should "have used the name for the key when creating the namespace" do assert_equal @name, subject.class.configs.options.key assert_match @name, subject.configs.options.key end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ns-options-0.2.0 | test/unit/ns-options/has_options_test.rb |
ns-options-0.1.1 | test/unit/ns-options/has_options_test.rb |
ns-options-0.1.0 | test/unit/ns-options/has_options_test.rb |