Skip to content

Commit

Permalink
adding respond_with matcher to should_respond_with macro, documenting…
Browse files Browse the repository at this point in the history
… matcher
  • Loading branch information
Dan Croak authored and jferris committed Feb 7, 2009
1 parent 0a5c6b9 commit 5d0ac37
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/shoulda/controller/macros.rb
Expand Up @@ -174,7 +174,8 @@ def should_not_assign_to(*names)
# should_respond_with :success
def should_respond_with(response)
should "respond with #{response}" do
assert_response response
matcher = respond_with(response)
assert_accepts matcher, @controller
end
end

Expand Down
14 changes: 13 additions & 1 deletion lib/shoulda/controller/matchers/respond_with_matcher.rb
Expand Up @@ -2,7 +2,19 @@ module Shoulda # :nodoc:
module Controller # :nodoc:
module Matchers

# docs
# Ensures a controller responded with expected 'response' status code.
#
# You can pass an explicit status number like 200, 301, 404, 500
# or its symbolic equivalent :success, :redirect, :missing, :error.
# See ActionController::StatusCodes for a full list.
#
# Example:
#
# it { should respond_with(:success) }
# it { should respond_with(:redirect) }
# it { should respond_with(:missing) }
# it { should respond_with(:error) }
# it { should respond_with(501) }
def respond_with(status)
RespondWithMatcher.new(status)
end
Expand Down

0 comments on commit 5d0ac37

Please sign in to comment.