spec/lib/armoire_spec.rb in armoire-1.2.1 vs spec/lib/armoire_spec.rb in armoire-1.3.0
- old
+ new
@@ -2,10 +2,14 @@
describe Armoire do
describe '#.environment' do
subject { described_class.instance.environment }
+ before do
+ described_class.environment = nil
+ end
+
context "ENV['RAILS_ENV'] is set" do
before do
@prev_rails_env = ENV['RAILS_ENV']
ENV['RAILS_ENV'] = 'rails_env'
end
@@ -35,10 +39,31 @@
ENV['RAILS_ENV'] = @prev_rails_env
ENV['RACK_ENV'] = @prev_rack_env
end
end
+ context "environment is explicitly set" do
+ before do
+ @prev_rails_env = ENV['RAILS_ENV']
+ @prev_rack_env = ENV['RACK_ENV']
+ ENV['RAILS_ENV'] = nil
+ ENV['RACK_ENV'] = nil
+ described_class.environment = 'no_rack'
+ end
+
+ it "returns the explicitly set environment" do
+ expect(subject).to eql("no_rack")
+ end
+
+ after do
+ ENV['RAILS_ENV'] = @prev_rails_env
+ ENV['RACK_ENV'] = @prev_rack_env
+ described_class.environment = nil
+ end
+ end
+
+
context "nothing is set" do
before do
@prev_rails_env = ENV['RAILS_ENV']
@prev_rack_env = ENV['RACK_ENV']
ENV['RAILS_ENV'] = nil
@@ -51,9 +76,13 @@
after do
ENV['RAILS_ENV'] = @prev_rails_env
ENV['RACK_ENV'] = @prev_rack_env
end
+ end
+
+ after do
+ described_class.environment = nil
end
end
describe '#[]' do
context "simple config option" do