h1. Controller macros For each example below, we will show you the Rspec way and in the Macro (Shoulda) way. Choose the one that pleases you the most. :) h2. assign_to Macro that creates a test asserting that the controller assigned to each of the named instance variable(s). Options: * :with - A string or a proc which is evaluated and compared with the instance variable being checked. * :with_kind_of - The expected class of the instance variable being checked. Example:
should_assign_to :user, :posts
should_assign_to :user, :with_kind_of => User
should_assign_to :user, :with => proc { @user }
should_assign_to(:user){ @user }
should_not_assign_to :user, :posts
it { should assign_to(:user, :posts) }
it { should assign_to(:user, :with_kind_of => User) }
it { should assign_to(:user, :with => @user) }
it { should_not assign_to(:user, :posts) }
h2. filter_params
Macro that creates a test asserting that filter_parameter_logging is set for the specified keys.
Example:
should_filter_params :password, :ssn
it { should filter_params(:password, :ssn) }
h2. render_a_form
Macro that creates a test asserting that the rendered view contains a @