Sha256: 58a76cba8a5e6a4ba440e1be27a8cbaeff1598dc576f72f045cc2e3954d08f36

Contents?: true

Size: 1.62 KB

Versions: 2

Compression:

Stored size: 1.62 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_equal @run, subject.run_commands
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ns-options-0.4.1 test/integration/app_test.rb
ns-options-0.4.0 test/integration/app_test.rb