Sha256: 01c59a1fb46e3f28fc6afccd9bb74411c6d6c0ee9ba59eaf3933762a7e4380a1
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
module Cell module RailsExtensions # This modules overrides Cell::Testing#controller_for and provides Rails-specific logic. module Testing RAILS_9_0 = Gem::Version.new("9.0.0") RAILS_5_1 = Gem::Version.new("5.1.0") RAILS_5_0 = Gem::Version.new("5.0.0") def controller_for(controller_class) return unless controller_class controller_class.new.tap do |ctl| ctl.request = action_controller_test_request(controller_class) ctl.instance_variable_set :@routes, ::Rails.application.routes.url_helpers end end def action_controller_test_request(controller_class) version = ::Rails.gem_version if version >= RAILS_5_1 && version < RAILS_9_0 ::ActionController::TestRequest.create(controller_class) elsif version >= RAILS_5_0 && version < RAILS_5_1 ::ActionController::TestRequest.create else ::ActionController::TestRequest.new end end end # Testing end end Cell::Testing.send(:include, Cell::RailsExtensions::Testing)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cells-rails-0.1.6 | lib/cell/rails/testing.rb |