什么是 Rails 3 合适的测试框架? [英] What is a suitable testing framework for Rails 3?

查看:40
本文介绍了什么是 Rails 3 合适的测试框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

去年我一直在使用 Ruby On Rails.但是,无法进行单元测试.现在我必须编写单元测试代码.哪个测试框架是好的,为什么?

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?

有什么好的教程吗?

我的系统配置:Ruby 1.9.2、Rails 3、Ubuntu 10

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

推荐答案

我从过去两年开始使用 Rspec,从我的角度来看,它是我使用过的最简单的 Ruby 测试框架.

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.

在 Rspec 中,您必须使用 factories 创建模型的对象并在脚本中使用它.

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

在 Rspec 中只需要编写 3 个块:describecontextit.

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

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

这篇关于什么是 Rails 3 合适的测试框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆