说说rspec测试的使用
2013-08-23 00:37
357 查看
近来开始学习ruby on rails,用rspec做unit test.
An basic rspec testing requires the following steps:
1. add gem 'rspec-rails' to Gemfile and run 'bundle install'
2. run
here, for example, vcr configuration. .rspec file can define how the result will be shown. You can run 'rspec --help' for more information.
3. Add a test. File name usually is class_name_spec.rb. A template can be as follows:
require 'spec_helper'
describe className do
context '...' do #optional
it "should..." do
sth.should == expected
end
end
end
4. run the test
rspec file_directory
That's all.
An basic rspec testing requires the following steps:
1. add gem 'rspec-rails' to Gemfile and run 'bundle install'
2. run
'rails generate rspec:install' to initialize rspec and generate spec directory. Two configuration files will be added under spec/: .rspec and spec_helper. spec_helper defines configurations required to run the test. Some more can be added
here, for example, vcr configuration. .rspec file can define how the result will be shown. You can run 'rspec --help' for more information.
3. Add a test. File name usually is class_name_spec.rb. A template can be as follows:
require 'spec_helper'
describe className do
context '...' do #optional
it "should..." do
sth.should == expected
end
end
end
4. run the test
rspec file_directory
That's all.
相关文章推荐
- 使用 RSpec 进行行为驱动测试
- 使用Cucumber+Rspec玩转BDD(7)——测试重构
- 使用Rspec进行行为驱动测试
- 使用Rspec进行rails测试详解1-Transactions
- 使用 RSpec 进行行为驱动测试
- 使用Rspec进行rails测试详解1-搭建测试环境
- rails3使用cucumber和rspec进行测试
- 使用 RSpec 进行行为驱动测试
- 转:rsync传输性能测试总结及使用技巧
- mysql使用存储过程批量生成学生表、课程表和成绩表测试数据
- memcache使用方法测试
- 使用Afl-fuzz (American Fuzzy Lop) 进行fuzzing测试(待续)
- PICT测试用例辅助使用
- CaffeOnSpark安装和使用教程系列三:集群环境下使用CaffeOnSpark进行MNIST数据集的测试
- 如何使用思维导图更高效的设计测试用例?
- 说说Android 两种为自定义组件添加属性的使用方法和区别
- 性能测试——使用单用户并发
- Rspec 使用笔记
- 建议网页开发者使用IE8测试版测试网站
- 使用非 GUI 模式运行 JMeter 压力测试