Module Merb::Test::Rspec::ControllerMatchers
In: lib/merb-core/test/matchers/controller_matchers.rb

Methods

Classes and Modules

Class Merb::Test::Rspec::ControllerMatchers::BeMissing
Class Merb::Test::Rspec::ControllerMatchers::BeRedirect
Class Merb::Test::Rspec::ControllerMatchers::BeSuccess
Class Merb::Test::Rspec::ControllerMatchers::Provide
Class Merb::Test::Rspec::ControllerMatchers::RedirectTo

Public Instance methods

be_client_error()

Alias for be_missing

Passes if the request that generated the target was missing, or the target is a client-side error (400 level) response code.

Examples

  # Passes if the controller call was unknown or not understood
  controller.should be_missing

  # Also passes if the target is a response code
  controller.status.should be_missing

Notes

valid HTTP Client Error codes:

  • 400: Bad Request
  • 401: Unauthorized
  • 402: Payment Required
  • 403: Forbidden
  • 404: Not Found
  • 405: Method Not Allowed
  • 406: Not Acceptable
  • 407: Proxy Authentication Required
  • 408: Request Timeout
  • 409: Conflict
  • 410: Gone
  • 411: Length Required
  • 412: Precondition Failed
  • 413: Request Entity Too Large
  • 414: Request-URI Too Long
  • 415: Unsupported Media Type
  • 416: Requested Range Not Satisfiable
  • 417: Expectation Failed
  • 422: Unprocessable Entity
be_redirection()

Alias for redirect

be_redirection_to(expected)

Alias for redirect_to

be_successful()

Passes if the controller actually provides the target format

Parameters

expected<Symbol>:A format to check

Examples

  ControllerClass.should provide( :html )
  controller_instance.should provide( :xml )

Passes if the target was redirected, or the target is a redirection (300 level) response code.

Examples

  # Passes if the controller was redirected
  controller.should redirect

  # Also works if the target is the response code
  controller.status.should redirect

Notes

valid HTTP Redirection codes:

  • 300: Multiple Choices
  • 301: Moved Permanently
  • 302: Moved Temporarily (HTTP/1.0)
  • 302: Found (HTTP/1.1)
  • 303: See Other (HTTP/1.1)
  • 304: Not Modified
  • 305: Use Proxy
  • 307: Temporary Redirect

Passes if the target was redirected to the expected location.

Paramters

expected<String>:A relative or absolute url.

Examples

  # Passes if the controller was redirected to http://example.com/
  controller.should redirect_to('http://example.com/')

Passes if the request that generated the target was successful, or the target is a success (200 level) response code.

Examples

  # Passes if the controller call was successful
  controller.should respond_successfully

  # Also works if the target is the response code
  controller.status.should respond_successfully

Notes

valid HTTP Success codes:

  • 200: OK
  • 201: Created
  • 202: Accepted
  • 203: Non-Authoritative Information
  • 204: No Content
  • 205: Reset Content
  • 206: Partial Content
  • 207: Multi-Status

[Validate]