diff --git a/Gemfile b/Gemfile index 92d39576..9a386356 100644 --- a/Gemfile +++ b/Gemfile @@ -21,8 +21,6 @@ if version == 'master' # Rails 5 gem 'actionview' end - # Rails 5 - gem 'rails-controller-testing', github: 'rails/rails-controller-testing' else gem_version = "~> #{version}.0" gem 'railties', gem_version diff --git a/test/support/test_case.rb b/test/support/test_case.rb index 66e8648d..c07b5bc0 100644 --- a/test/support/test_case.rb +++ b/test/support/test_case.rb @@ -2,4 +2,12 @@ ActionController::TestCase.class_eval do def setup @routes = TestHelper::Routes end + + # For Rails5 + # https://github.com/rails/rails/commit/ca83436d1b3b6cedd1eca2259f65661e69b01909#diff-b9bbf56e85d3fe1999f16317f2751e76L17 + def assigns(key = nil) + assigns = {}.with_indifferent_access + @controller.view_assigns.each { |k, v| assigns.regular_writer(k, v) } + key.nil? ? assigns : assigns[key] + end end