Sha256: 829a4af2bbabc8165518775752baf84315318deff49a9c60816f3de6ee22bb37

Contents?: true

Size: 1.69 KB

Versions: 3

Compression:

Stored size: 1.69 KB

Contents

require 'assert'

module App

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

    should have_instance_methods :options, :settings

  end

  class DefineTest < BaseTest
    desc "defined"
    setup do
      stage = @stage = "test"
      root_path = @root_path = File.expand_path("../../..", __FILE__)
      logger = @logger = Logger.new(File.join(@root_path, "log", "test.log"))
      run = @run = true
      @module.settings.define do |namespace|
        namespace.stage stage
        namespace.root = root_path
        namespace.logger = logger

        namespace.sub do
          run_commands run
        end
      end
    end
    subject{ @module.settings }

    should have_instance_methods :namespace, :option, :define, :options, :metaclass
    should have_accessors :stage, :root, :logger
    should have_instance_methods :sub

    should "have set the stage to 'test'" do
      assert_equal @stage, subject.stage
    end

    should "have set the root to this gem's dir" do
      assert_equal Pathname.new(@root_path), subject.root
    end

    should "have set the logger to the passed logger" do
      assert_equal @logger, subject.logger
      assert_same @logger, subject.logger
    end

    should "have set its self_stage option to its stage" do
      assert_equal @stage, subject.self_stage
      assert_same @stage, subject.self_stage
    end

  end

  class SubNamespaceTest < DefineTest
    desc "the sub namespace"
    subject{ @module.settings.sub }

    should "have set the run_commands option" do
      assert_kind_of NsOptions::Boolean, subject.run_commands
      assert_equal @run, subject.run_commands.actual
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ns-options-0.3.1 test/integration/app_test.rb
ns-options-0.3.0 test/integration/app_test.rb
ns-options-0.2.0 test/integration/app_test.rb