Rails Test "IV" unit test

Source: Internet
Author: User
Tags ruby on rails

The previous blog introduced some knowledge about rails testing. Test the location of the files, the types of tests, test common commands, and some of the resources available, and how to generate mock data using fixtures.

Today we're going to actually write unit tests, and the knowledge we use is mainly fixtures and test. Fixtures is used to simulate data, unit test is our leading actor today.

Today's code will write some unit tests for this project in the context of a blog project.

The code for this project is available in Https://github.com/woaigithub/blog, and the project has been deployed to http://42.121.5.68:10000/, and you can write your own blog directly on the deployed production environment.

Master is the main branch, develop is the development branch, and the code in the Development branch is up to date.

The project uses Ruby on Rails to develop, develop, and test the environment using SQLITE3 as the data store, and the production environment uses MySQL as the data store.

Unit Test

The Rails unit tests are focused on Model,model as our business entity. Unit Test main test model validates, as well as model business rules, testing through the implementation of business rules, our model changes, is the model of the property value, whether the description of the rules, whether to become the expected value.

= = Advertising Start

This blog is positioned as a collaborative blogging platform. Is that everyone can write a blog, blog management, including classification, tag and so on.

The main target audience for the blog is the developer, and more other types of practitioners are welcome to blog on this platform.

By registering in the upper-right corner, you can become an admin of this blog platform, and then you can write blogs and manage blogs. Of course, look at the blog is not required to register, directly can browse.

In the footer section, there is an admin link that can be entered backstage through a link. Of course, entering the background requires login.

Blog platform is still in development, if you have any good ideas, or want to join the development, can be https://github.com/woaigithub/blog on the message.

= = End of advertisement

Our project this time is a blog with some basic features.

Browse the Blogs list, sort through blogs, and browse through individual posts.

Check your blog post and leave a message for your blog.

Registered users, landing platform.

Manage blogs, manage blog posts, manage categories, manage tag, manage reviews.

Table structure is as follows

### users

Id

Nickname

Email

Password_digest

Salt

Created_at

Updated_at

### tags

Id

Title

Created_at

Updated_at

### Categorys

Id

Title

Created_at

Updated_at

### comments

Id

Commenter

Commenter_email

Commenter_url

Content

post_id

Created_at

Updated_at

### posts

Id

Title

Slug

category_id

Summary

Content

Created_at

Updated_at

user_id

### Posts_tags

post_id

tag_id

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.