module Shoulda::Matchers::ActionController

def filter_param(key)

it { should filter_param(:password) }

Example:

Ensures that filter_parameter_logging is set for the specified key.
:nodoc:
def filter_param(key)
  FilterParamMatcher.new(key)
end

def permit(*params)

def permit(*params)
  StrongParametersMatcher.new(params).in_context(self)
end

def redirect_to(url_or_description, &block)

it { should redirect_to(users_path) }
it { should redirect_to('http://somewhere.com') }

Example:

Ensures a controller redirected to the given url.
:nodoc:
def redirect_to(url_or_description, &block)
  RedirectToMatcher.new(url_or_description, self, &block)
end

def render_template(options = {}, message = nil)

it { should render_template(partial: false) }
assert that no partials were rendered

it { should render_template(partial: '_customer', count: 2) }
assert that the "_customer" partial was rendered twice

it { should render_template(partial: '_customer') }
assert that the "_customer" partial was rendered

it { should render_template(:show) }

Example:

Ensures a controller rendered the given template.
:nodoc:
def render_template(options = {}, message = nil)
  RenderTemplateMatcher.new(options, message, self)
end

def render_with_layout(expected_layout = nil)

it { should_not render_with_layout }
it { should render_with_layout(:special) }
it { should render_with_layout }

Example:

Ensures that the controller rendered with the given layout.
def render_with_layout(expected_layout = nil)
  RenderWithLayoutMatcher.new(expected_layout).in_context(self)
end

def rescue_from(exception)

def rescue_from(exception)
  RescueFromMatcher.new exception
end

def respond_with(status)

it { should respond_with(501) }
it { should respond_with(:error) }
it { should respond_with(:missing) }
it { should respond_with(:redirect) }
it { should respond_with(:success) }

Example:

See ActionController::StatusCodes for a full list.
or its symbolic equivalent :success, :redirect, :missing, :error.
You can pass an explicit status number like 200, 301, 404, 500

Ensures a controller responded with expected 'response' status code.
def respond_with(status)
  RespondWithMatcher.new(status)
end

def route(method, path)

to('posts#show', id: 1, user_id: 1) }
it { should route(:get, '/users/1/posts/1').
to(action: :show, id: 1, user_id: 1) }
it { should route(:get, '/users/1/posts/1').
to(action: :destroy, id: 1) }
it { should route(:delete, '/posts/1').
it { should route(:put, '/posts/1').to(action: :update, id: 1) }
it { should route(:get, '/posts/1/edit').to(action: :edit, id: 1) }
it { should route(:get, '/posts/1').to('posts#show', id: 1) }
it { should route(:get, '/posts/1').to(action: :show, id: 1) }
it { should route(:post, '/posts').to(action: :create) }
it { should route(:get, '/posts/new').to(action: :new) }
it { should route(:get, '/posts').to('posts#index') }
to(controller: :posts, action: :index) }
it { should route(:get, '/posts').

Examples:

+to_param+ is called on the +options+ given.

example group.
If you don't specify a controller, it will use the controller from the

Ensures that requesting +path+ using +method+ routes to +options+.
def route(method, path)
  RouteMatcher.new(method, path, self)
end

def set_session(key)

it { should_not set_session(:user_id) }
it { should set_session(:user_id).to(@user.id) }
it { should set_session(:message) }

Example:

Ensures that a session key was set to the expected value.
def set_session(key)
  SetSessionMatcher.new(key)
end

def set_the_flash

it { should_not set_the_flash }
it { should set_the_flash.to(/logged in/i).now }
it { should set_the_flash[:alert].to('Password does not match') }
it { should set_the_flash.to(/created/i) }
it { should set_the_flash.to('Thank you for placing this order.') }
it { should set_the_flash }

Example:

Regexp, or nil (indicating that the flash should not be set).
Ensures that the flash contains the given value. Can be a String, a
def set_the_flash
  SetTheFlashMatcher.new
end

def use_after_action(callback)

it { should_not use_after_action(:destroy_user) }
it { should use_after_action(:log_activity) }

Example:

Ensure a controller uses a given after_action
def use_after_action(callback)
  CallbackMatcher.new(callback, :after, :action)
end

def use_after_filter(callback)

it { should_not use_after_filter(:destroy_user) }
it { should use_after_filter(:log_activity) }

Example:

Ensure a controller uses a given before_filter
def use_after_filter(callback)
  CallbackMatcher.new(callback, :after, :filter)
end

def use_around_action(callback)

it { should_not use_around_action(:destroy_user) }
it { should use_around_action(:log_activity) }

Example:

Ensure a controller uses a given around_action
def use_around_action(callback)
  CallbackMatcher.new(callback, :around, :action)
end

def use_around_filter(callback)

it { should_not use_around_filter(:destroy_user) }
it { should use_around_filter(:log_activity) }

Example:

Ensure a controller uses a given around_filter
def use_around_filter(callback)
  CallbackMatcher.new(callback, :around, :filter)
end

def use_before_action(callback)

it { should_not use_before_action(:prevent_ssl) }
it { should use_before_action(:authenticate_user!) }

Example:

Ensure a controller uses a given before_action
def use_before_action(callback)
  CallbackMatcher.new(callback, :before, :action)
end

def use_before_filter(callback)

it { should_not use_before_filter(:prevent_ssl) }
it { should use_before_filter(:authenticate_user!) }

Example:

Ensure a controller uses a given before_filter
:nodoc:
def use_before_filter(callback)
  CallbackMatcher.new(callback, :before, :filter)
end