Rspec-rails: Changes In Rails 6 ActionView::Template Breaks EmptyTemplateHandler

Created on 26 Feb 2019  路  8Comments  路  Source: rspec/rspec-rails

Changes to the Template handler calls in Rails 6.0 beta breaks EmptyTemplateResolver

Specifically this change which changes actionview/lib/action_view/template.rb, line 307, from this...

code = @handler.call(LegacyTemplate.new(self, source))

... to this ...

code = @handler.call(self, source)

... breaks rspec-rails, lib/rspec/rails/view_rendering.rb, line 105

def self.call(_template)

with the following error;

ActionView::Template::Error: wrong number of arguments (given 2, expected 1)

Ruby version: ruby 2.5.1p57
Rails version: 6.0.0.beta2
Rspec version: 3.8.2

Most helpful comment

It'd need to be _source = nil in order to remain backwards compatible.

All 8 comments

Any PR for this should target 4-0-dev

Hi @JonRowe - targeting 4-0-dev (which currently has some test failures around Notifications) sounds like a good plan - but this patch will need to sniff which version of ActionView it's running against right? Is there a simple example of where that is already being done?

TBH I'm not sure we need to gate this, our method defines one argument, it needs two on this version of Rails, seems like simply adding a second optional argument would fix it, and gate the spec instead.

(Also 馃憢 @jamesjefferies)

@JonRowe ah yes, that sounds like the best way to sort this .. and yes! 馃憢

@JonRowe I toyed with that in a monkey-patch

def self.call(_template, source)

, but given the method doesn't use _template as it is, it seemed a reasonable future-proof solution, Just a thought.

It'd need to be _source = nil in order to remain backwards compatible.

Fixed in #2089

Was this page helpful?
0 / 5 - 0 ratings