Sha256: 34e0b8091c9f0d43f838268acb36b235ac1681db99ccf7e8b238e80d118a95fb

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

require File.dirname(File.dirname(__FILE__)) + '/spec_helper'

current_dir = Dir.getwd

describe 'Rack::Env' do
  include Rack::Test::Methods

  before do
    # move current_dir as ./spec
    Dir::chdir(File.dirname(File.dirname(__FILE__)))
  end

  after(:all) do
    Dir::chdir(current_dir)
  end

  def without_rack_env_app
    Rack::Builder.new do
      run TestRackApp.new
    end
  end

  def rack_env_app
    Rack::Builder.new do
      use Rack::Env
      run TestRackApp.new
    end
  end

  def rack_env_app_with_argument
    Rack::Builder.new do
      use Rack::Env, envfile: ".envfile"
      run TestRackApp.new
    end
  end

  context "When not using Rack::Env" do
    def app
      without_rack_env_app
    end

    it "should ENV['FOO'] is nil" do
      get '/'
      ENV['FOO'].should be_nil
    end
  end

  context "When using Rack::Env" do
    context "without argument" do
      def app
        rack_env_app
      end

      it "should ENV['FOO'] == 'bar'" do
        get '/'
        ENV['FOO'].should == "bar"
      end
    end

    context "with argument" do
      def app
        rack_env_app_with_argument
      end

      it "should ENV['BAZ'] == 'qux'" do
        get '/'
        ENV['BAZ'].should == "qux"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rack-env-0.0.2 spec/rack/env_spec.rb
rack-env-0.0.1 spec/rack/env_spec.rb