ddollar/foreman — Issue #104: Foreman.load_env! raises NoMethodError if env_file doesn't exist
Author: juno
Created: 2011-12-15 05:08:56+00:00
State: open

`Foreman.load_env!` raises NoMethodError if env_file doesn't exist.

```
>> require 'foreman'
=> true
>> Foreman.load_env! 'nope'
NoMethodError: undefined method `error' for Foreman::Engine:Class
from /Users/juno/src/foreman/lib/foreman/engine.rb:193:in `block in read_environment_files'
from /Users/juno/src/foreman/lib/foreman/engine.rb:192:in `each'
from /Users/juno/src/foreman/lib/foreman/engine.rb:192:in `read_environment_files'
from /Users/juno/src/foreman/lib/foreman/engine.rb:30:in `load_env!'
from /Users/juno/src/foreman/lib/foreman.rb:10:in `load_env!'
from (irb):2
from /Users/juno/.rbenv/versions/1.9.3-p0/bin/irb:12:in `

'
```

I created spec for this issue, but I can't fix it sorry.

```
# spec/foreman/engine_spec.rb
describe "Foreman::Engine" do
describe "::load_env!(env_file)" do
subject { Foreman::Engine }
it "should exit if env_file doesnt exist" do
File.exist?("./.env").should be_false
mock_error(subject, "No such file: ./.env") do
subject.load_env!("./.env")
end
end
end
end
```

hope this helps.