Sha256: 2a3e24966eb1515b73ad13cc4a234f75f5a225377318f625c9a18bcb2de88fb6

Contents?: true

Size: 742 Bytes

Versions: 2

Compression:

Stored size: 742 Bytes

Contents

module Cell
  module RailsExtensions
    # This modules overrides Cell::Testing#controller_for and provides Rails-specific logic.
    module Testing
      def controller_for(controller_class)
        return unless controller_class

        controller_class.new.tap do |ctl|
          ctl.request = action_controller_test_request
          ctl.instance_variable_set :@routes, ::Rails.application.routes.url_helpers
        end
      end

      def action_controller_test_request
        if ::Rails.version.start_with?('5')
          ::ActionController::TestRequest.create
        else
          ::ActionController::TestRequest.new
        end
      end
    end # Testing
  end
end

Cell::Testing.send(:include, Cell::RailsExtensions::Testing)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cells-rails-0.0.7 lib/cell/rails/testing.rb
cells-rails-0.0.6 lib/cell/rails/testing.rb