Sha256: b433991e1b5c834660302ed9a8f1ef4c2681dc4f79ff5987e7ac9c9c80516189

Contents?: true

Size: 1.63 KB

Versions: 13

Compression:

Stored size: 1.63 KB

Contents

require 'assert'
require 'test/support/app'

module App

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

    should have_instance_methods :options, :settings

  end

  class DefineTests < BaseTests
    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
    should have_accessors :stage, :root, :logger
    should have_readers   :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 SubNamespaceTests < DefineTests
    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

13 entries across 13 versions & 1 rubygems

Version Path
ns-options-1.1.6 test/system/app_tests.rb
ns-options-1.1.5 test/system/app_tests.rb
ns-options-1.1.4 test/system/app_tests.rb
ns-options-1.1.3 test/system/app_tests.rb
ns-options-1.1.2 test/system/app_tests.rb
ns-options-1.1.1 test/system/app_tests.rb
ns-options-1.1.0 test/system/app_tests.rb
ns-options-1.0.1 test/system/app_tests.rb
ns-options-1.0.0 test/system/app_tests.rb
ns-options-1.0.0.rc4 test/system/app_tests.rb
ns-options-1.0.0.rc3 test/system/app_tests.rb
ns-options-1.0.0.rc2 test/system/app_tests.rb
ns-options-1.0.0.rc1 test/system/app_tests.rb