Sha256: 365b3775bcf50561079bfe8318a8526bee6cde77f35cece06b4f16a0206e8fd2

Contents?: true

Size: 378 Bytes

Versions: 4

Compression:

Stored size: 378 Bytes

Contents

module Helpers
  def with_env(opts = {})
    old = {}
    opts.each do |k, v|
      k = k.to_s
      v = v.to_s unless v.nil?
      old[k] = ENV[k]
      ENV[k] = v
    end
    yield
  ensure
    old.each do |k, v|
      ENV[k] = v
    end
  end

  def with_rails_env(env)
    initial_env = Rails.env
    Rails.env = env
    yield
  ensure
    Rails.env = initial_env
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
webvalve-0.9.3 spec/support/helpers.rb
webvalve-0.9.2 spec/support/helpers.rb
webvalve-0.9.1 spec/support/helpers.rb
webvalve-0.9.0 spec/support/helpers.rb