Permalink
Browse files

adding respond_with matcher to should_respond_with macro, documenting…

… matcher
  • Loading branch information...
croaky authored and jferris committed Feb 5, 2009
1 parent 0a5c6b9 commit 5d0ac376e593f89f83af83dc65fb2be12a89cadf
Showing with 15 additions and 2 deletions.
  1. +2 −1 lib/shoulda/controller/macros.rb
  2. +13 −1 lib/shoulda/controller/matchers/respond_with_matcher.rb
@@ -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
@@ -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

0 comments on commit 5d0ac37

Please sign in to comment.