Sha256: 1cfa2170c53a6827aba44177d023162729b31e1a1632351a8152e5b86e54eb9e

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

require 'assert'

module Sanford::Host

  class BaseTest < Assert::Context
    desc "Sanford::Host"
    setup do
      @configuration = MyHost.configuration.to_hash
    end
    teardown do
      MyHost.configuration.apply(@configuration)
    end
    subject{ MyHost.instance }

    should have_instance_methods :configuration, :name, :ip, :port, :pid_file,
      :logger, :verbose_logging, :runner, :error, :init, :version,
      :versioned_services

    should "get and set it's configuration options with their matching methods" do
      subject.name 'my_awesome_host'

      assert_equal 'my_awesome_host',           subject.name
      assert_equal subject.configuration.port,  subject.port
    end

    should "add a version group with #version" do
      subject.version('v1'){ }

      assert_equal({}, subject.versioned_services["v1"])
    end

  end

  class ClassMethodsTest < Assert::Context
    desc "Sanford::Host class"
    subject{ MyHost }

    should "proxy it's method to it's instance" do
      assert_equal subject.instance.name, subject.name
      assert subject.respond_to?(:pid_file)
    end

    should "have registered the class with sanford's known hosts" do
      assert_includes subject, Sanford.hosts
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sanford-0.6.3 test/unit/host_test.rb
sanford-0.6.2 test/unit/host_test.rb
sanford-0.6.1 test/unit/host_test.rb