gem install rspec
rspec --init我们可以用 .rspec 文件做 rspec 的配置。
--color
--format documentation这里的 documentation 可以让 rspec 显示出具体的信息,而默认的是
--format progress 只会显示类似 testunit 的显示形式。
rails new *application* --skip-test-unit可以让 rails 不要给予 test-unit 的任何内容。 然后在 Gemfile 添加
group :development, :test do
  gem 'rspec-rails'
end然后
rails generate rspec:install之后如果执行rails g scaffold那么就会在spec目录下建立相应的测试。
group :development, :test do
  gem 'rspec-rails'
  gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
  gem 'guard-rspec'
  gem 'guard-livereload'
end安装 guard 的支持非常的简单。然后
guard init rspec
guard init livereload
guard对于还没有想好测试内容的情况这个就是超级有用了。
首先可以这样做
describe Hotel do
  it "should have method price"
end或者这样
describe Hotel do
  it "should have method price" do
    pending
  end
endzombie = Zombie.new (name: 'Ash')
zombie.name.should == 'Ash'
zombie.should respond_to(:name)
zombie.weapons.should include(weapon)
zombie.weapon.should_not be_nil