From 44a5dff724bb26fc7e92b0a485bc1d2257c7f76d Mon Sep 17 00:00:00 2001 From: Chris Continanza Date: Mon, 5 Dec 2011 11:37:51 -0800 Subject: [PATCH] use ./.env as default --- lib/foreman.rb | 2 +- spec/foreman_spec.rb | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/foreman.rb b/lib/foreman.rb index f9c522a..a7d841e 100644 --- a/lib/foreman.rb +++ b/lib/foreman.rb @@ -5,7 +5,7 @@ module Foreman class AppDoesNotExist < Exception; end # load contents of env_file into ENV - def self.load!(env_file) + def self.load!(env_file = './.env') require 'foreman/engine' Foreman::Engine.load_env(env_file) end diff --git a/spec/foreman_spec.rb b/spec/foreman_spec.rb index f2c14cf..9a66d12 100644 --- a/spec/foreman_spec.rb +++ b/spec/foreman_spec.rb @@ -10,16 +10,24 @@ describe Foreman do describe "::load!(env_file)" do before do - File.open("/tmp/env1", "w") { |f| f.puts("FOO=bar") } + FakeFS.activate! end after do + FakeFS.deactivate! ENV['FOO'] = nil end it "should load env_file into ENV" do + File.open("/tmp/env1", "w") { |f| f.puts("FOO=bar") } Foreman.load!("/tmp/env1") ENV['FOO'].should == 'bar' end + + it "should assume env_file in ./.env" do + File.open("./.env", "w") { |f| f.puts("FOO=bar") } + Foreman.load! + ENV['FOO'].should == 'bar' + end end end