Sha256: 83fae66b6f611097aa7c92678c519d7dda2b67548af014ecb5617db377a76db8

Contents?: true

Size: 1.65 KB

Versions: 3

Compression:

Stored size: 1.65 KB

Contents

require 'assert'

module NsOptions::Helper

  class BaseTest < Assert::Context
    desc "NsOptions::Helper"
    setup do
      @module = NsOptions::Helper
    end
    subject{ @module }

    should have_instance_methods :find_and_define_namespace, :find_and_define_option,
      :define_namespace_methods, :define_option_methods, :advisor
      
    should "return an instance of NsOptions::Helper::Advisor with a call to #advisor" do
      advisor = subject.advisor(NsOptions::Namespace.new("something"))
      assert_instance_of NsOptions::Helper::Advisor, advisor
    end
  end
  
  class FindAndDefineOptionTest < BaseTest
    desc "find_and_define_option method"
    setup do
      @namespace = NsOptions::Namespace.new("something")
      @option = @namespace.options.add(:anything)
      @result = @module.find_and_define_option(@namespace, @option.name)
    end
    subject{ @namespace }
    
    should "have defined reader/writer methods for the option and returned the option" do
      assert_respond_to @option.name, subject
      assert_respond_to "#{@option.name}=", subject
      assert_equal @option, @result
    end
  end 
  
  class FindAndDefineNamespaceTest < BaseTest
    desc "find_and_define_namespace method"
    setup do
      @namespace = NsOptions::Namespace.new("something")
      @namespace.options.add_namespace(:else, "something:else")
      @result = @module.find_and_define_namespace(@namespace, :else)
    end
    subject{ @namespace }
    
    should "have defined reader method for the namespace and returned the namespace" do
      assert_respond_to :else, subject
      assert_equal subject.options.get_namespace(:else), @result
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ns-options-0.3.1 test/unit/ns-options/helper_test.rb
ns-options-0.3.0 test/unit/ns-options/helper_test.rb
ns-options-0.2.0 test/unit/ns-options/helper_test.rb