Methods
- R
- S
- T
-
- teardown,
- test_api_response_with_invalid_resource_respect_override_block,
- test_api_response_with_valid_resource_respect_override_block,
- test_block_inside_respond_with_is_rendered,
- test_clear_respond_to,
- test_error_is_raised_if_no_respond_to_is_declared_and_respond_with_is_called,
- test_first_in_respond_to_has_higher_priority,
- test_no_double_render_is_raised,
- test_not_acceptable,
- test_render_json_object_responds_to_str_still_produce_json,
- test_respond_as_responder_entry_point,
- test_using_hash_resource,
- test_using_hash_resource_with_js_raises_an_error_if_template_cant_be_found,
- test_using_hash_resource_with_post,
- test_using_invalid_resource_with_template,
- test_using_options_with_template,
- test_using_resource,
- test_using_resource_for_delete_with_html_redirects_on_failure,
- test_using_resource_for_delete_with_html_redirects_on_success,
- test_using_resource_for_delete_with_json_yields_no_content_on_success,
- test_using_resource_for_delete_with_xml_yields_no_content_on_success,
- test_using_resource_for_post_with_html_redirects_on_success,
- test_using_resource_for_post_with_html_rerender_on_failure,
- test_using_resource_for_post_with_json_yields_unprocessable_entity_on_failure,
- test_using_resource_for_post_with_xml_yields_created_on_success,
- test_using_resource_for_post_with_xml_yields_unprocessable_entity_on_failure,
- test_using_resource_for_put_with_html_redirects_on_success,
- test_using_resource_for_put_with_html_rerender_on_failure,
- test_using_resource_for_put_with_html_rerender_on_failure_even_on_method_override,
- test_using_resource_for_put_with_json_yields_no_content_on_success,
- test_using_resource_for_put_with_json_yields_unprocessable_entity_on_failure,
- test_using_resource_for_put_with_xml_yields_no_content_on_success,
- test_using_resource_for_put_with_xml_yields_unprocessable_entity_on_failure,
- test_using_resource_with_action,
- test_using_resource_with_block,
- test_using_resource_with_collection,
- test_using_resource_with_js_simply_tries_to_render_the_template,
- test_using_resource_with_overwrite_block,
- test_using_resource_with_parent_for_get,
- test_using_resource_with_parent_for_post,
- test_using_resource_with_responder,
- test_using_resource_with_set_responder,
- test_using_resource_with_status_and_location,
- test_using_resource_with_status_and_location_with_invalid_resource
Instance Public methods
render(params={})
Link
setup()
Link
teardown()
Link
test_api_response_with_invalid_resource_respect_override_block()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 989 def test_api_response_with_invalid_resource_respect_override_block @controller = RenderJsonRespondWithController.new post :create, :name => "david", :format => :json assert_equal '{"valid":false}', @response.body end
test_api_response_with_valid_resource_respect_override_block()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 983 def test_api_response_with_valid_resource_respect_override_block @controller = RenderJsonRespondWithController.new post :create, :name => "sikachu", :format => :json assert_equal '{"valid":true}', @response.body end
test_block_inside_respond_with_is_rendered()
Link
test_clear_respond_to()
Link
test_error_is_raised_if_no_respond_to_is_declared_and_respond_with_is_called()
Link
test_first_in_respond_to_has_higher_priority()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 960 def test_first_in_respond_to_has_higher_priority @controller = InheritedRespondWithController.new @request.accept = "*/*" get :index assert_equal "application/xml", @response.content_type assert_equal "<name>david</name>", @response.body end
test_no_double_render_is_raised()
Link
test_not_acceptable()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 706 def test_not_acceptable @request.accept = "application/xml" get :using_resource_with_block assert_equal 406, @response.status @request.accept = "text/javascript" get :using_resource_with_overwrite_block assert_equal 406, @response.status end
test_render_json_object_responds_to_str_still_produce_json()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 975 def test_render_json_object_responds_to_str_still_produce_json @controller = RenderJsonRespondWithController.new @request.accept = "application/json" get :index, :format => :json assert_match(/"message":"boom"/, @response.body) assert_match(/"error":"RenderJsonTestException"/, @response.body) end
test_respond_as_responder_entry_point()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 943 def test_respond_as_responder_entry_point @request.accept = "text/html" get :using_responder_with_respond assert_equal "respond html", @response.body @request.accept = "application/xml" get :using_responder_with_respond assert_equal "respond xml", @response.body end
test_using_hash_resource()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 662 def test_using_hash_resource @request.accept = "application/xml" get :using_hash_resource assert_equal "application/xml", @response.content_type assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<hash>\n <name>david</name>\n</hash>\n", @response.body @request.accept = "application/json" get :using_hash_resource assert_equal "application/json", @response.content_type assert @response.body.include?("result") assert @response.body.include?('"name":"david"') assert @response.body.include?('"id":13') end
test_using_hash_resource_with_js_raises_an_error_if_template_cant_be_found()
Link
test_using_hash_resource_with_post()
Link
test_using_invalid_resource_with_template()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 1030 def test_using_invalid_resource_with_template errors = { :name => :invalid } Customer.any_instance.stubs(:errors).returns(errors) @request.accept = "text/xml" post :using_invalid_resource_with_template assert_equal errors.to_xml, @response.body assert_equal 422, @response.status assert_equal nil, @response.location put :using_invalid_resource_with_template assert_equal errors.to_xml, @response.body assert_equal 422, @response.status assert_equal nil, @response.location end
test_using_options_with_template()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 1047 def test_using_options_with_template @request.accept = "text/xml" post :using_options_with_template assert_equal "<customer-name>david</customer-name>", @response.body assert_equal 123, @response.status assert_equal "http://test.host/", @response.location put :using_options_with_template assert_equal "<customer-name>david</customer-name>", @response.body assert_equal 123, @response.status assert_equal "http://test.host/", @response.location end
test_using_resource()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 636 def test_using_resource @request.accept = "application/xml" get :using_resource assert_equal "application/xml", @response.content_type assert_equal "<name>david</name>", @response.body @request.accept = "application/json" assert_raise ActionView::MissingTemplate do get :using_resource end end
test_using_resource_for_delete_with_html_redirects_on_failure()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 880 def test_using_resource_for_delete_with_html_redirects_on_failure with_test_route_set do errors = { :name => :invalid } Customer.any_instance.stubs(:errors).returns(errors) Customer.any_instance.stubs(:destroyed?).returns(false) delete :using_resource assert_equal "text/html", @response.content_type assert_equal 302, @response.status assert_equal "http://www.example.com/customers", @response.location end end
test_using_resource_for_delete_with_html_redirects_on_success()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 851 def test_using_resource_for_delete_with_html_redirects_on_success with_test_route_set do Customer.any_instance.stubs(:destroyed?).returns(true) delete :using_resource assert_equal "text/html", @response.content_type assert_equal 302, @response.status assert_equal "http://www.example.com/customers", @response.location end end
test_using_resource_for_delete_with_json_yields_no_content_on_success()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 870 def test_using_resource_for_delete_with_json_yields_no_content_on_success Customer.any_instance.stubs(:to_json).returns('{"name": "David"}') Customer.any_instance.stubs(:destroyed?).returns(true) @request.accept = "application/json" delete :using_resource assert_equal "application/json", @response.content_type assert_equal 204, @response.status assert_equal " ", @response.body end
test_using_resource_for_delete_with_xml_yields_no_content_on_success()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 861 def test_using_resource_for_delete_with_xml_yields_no_content_on_success Customer.any_instance.stubs(:destroyed?).returns(true) @request.accept = "application/xml" delete :using_resource assert_equal "application/xml", @response.content_type assert_equal 204, @response.status assert_equal " ", @response.body end
test_using_resource_for_post_with_html_redirects_on_success()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 716 def test_using_resource_for_post_with_html_redirects_on_success with_test_route_set do post :using_resource assert_equal "text/html", @response.content_type assert_equal 302, @response.status assert_equal "http://www.example.com/customers/13", @response.location assert @response.redirect? end end
test_using_resource_for_post_with_html_rerender_on_failure()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 726 def test_using_resource_for_post_with_html_rerender_on_failure with_test_route_set do errors = { :name => :invalid } Customer.any_instance.stubs(:errors).returns(errors) post :using_resource assert_equal "text/html", @response.content_type assert_equal 200, @response.status assert_equal "New world!\n", @response.body assert_nil @response.location end end
test_using_resource_for_post_with_json_yields_unprocessable_entity_on_failure()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 762 def test_using_resource_for_post_with_json_yields_unprocessable_entity_on_failure with_test_route_set do @request.accept = "application/json" errors = { :name => :invalid } Customer.any_instance.stubs(:errors).returns(errors) post :using_resource assert_equal "application/json", @response.content_type assert_equal 422, @response.status errors = {:errors => errors} assert_equal errors.to_json, @response.body assert_nil @response.location end end
test_using_resource_for_post_with_xml_yields_created_on_success()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 738 def test_using_resource_for_post_with_xml_yields_created_on_success with_test_route_set do @request.accept = "application/xml" post :using_resource assert_equal "application/xml", @response.content_type assert_equal 201, @response.status assert_equal "<name>david</name>", @response.body assert_equal "http://www.example.com/customers/13", @response.location end end
test_using_resource_for_post_with_xml_yields_unprocessable_entity_on_failure()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 749 def test_using_resource_for_post_with_xml_yields_unprocessable_entity_on_failure with_test_route_set do @request.accept = "application/xml" errors = { :name => :invalid } Customer.any_instance.stubs(:errors).returns(errors) post :using_resource assert_equal "application/xml", @response.content_type assert_equal 422, @response.status assert_equal errors.to_xml, @response.body assert_nil @response.location end end
test_using_resource_for_put_with_html_redirects_on_success()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 776 def test_using_resource_for_put_with_html_redirects_on_success with_test_route_set do put :using_resource assert_equal "text/html", @response.content_type assert_equal 302, @response.status assert_equal "http://www.example.com/customers/13", @response.location assert @response.redirect? end end
test_using_resource_for_put_with_html_rerender_on_failure()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 786 def test_using_resource_for_put_with_html_rerender_on_failure with_test_route_set do errors = { :name => :invalid } Customer.any_instance.stubs(:errors).returns(errors) put :using_resource assert_equal "text/html", @response.content_type assert_equal 200, @response.status assert_equal "Edit world!\n", @response.body assert_nil @response.location end end
test_using_resource_for_put_with_html_rerender_on_failure_even_on_method_override()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 798 def test_using_resource_for_put_with_html_rerender_on_failure_even_on_method_override with_test_route_set do errors = { :name => :invalid } Customer.any_instance.stubs(:errors).returns(errors) @request.env["rack.methodoverride.original_method"] = "POST" put :using_resource assert_equal "text/html", @response.content_type assert_equal 200, @response.status assert_equal "Edit world!\n", @response.body assert_nil @response.location end end
test_using_resource_for_put_with_json_yields_no_content_on_success()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 819 def test_using_resource_for_put_with_json_yields_no_content_on_success Customer.any_instance.stubs(:to_json).returns('{"name": "David"}') @request.accept = "application/json" put :using_resource assert_equal "application/json", @response.content_type assert_equal 204, @response.status assert_equal " ", @response.body end
test_using_resource_for_put_with_json_yields_unprocessable_entity_on_failure()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 839 def test_using_resource_for_put_with_json_yields_unprocessable_entity_on_failure @request.accept = "application/json" errors = { :name => :invalid } Customer.any_instance.stubs(:errors).returns(errors) put :using_resource assert_equal "application/json", @response.content_type assert_equal 422, @response.status errors = {:errors => errors} assert_equal errors.to_json, @response.body assert_nil @response.location end
test_using_resource_for_put_with_xml_yields_no_content_on_success()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 811 def test_using_resource_for_put_with_xml_yields_no_content_on_success @request.accept = "application/xml" put :using_resource assert_equal "application/xml", @response.content_type assert_equal 204, @response.status assert_equal " ", @response.body end
test_using_resource_for_put_with_xml_yields_unprocessable_entity_on_failure()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 828 def test_using_resource_for_put_with_xml_yields_unprocessable_entity_on_failure @request.accept = "application/xml" errors = { :name => :invalid } Customer.any_instance.stubs(:errors).returns(errors) put :using_resource assert_equal "application/xml", @response.content_type assert_equal 422, @response.status assert_equal errors.to_xml, @response.body assert_nil @response.location end
test_using_resource_with_action()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 929 def test_using_resource_with_action @controller.instance_eval do def render(params={}) self.response_body = "#{params[:action]} - #{formats}" end end errors = { :name => :invalid } Customer.any_instance.stubs(:errors).returns(errors) post :using_resource_with_action assert_equal "foo - #{[:html].to_s}", @controller.response.body end
test_using_resource_with_block()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 683 def test_using_resource_with_block @request.accept = "*/*" get :using_resource_with_block assert_equal "text/html", @response.content_type assert_equal 'Hello world!', @response.body @request.accept = "text/csv" get :using_resource_with_block assert_equal "text/csv", @response.content_type assert_equal "CSV", @response.body @request.accept = "application/xml" get :using_resource assert_equal "application/xml", @response.content_type assert_equal "<name>david</name>", @response.body end
test_using_resource_with_collection()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 920 def test_using_resource_with_collection @request.accept = "application/xml" get :using_resource_with_collection assert_equal "application/xml", @response.content_type assert_equal 200, @response.status assert_match(/<name>david<\/name>/, @response.body) assert_match(/<name>jamis<\/name>/, @response.body) end
test_using_resource_with_js_simply_tries_to_render_the_template()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 648 def test_using_resource_with_js_simply_tries_to_render_the_template @request.accept = "text/javascript" get :using_resource assert_equal "text/javascript", @response.content_type assert_equal "alert(\"Hi\");", @response.body end
test_using_resource_with_overwrite_block()
Link
test_using_resource_with_parent_for_get()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 892 def test_using_resource_with_parent_for_get @request.accept = "application/xml" get :using_resource_with_parent assert_equal "application/xml", @response.content_type assert_equal 200, @response.status assert_equal "<name>david</name>", @response.body end
test_using_resource_with_parent_for_post()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 900 def test_using_resource_with_parent_for_post with_test_route_set do @request.accept = "application/xml" post :using_resource_with_parent assert_equal "application/xml", @response.content_type assert_equal 201, @response.status assert_equal "<name>david</name>", @response.body assert_equal "http://www.example.com/quiz_stores/11/customers/13", @response.location errors = { :name => :invalid } Customer.any_instance.stubs(:errors).returns(errors) post :using_resource assert_equal "application/xml", @response.content_type assert_equal 422, @response.status assert_equal errors.to_xml, @response.body assert_nil @response.location end end
test_using_resource_with_responder()
Link
test_using_resource_with_set_responder()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 1066 def test_using_resource_with_set_responder RespondWithController.responder = proc { |c, r, o| c.render :text => "Resource name is #{r.first.name}" } get :using_resource assert_equal "Resource name is david", @response.body ensure RespondWithController.responder = ActionController::Responder end
test_using_resource_with_status_and_location()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 1002 def test_using_resource_with_status_and_location @request.accept = "text/html" post :using_resource_with_status_and_location assert @response.redirect? assert_equal "http://test.host/", @response.location @request.accept = "application/xml" get :using_resource_with_status_and_location assert_equal 201, @response.status end
test_using_resource_with_status_and_location_with_invalid_resource()
Link
# File actionpack/test/controller/mime_responds_test.rb, line 1013 def test_using_resource_with_status_and_location_with_invalid_resource errors = { :name => :invalid } Customer.any_instance.stubs(:errors).returns(errors) @request.accept = "text/xml" post :using_resource_with_status_and_location assert_equal errors.to_xml, @response.body assert_equal 422, @response.status assert_equal nil, @response.location put :using_resource_with_status_and_location assert_equal errors.to_xml, @response.body assert_equal 422, @response.status assert_equal nil, @response.location end