これは非常に単純な質問ですが、多くのバリエーションがあるにもかかわらず、これを修正できないようです。
it "will send an email" do
invitation = Invitation.new
invitation.email = "host@localhost.com"
invitation.deliver
invitation.sent.should == true
end
私のモデル:
class Invitation
include Mongoid::Document
include Mongoid::Timestamps
field :email, :type => String, :presence => true, :email => true
field :sent, :type => Boolean, :default => false
field :used, :type => Boolean, :default => false
validates :email, :uniqueness => true, :email => true
def is_registered?
User.where(:email => email).count > 0
end
def deliver
sent = true
save
end
end
これは以下を出力します:
1) Invitation will send an email
Failure/Error: invitation.sent.should == true
expected: true
got: false (using ==)
# ./spec/models/invitation_spec.rb:26:in `block (2 levels) in <top (required)>'
値を設定してモデル自体に保存するにはどうすればよいですか?