10

テスト環境で 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

user_mail.rb問題は、テストを実行したときに byebug/pry が停止しないのはなぜrspec spec/mailer/user_mailer_spec.rbですか?

なぜ?

そのブレークポイントで停止させるにはどうすればよいですか?

デバッガにバグはありますか?

4

3 に答える 3

1

私は今日同じ状況に遭遇しました。掘り下げた後、私の問題はthinサーバーのdaemonize構成が原因であることがわかりました。

あなたの編集config/thin.yml

daemonize: false

またはthin、Gemfile で gem をコメントアウトして、WEBrick代わりにデフォルトを使用することもできます。

于 2015-05-19T03:47:15.327 に答える
0

サーバーを再起動するだけで、同じ問題が発生しました。

私の場合はプーマで、スプリングなしです。

于 2020-05-28T14:43:04.730 に答える