123456789_123456789_123456789_123456789_123456789_

Module: RSpec::Rails::ViewRendering

Relationships & Source Files
Namespace Children
Modules:
Classes:
Extension / Inclusion / Inheritance Descendants
Included In:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ActiveSupport::Concern
Defined in: rspec-rails/lib/rspec/rails/view_rendering.rb

Overview

Helpers for optionally rendering views in controller specs.

Constant Summary

Instance Attribute Summary

DSL Calls

included

[ GitHub ]


149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'rspec-rails/lib/rspec/rails/view_rendering.rb', line 149

included do
  before do
    unless render_views?
      @_original_path_set = controller.class.view_paths
      path_set = @_original_path_set.map { |resolver| RESOLVER_CACHE[resolver] }

      controller.class.view_paths = path_set
      controller.extend(EmptyTemplates)
    end
  end

  after do
    controller.class.view_paths = @_original_path_set unless render_views?
  end
end

Instance Attribute Details

#controller (rw)

Returns the controller object instance under test.

[ GitHub ]

  
# File 'rspec-rails/lib/rspec/rails/view_rendering.rb', line 12

attr_reader :controller

#controller=(value) (rw, private)

This method is for internal use only.
[ GitHub ]

  
# File 'rspec-rails/lib/rspec/rails/view_rendering.rb', line 15

attr_writer :controller

#render_views?Boolean (readonly)

This method is for internal use only.
[ GitHub ]

  
# File 'rspec-rails/lib/rspec/rails/view_rendering.rb', line 38

def render_views?
  self.class.render_views? || !controller.class.respond_to?(:view_paths)
end