gemfile:
group :test do
gem 'rspec-rails', '2.13.0'
gem 'factory_girl_rails', '~> 4.2.1'
gem 'coveralls', :require => false # 帮助在 coveralls.io 线统计测试覆盖率
end
rake db:migrate RAILS_ENV=test
rails g
rspec
rails g rspec:install
rspec
http://ruby-china.org/topics/2848
describe 类 do
before {
# 准备所有方法测试所要依赖的数据
}
describe '#方法1' do
before {
# 准备该方法测试所要依赖的数据
}
context '第一组参数' do
before {
# 用......
阅读全文