Sha256: f0ec699b73f3ba982ae21b40bedf07988ce25094d24120c79988878d66f13499
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_8_0 = Gem::Version.new("8.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_8_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.5 | lib/cell/rails/testing.rb |