我尝试在我的测试环境中调试我的 user_mailer.rb。但我不知道为什么调试器不会停止它应该停止的地方。
所以,我大致拥有的代码是:
user_mailer_spec.rb
describe UserMailer do
describe '#send_notification_letters' do
# bunch of code omitted here ...
it 'should record itself to the database'
expect { UserMailer.send_notification_letters(user) }.to change{SentMail.count}.by(1)
end
end
end
在user_mailer.rb
class UserMailer < ActionMailer::Base
def send_notification_letters(user)
byebug # should break here but doesnt,
# also tried binding.pry here, also doesnt work
# buggy code ...
# buggy code ...
# buggy code ...
SentMail.create(...) # never reached
mail(to:..., from:...)
end
end
问题是,为什么 byebug/pryuser_mail.rb
在我运行测试时没有停止rspec spec/mailer/user_mailer_spec.rb
?
为什么?
如何让它停在那个断点?
调试器中是否存在错误?