鉴于以下内容:
it "sends an email to user" do
subscription = FactoryGirl.create(:subscription, stripe_customer_token: 'bloop')
subscription.expire!
ActionMailer::Base.deliveries.last.to.should == [subscription.user.email]
end
我明白了:
Failure/Error: ActionMailer::Base.deliveries.last.to.should == [subscription.user.email]
NoMethodError: undefined method `to' for nil:NilClass
# ./spec/models/subscription_spec.rb:113:in `block (3 levels) in <top (required)>'
我不明白,因为如果我在控制台的开发中做同样的事情,我会看到发送的电子邮件。我有test.rb config.action_mailer.delivery_method = :test
问题是什么?