Module: InertiaRails::RSpec::DeprecatedConfiguration Deprecated

Defined in:
lib/inertia_rails/rspec/deprecated.rb

Overview

Deprecated.

Will be removed in InertiaRails 4.0

Class Method Summary collapse

Class Method Details

.install!(config) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/inertia_rails/rspec/deprecated.rb', line 69

def self.install!(config)
  config.before(:each, inertia: true) do
    InertiaRails.deprecator.warn(
      'The `inertia: true` metadata flag is deprecated and will be removed in InertiaRails 4.0. ' \
      'Inertia test helpers are now auto-enabled. Simply remove the flag.'
    )
    new_renderer = InertiaRails::Renderer.method(:new)
    # rubocop:disable Layout/LineLength
    allow(InertiaRails::Renderer).to receive(:new) do |component, controller, request, response, render, named_args|
      # rubocop:enable Layout/LineLength
      new_renderer.call(
        component, controller, request, response, inertia_wrap_render(render), **(named_args || {})
      )
    end
  end
end