Sha256: bc9580ff60378050d6e4d124ecb8b99eda5c0743d1ce24851c070c806c0d6e77

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)

require 'rspec'
require 'action_controller/railtie'
require 'gaffe'

RSpec.configure do |config|
  # Disable `should` syntax
  config.expect_with :rspec do |c|
    c.syntax = :expect
  end

  config.before(:each) do
    # Fake Rails.root
    allow(Rails).to receive(:root).and_return(RAILS_ROOT)

    # Fake Rails.application
    application = double('Rails Application', config: OpenStruct.new, env_config: {})
    allow(Rails).to receive(:application).and_return(application)

    # Make sure we clear memoized variables before each test
    [:@configuration].each do |variable|
      Gaffe.send :remove_instance_variable, variable if Gaffe.instance_variable_defined?(variable)
    end
  end
end

# We need a fake "ApplicationController" because Gaffe's default controller inherits from it
class ApplicationController < ActionController::Base
end

def test_request
  if Rails::VERSION::MAJOR >= 5
    ActionDispatch::TestRequest.create
  else
    ActionDispatch::TestRequest.new
  end
end

# We need Rails.root
RAILS_ROOT = Pathname.new(File.expand_path('../../', __FILE__))

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gaffe-1.1.0 spec/spec_helper.rb