Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get environment from RACK_ENV if exists by default #13

Merged
merged 2 commits into from
Nov 11, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changes

* Get environment from RACK_ENV by default

## 0.2.5

* Change rb-inotify and libnotify to be development dependencies
Expand Down
7 changes: 6 additions & 1 deletion lib/guard/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@
module Guard
class Puma < Guard
attr_reader :options, :runner

def self.default_env
ENV.fetch('RACK_ENV', 'development')
end

DEFAULT_OPTIONS = {
:port => 4000,
:environment => 'development',
:environment => default_env,
:start_on_start => true,
:force_run => false,
:timeout => 20,
Expand Down
23 changes: 23 additions & 0 deletions spec/lib/guard/puma_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,29 @@
end
end

describe "#default_env" do
context "when RACK_ENV is set" do
before do
@rack_env = ENV['RACK_ENV']
end

it "uses the value of RACK_ENV" do
ENV['RACK_ENV'] = 'production'
Guard::Puma.default_env.should == 'production'
end

after do
ENV['RACK_ENV'] = @rack_env
end
end

context "when RACK_ENV is not set" do
it "defaults to development" do
Guard::Puma.default_env.should == 'development'
end
end
end

describe '#start' do

context 'start on start' do
Expand Down