Ruby on Rails development from scratch (Windows) (23)-Functional testing conventions

Source: Internet
Author: User
Tags hash http request ruby on rails

In the previous essay, we tested Login_controller, and we used a lot of rails built in assertions and get,put to test it. Take a look at some of the rails ' conventions on functional testing this time.

1.HTTP requested methods (HTTP request method)

The following methods are used to simulate HTTP requests and receive a response (response)

Get () the put ()
post () The
Delete (
) head ()

Each of these five functions has the same four parameters, with get () as an example:

Get (action, parameters = nil, session = nil, Flash = nil)

Sends an HTTP GET request to the specified action and sets the response, with four parameters meaning:

An action for a controller (controller) specified by the Action:http request.

Parameters: Optional hash, as a parameter to the request.

Session: Optional, session hash.

Flash: optional, flash hash.

Here is an example:

Get:index
Get:add_to_cart,: ID => @version_control_book. ID
get:add_to_cart,: ID => @version_control_ Book.id,
: Session_key => ' Session_value ',: Message => "success!"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.