Sha256: bb943ae6b7641e84ed74782adc05f60aca442c09a5c5e5037ddd0802e7732c8a

Contents?: true

Size: 904 Bytes

Versions: 12

Compression:

Stored size: 904 Bytes

Contents

# frozen_string_literal: true
module Decidim
  # This is a quick hack so all controller specs have their engine's routes
  # included as well as our Devise mapping.
  module ControllerRequests
    extend ActiveSupport::Concern

    included do
      begin
        engine = (ENV["ENGINE_NAME"].to_s.split("-").map(&:capitalize).join("::") + "::Engine").constantize

        load_routes engine if engine.respond_to?(:routes)
      rescue NameError => _exception
        puts "Failed to automatically inject routes for engine #{ENV["ENGINE_NAME"]}"
      end
    end

    class_methods do
      def load_routes(klass)
        routes do
          klass.routes
        end
      end
    end
  end
end

RSpec.configure do |config|
  config.include Decidim::ControllerRequests, type: :controller

  config.before :each, type: :controller do
    @request.env["devise.mapping"] = Devise.mappings[:user]
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
decidim-dev-0.1.0 lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-0.1.0 decidim-dev/lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-dev-0.0.8.1 lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-0.0.8.1 decidim-dev/lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-dev-0.0.8 lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-dev-0.0.7 lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-0.0.7 decidim-dev/lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-dev-0.0.6 lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-0.0.6 decidim-dev/lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-0.0.5 decidim-dev/lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-0.0.4 decidim-dev/lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-0.0.3 decidim-dev/lib/decidim/dev/test/rspec_support/engine_routes.rb