-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Treat non
{test,development}
envs as production
Closes [#361]. When the Rails environment is neither `test` nor `development` ([two environments handled by EmberCLI out-of-the-box][ember-cli-env]), treat it as `production`, unless an `EMBER_ENV` is specified. [#361]: #361 [ember-cli-env]: http://ember-cli.com/user-guide/#Environments
- Loading branch information
1 parent
b85bd02
commit ce613b0
Showing
4 changed files
with
76 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require "ember_cli/helpers" | ||
|
||
describe EmberCli::Helpers do | ||
describe ".current_environment" do | ||
context "when EMBER_ENV is set" do | ||
it "returns the value of EMBER_ENV" do | ||
stub_env("EMBER_ENV" => "staging") | ||
|
||
current_environment = EmberCli::Helpers.current_environment | ||
|
||
expect(current_environment).to be_staging | ||
end | ||
end | ||
|
||
context "when test" do | ||
it "returns test" do | ||
stub_rails_env("test") | ||
|
||
current_environment = EmberCli::Helpers.current_environment | ||
|
||
expect(current_environment).to be_test | ||
end | ||
end | ||
|
||
context "when development" do | ||
it "returns development" do | ||
stub_rails_env("development") | ||
|
||
current_environment = EmberCli::Helpers.current_environment | ||
|
||
expect(current_environment).to be_development | ||
end | ||
end | ||
|
||
context "when anything else" do | ||
it "returns production" do | ||
stub_rails_env("staging") | ||
|
||
current_environment = EmberCli::Helpers.current_environment | ||
|
||
expect(current_environment).to be_production | ||
end | ||
end | ||
end | ||
|
||
def stub_env(key_to_value) | ||
allow(ENV). | ||
to receive(:fetch). | ||
with(key_to_value.keys.first). | ||
and_return(key_to_value.values.first) | ||
end | ||
|
||
def stub_rails_env(env) | ||
allow(Rails). | ||
to receive(:env). | ||
and_return(env.to_s.inquiry) | ||
end | ||
end |