spec/rack_environment_spec.rb in rack-environment-1.0.1 vs spec/rack_environment_spec.rb in rack-environment-1.1.0

- old
+ new

@@ -1,21 +1,42 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe "RackEnvironment" do include Rack::Test::Methods + def rack_environment_with_filename(filename) + Rack::Builder.new do + use RackEnvironment, :file => File.join(File.dirname(__FILE__), 'config', filename) + run TestApplication.new + end + end + + def rack_environment_with_environment(environment) + Rack::Builder.new do + use RackEnvironment, :environment => environment + run TestApplication.new + end + end + before :each do get "/" @environment = last_response.headers['X-Rack-Environment'] end + describe "with specified environment" do + def app + rack_environment_with_environment :ONE => 'one_value' + end + + it "should have the proper environment set" do + @environment['ONE'].should == 'one_value' + end + end + describe "with specified config file" do def app - Rack::Builder.new do - use RackEnvironment, :file => File.expand_path(File.dirname(__FILE__) + '/config/environment.yml') - run TestApplication.new - end + rack_environment_with_filename 'environment.yml' end it "should have the proper environment set" do @environment['UPPER'].should == 'upper_value' end @@ -24,19 +45,16 @@ @environment['lower'].should_not == 'lower_value' @environment['LOWER'].should == 'lower_value' end end - describe "with specified environment" do + describe "with blank config file" do def app - Rack::Builder.new do - use RackEnvironment, :environment => { :ONE => 'one_value' } - run TestApplication.new - end + rack_environment_with_filename 'blank.yml' end - it "should have the proper environment set" do - @environment['ONE'].should == 'one_value' + it "should not raise an error" do + @environment.should_not be_nil end end end