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