RSpecResponseCodeMatchers is rspec’s custom spec matcher, that checking http response code.
target is Integer or Object, that defined “status” method.
require "rspec_response_code_matchers" 500.should be_internal_server_error 404.should be_not_found
in spec/spec_helper.rb:
require "rspec_response_code_matchers"
in spec/requests/sample_helper.rb:
describe "/sample/show" do before(:each) do @response = request("/sample/show") end it "should response code 301(redirect)" do @response.should be_redirect # match 3xx @response.should be_moved_permanently # match 301 end end
Copyright © 2009 hiroeorz. See LICENSE for details.