Sha256: 12c7f3847e2cb8aeee91551871e41e9cb5aa15a3fb1bd1ebbcf206f410af6089

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

require File.join(File.dirname(__FILE__), "test_helper.rb")
require "thread"

class EcologyTest < Scope::TestCase
  context "with ecology" do
    setup do
      Ecology.reset
    end

    should "correctly determine default ecology names" do
      assert_equal "/path/to/bob.txt.ecology", Ecology.default_ecology_name("/path/to/bob.txt.rb")
      assert_equal "relative/path/to/app.ecology", Ecology.default_ecology_name("relative/path/to/app.rb")
      assert_equal "/path/to/bob.ecology", Ecology.default_ecology_name("/path/to/bob.sh")
      assert_equal "\\path\\to\\bob.ecology", Ecology.default_ecology_name("\\path\\to\\bob.EXE")
    end

    should "respect the ECOLOGY_SPEC environment variable" do
      ENV['ECOLOGY_SPEC'] = '/tmp/bobo.txt'
      File.expects(:exist?).with('/tmp/bobo.txt').returns(true)
      File.expects(:read).with('/tmp/bobo.txt').returns('{ "application": "foo_app" }')
      Ecology.read

      assert_equal "foo_app", Ecology.application
    end

    should "recognize that this is the main thread" do
      assert_equal "main", Ecology.thread_id(Thread.current)
    end

    should "work without an ECOLOGY_SPEC" do
      $0 = "whatever_app.rb"

      ENV['ECOLOGY_SPEC'] = nil
      File.expects(:exist?).with("whatever_app.ecology").returns(false)

      Ecology.read

      assert_equal "whatever_app.rb", Ecology.application
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ecology-0.0.11 test/ecology_test.rb