Module: Spec::Rails::Example::ControllerExampleGroup::ControllerInstanceMethods

Includes:
RenderObserver
Defined in:
lib/spec/rails/example/controller_example_group.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods included from RenderObserver

#register_verify_after_each, #render_proxy, #should_not_receive, #should_receive, #stub, #stub!, #unregister_verify_after_each, #verify_rendered, #verify_rendered_proc

Instance Method Details

#default_template(action_name = self.action_name) ⇒ Object

Rails 2.3



242
243
244
245
246
247
248
249
250
251
252
# File 'lib/spec/rails/example/controller_example_group.rb', line 242

def default_template(action_name = self.action_name)
  if integrate_views?
    super
  else
    begin
      super
    rescue ActionView::MissingTemplate
      "#{self.class.name.sub(/Controller$/,'').underscore}/#{action_name}"
    end
  end
end

#integrate_views!Object



260
261
262
# File 'lib/spec/rails/example/controller_example_group.rb', line 260

def integrate_views!
  @integrate_views = true
end

#render(options = nil, extra_options = {}, &block) ⇒ Object

render(options = nil, extra_options={}, &block)

This gets added to the controller’s singleton meta class, allowing Controller Examples to run in two modes, freely switching from example group to example group.



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/spec/rails/example/controller_example_group.rb', line 218

def render(options=nil, extra_options={}, &block)
  unless block_given?
    unless integrate_views?
      @template.extend TemplateIsolationExtensions
    end
  end

  if matching_message_expectation_exists(options)
    render_proxy.render(options, &block)
    @performed_render = true
  else
    if matching_stub_exists(options)
      @performed_render = true
    else
      if ::Rails::VERSION::STRING > '2.1'
        super(options, extra_options, &block)
      else
        super(options, &block)
      end
    end
  end
end

#response(&block) ⇒ Object



254
255
256
257
258
# File 'lib/spec/rails/example/controller_example_group.rb', line 254

def response(&block)
  # NOTE - we're setting @update for the assert_select_spec - kinda weird, huh?
  @update = block
  super
end