アプリ/モデル/ゾンビ.rb
class Zombie < ActiveRecord::Base
attr_accessible :name
validates :name, presence: true
end
仕様/モデル/ゾンビ_spec.rb
require 'spec_helper'
describe Zombie do
it "is invalid without a name" do
zombie = Zombie.new
zombie.should_not be_valid
end
end
エラー
ゾンビは名前なしでは無効です (FAILED - 1) 失敗:
1) Zombie is invalid without a name Failure/Error: zombie.should_not be_valid ActiveRecord::StatementInvalid: Could not find table 'zombies' # ./spec/models/zombie_spec.rb:5:in `new' # ./spec/models/zombie_spec.rb:5:in `block (2 levels) in <top (required)>'
0.02912秒で完走 7例 失敗1回
失敗した例:
rspec ./spec/models/zombie_spec.rb:4 # 名前のないゾンビは無効
シード 12906 でランダム化