1,安装
2,Generator
3,写测试
4,测试
5,使用--drb来让测试飞快运行
- gem install rspec
- ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec
- ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec_on_rails
- ruby script/generate rspec
2,Generator
- ruby script/generate rspec_scaffold User name:string age:integer
- ruby script/generate rspec_model User
- ruby script/generate rspec_controller User
3,写测试
- require File.dirname(__FILE__) + '/../spec_helper'
- describe User do
- before(:each) do
- @user = User.new
- end
- it "should be valid" do
- @user.should be_valid
- end
- end
4,测试
- spec spec/models/user_spec.rb
- rake spec:models
- rake spec
5,使用--drb来让测试飞快运行
- ruby script\spec_server
- spec --drb spec\models\user_spec.rb
- spec --drb spec\models\*
- spec --drb spec\models\*_spec.rb