Skip to content

Commit

Permalink
Fix ActionView::Template#formats issue in Rails 6
Browse files Browse the repository at this point in the history
In Rails 6 the `ActionView::Template#formats` method has been deprecated
[1] and replaced with `ActionView::Template#format` method.

I have attempted to retain support for Rails <= 5.2.

[1] https://www.github.com/rails/rails/commit/ca5e23ed4d8
  • Loading branch information
sebjacobs committed Mar 18, 2019
1 parent bf65b86 commit 81fdc8a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/rspec/rails/view_rendering.rb
Expand Up @@ -56,11 +56,21 @@ def self.nullify_template_rendering(templates)
template.identifier,
EmptyTemplateHandler,
:virtual_path => template.virtual_path,
:format => template.formats
:format => template_format(template)
)
end
end

if ::Rails::VERSION::STRING >= '6'
def self.template_format(template)
template.format
end
else
def self.template_format(template)
template.formats
end
end

# Delegates all methods to the submitted resolver and for all methods
# that return a collection of `ActionView::Template` instances, return
# templates with modified source
Expand Down

0 comments on commit 81fdc8a

Please sign in to comment.