Sha256: e99cf547a7a6934d1a9fa91233b180895c4e977d18713ea92d045ed5ad4effb4

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

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

class ErubisTest < Scope::TestCase
  setup do
    Ecology.reset
  end

  context "with a .erb ecology" do
    setup do
      set_up_ecology(<<ECOLOGY_CONTENTS, "some_app.ecology.erb")
{
  "application": "SomeApp",
  "domain": {
    "property1" :
      <% if ENV["BOBO"] %>
        37
      <% else %>
        42
      <% end %>
  },
  "bobo": <%= MultiJson.encode(ENV["BOBO"]) %>
}
ECOLOGY_CONTENTS

      ENV["BOBO"] = nil
    end

    should "Parse conditionally with Erubis" do
      ENV["BOBO"] = "true"
      Ecology.read
      assert_equal 37, Ecology.property("domain::property1")
    end

    should "Parse conditionally with Erubis when a variable is unset" do
      Ecology.read
      assert_equal 42, Ecology.property("domain::property1")
    end

#    should "Return values from Erubis" do
#      ENV["BOBO"] = { "a" => "b", "c" => "d" }
#      Ecology.read
#      assert_equal { "a" => "b", "c" => "d" }, Ecology.property("bobo")
#    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ecology-0.0.18 test/erubis_test.rb
ecology-0.0.14 test/erubis_test.rb
ecology-0.0.12 test/erubis_test.rb