app/models/zombie.rb
class Zombie < ActiveRecord::Base
attr_accessible :name
validates :name, presence: true
end
spec/models/zombie_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
errors
Zombie
is invalid without a name (FAILED – 1)
Failures: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)>'Finished in 0.02912 seconds
7 examples, 1 failureFailed examples:
rspec ./spec/models/zombie_spec.rb:4 # Zombie is invalid without a name
Randomized with seed 12906
Thanks everyone, I was not running migrations so running rake db:migrate fixed it