失敗するはずなのに、2番目の例が成功する理由がわかりません
これは私の person_spec.rb です:
require 'spec_helper'
describe Person do
it "must have a first name" do
subject { Person.new(first_name: "", last_name: "Kowalski") }
subject.should_not be_valid
end
it "must have a last name" do
subject { Person.new(first_name: "Jan") }
subject.should_not be_valid
end
end
これは私の人です.rb
class Person < ActiveRecord::Base
attr_accessible :first_name, :last_name
validates :first_name, presence: true
def full_name
return "#{@first_name} #{@last_name}"
end
end
私のrspec出力:
Person
must have a last name
must have a first name
Finished in 0.09501 seconds
2 examples, 0 failures
Randomized with seed 51711
さらに悪いことは、私のさらなる例が非常に予想外の方法で失敗/合格していることです。どういうわけか私の件名は Person のインスタンスですが、 first_name も last_name も割り当てられていないようです