vendor/plugins/rspec-rails/lib/spec/rails/example/render_observer.rb
# Similar to mocking +render+ with the exception that calls to +render+ with
# any other options are passed on to the receiver (i.e. controller in
# controller examples, template in view examples).
#
# This is necessary because Rails uses the +render+ method on both
# controllers and templates as a dispatcher to render different kinds of
# things, sometimes resulting in many calls to the render method within one
# request. This approach makes it impossible to use a normal mock object, which
# is designed to observe all incoming messages with a given name.
#
# +expect_render+ is auto-verifying, so failures will be reported without
# requiring you to explicitly request verification.
#
# Also, +expect_render+ uses parts of RSpec's mock expectation framework. Because
# it wraps only a subset of the framework, using this will create no conflict with
# other mock frameworks if you choose to use them. Additionally, the object returned
# by expect_render is an RSpec mock object, which means that you can call any of the
# chained methods available in RSpec's mocks.
#
# == Controller Examples
#
#   controller.expect_render(:partial => 'thing', :object => thing)
#   controller.expect_render(:partial => 'thing', :collection => things).once
#
#   controller.stub_render(:partial => 'thing', :object => thing)
#   controller.stub_render(:partial => 'thing', :collection => things).twice
#
# == View Examples
#
#   template.expect_render(:partial => 'thing', :object => thing)
#   template.expect_render(:partial => 'thing', :collection => things)
#
#   template.stub_render(:partial => 'thing', :object => thing)
#   template.stub_render(:partial => 'thing', :collection => things)
#
Similar to mocking +render+ with the exception that calls to +render+ with
any other options are passed on to the receiver .

This is necessary because Rails uses the +render+ method on both
controllers and templates as a dispatcher to render different kinds of
things, sometimes resulting in many calls to the render method within one
request. This approach makes it impossible to use a normal mock object, which
is designed to observe all incoming messages with a given name.

+expect_render+ is auto-verifying, so failures will be reported without
requiring you to explicitly request verification.

Also, +expect_render+ uses parts of RSpec's mock expectation framework. Because
it wraps only a subset of the framework, using this will create no conflict with
other mock frameworks if you choose to use them. Additionally, the object returned
by expect_render is an RSpec mock object, which means that you can call any of the
chained methods available in RSpec's mocks.

Controller Examples





View Examples




Similar to mocking + render + with the exception that calls to + render + with any other options are passed on to the receiver . This is necessary because Rails uses the + render + method on both controllers and templates as a dispatcher to render different kinds of things sometimes resulting in many calls to the render method within one request . This approach makes it impossible to use a normal mock object which is designed to observe all incoming messages with a given name . + expect_render + is auto - verifying so failures will be reported without requiring you to explicitly request verification . Also + expect_render + uses parts of RSpec ' s mock expectation framework . Because it wraps only a subset of the framework using this will create no conflict with other mock frameworks if you choose to use them . Additionally the object returned by expect_render is an RSpec mock object which means that you can call any of the chained methods available in RSpec ' s mocks . Controller Examples View Examples
def verify_rendered_proc 
          template = self
          @verify_rendered_proc ||= Proc.new do
            template.verify_rendered
            template.unregister_verify_after_each
          end
        end
def verify_rendered_proc template = self @verify_rendered_proc ||= Proc . new do template . verify_rendered template . unregister_verify_after_each end end
Similar to mocking +render+ with the exception that calls to +render+ with
any other options are passed on to the receiver (i.e.
Similar to mocking + render + with the exception that calls to + render + with any other options are passed on to the receiver ( i . e .
#:nodoc: