module Shoulda::ActionController::Macros
def should_assign_to(*names, &block)
should_assign_to :user, :class => User
should_assign_to :user, :posts
Example:
the return value of that block.
If a block is passed, the assigned variable is expected to be equal to
* :class - The expected class of the instance variable being checked.
Options:
each of the named instance variable(s).
Macro that creates a test asserting that the controller assigned to
def should_assign_to(*names, &block) klass = get_options!(names, :class) names.each do |name| matcher = assign_to(name).with_kind_of(klass) should matcher.description do if block expected_value = instance_eval(&block) matcher = matcher.with(expected_value) end assert_accepts matcher, @controller end end end