What is a suitable testing framework for Rails 3?

一个人想着一个人 提交于 2019-12-10 11:14:46

问题


I am working with Ruby On Rails for the last year. But, could not work on Unit Testing. Now I have to write a unit testing code. Which testing framework is good and why?

Is there any good tutorial for this?

My system configuration: Ruby 1.9.2, Rails 3, Ubuntu 10


回答1:


The first tip is: Try upgrading to Rails 5.x. This is good practice to always leave your system clean and faultless from third parties.

Your greatest friend will always be the rails documentation: http://guides.rubyonrails.org/v3.2/testing.html

In last case if you can not upgrade, you can use the Minitest/Rspec gems, in old versions compatible with the current versions of development.

To perform integration testing you can try using Capybara or Google Chrome Headless.

You can look at how some big projects do tests, like the RubyGems site, which is written in RoR and is open in Github: https://github.com/rubygems/rubygems.org




回答2:


I am using Rspec from last two years and from my point of view it is easiest testing framework for Ruby that I have used.

In Rspec, you have to create objects of your models using factories and use it in script.

There are only 3 - blocks to write in Rspec : describe, context and it.

Refer - https://relishapp.com/rspec/rspec-rails/v/3-0/docs/model-specs



来源:https://stackoverflow.com/questions/5987128/what-is-a-suitable-testing-framework-for-rails-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!