Sha256: db4ea4aa796cd93a24b48363550a083935be780c570cfac740371fc472f81ef5

Contents?: true

Size: 1.11 KB

Versions: 19

Compression:

Stored size: 1.11 KB

Contents

require "rails"

# Defualt the rails logger to nothing, each test shoould be
# responsible for setting up the logger
logger = ::Logger.new(nil)
Rails.logger = logger

class RailsApp < Rails::Application
  if ::Rails.version =~ /^3\./
    config.secret_token = '1e05af2b349457936a41427e63450937'
  else
    config.secret_key_base = '1e05af2b349457936a41427e63450937'
  end
  config.active_support.deprecation = :stderr
  config.eager_load = false
end

RailsApp.initialize!

module Support
  module Rails
    def dispatch_rails_request(path, additional_env_options = {})
      application = ::Rails.application
      env = application.respond_to?(:env_config) ? application.env_config.clone : application.env_defaults.clone
      env["rack.request.cookie_hash"] = {}.with_indifferent_access
      env["REMOTE_ADDR"] = "123.456.789.10"
      env["X-Request-Id"] = "unique-request-id-1234"
      env["action_dispatch.request_id"] = env["X-Request-Id"]
      env = env.merge(additional_env_options)
      ::Rack::MockRequest.new(application).get(path, env)
    end
  end
end

RSpec.configure do |config|
  config.include Support::Rails
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
timber-1.1.3 spec/support/rails.rb
timber-1.1.2 spec/support/rails.rb
timber-1.1.1 spec/support/rails.rb
timber-1.1.0 spec/support/rails.rb
timber-1.0.13 spec/support/rails.rb
timber-1.0.12 spec/support/rails.rb
timber-1.0.11 spec/support/rails.rb
timber-1.0.10 spec/support/rails.rb
timber-1.0.9 spec/support/rails.rb
timber-1.0.8 spec/support/rails.rb
timber-1.0.7 spec/support/rails.rb
timber-1.0.6 spec/support/rails.rb
timber-1.0.5 spec/support/rails.rb
timber-1.0.4 spec/support/rails.rb
timber-1.0.3 spec/support/rails.rb
timberio-1.0.3 spec/support/rails.rb
timberio-1.0.2 spec/support/rails.rb
timberio-1.0.1 spec/support/rails.rb
timberio-1.0.0 spec/support/rails.rb