<commit_before>Feature: have_enqueued_mail matcher

  The `have_enqueued_mail` (also aliased as `enqueue_mail`) matcher is used to check if given mailer was enqueued.

  Background:
    Given active job is available

  Scenario: Checking mailer class and method name
    Given a file named "spec/mailers/user_mailer_spec.rb" with:
      """ruby
      require "rails_helper"

      RSpec.describe NotificationsMailer do
        it "matches with enqueued mailer" do
          ActiveJob::Base.queue_adapter = :test
          expect {
            NotificationsMailer.signup.deliver_later
          }.to have_enqueued_mail(NotificationsMailer, :signup)
        end
      end
      """
    When I run `rspec spec/mailers/user_mailer_spec.rb`
    Then the examples should all pass

  Scenario: Checking mailer enqueued time
    Given a file named "spec/mailers/user_mailer_spec.rb" with:
      """ruby
      require "rails_helper"

      RSpec.describe NotificationsMailer do
        it "matches with enqueued mailer" do
          ActiveJob::Base.queue_adapter = :test
          expect {
            NotificationsMailer.signup.deliver_later(wait_until: Date.tomorrow.noon)
          }.to have_enqueued_mail.at(Date.tomorrow.noon)
        end
      end
      """
    When I run `rspec spec/mailers/user_mailer_spec.rb`
    Then the examples should all pass

  Scenario: Checking mailer arguments
    Given a file named "app/mailers/my_mailer.rb" with:
      """ruby
      class MyMailer < ApplicationMailer

        def signup(user = nil)
          @user = user

          mail to: "<EMAIL>"
        end
      end
      """
    Given a file named "spec/mailers/my_mailer_spec.rb" with:
      """ruby
      require "rails_helper"

      RSpec.describe MyMailer do
        it "matches with enqueued mailer" do
          ActiveJob::Base.queue_adapter = :test
          # Works with plain args
          expect {
            MyMailer.signup('user').deliver_later
          }.to have_enqueued_mail(MyMailer, :signup).with('user')
          # Works with named parameters
          expect {
            MyMailer.with('foo' => 'bar').signup.deliver_later
          }.to have_enqueued_mail(MyMailer, :signup).with('foo' => 'bar')
          # Works also with both, named parameters match first argument
          expect {
            MyMailer.with('foo' => 'bar').signup('user').deliver_later
          }.to have_enqueued_mail(MyMailer, :signup).with({'foo' => 'bar'}, 'user')
        end
      end
      """
    When I run `rspec spec/mailers/my_mailer_spec.rb`
    Then the examples should all pass<commit_msg>Split all syntax in different examples<commit_after>Feature: have_enqueued_mail matcher

  The `have_enqueued_mail` (also aliased as `enqueue_mail`) matcher is used to check if given mailer was enqueued.

  Background:
    Given active job is available

  Scenario: Checking mailer class and method name
    Given a file named "spec/mailers/user_mailer_spec.rb" with:
      """ruby
      require "rails_helper"

      RSpec.describe NotificationsMailer do
        it "matches with enqueued mailer" do
          ActiveJob::Base.queue_adapter = :test
          expect {
            NotificationsMailer.signup.deliver_later
          }.to have_enqueued_mail(NotificationsMailer, :signup)
        end
      end
      """
    When I run `rspec spec/mailers/user_mailer_spec.rb`
    Then the examples should all pass

  Scenario: Checking mailer enqueued time
    Given a file named "spec/mailers/user_mailer_spec.rb" with:
      """ruby
      require "rails_helper"

      RSpec.describe NotificationsMailer do
        it "matches with enqueued mailer" do
          ActiveJob::Base.queue_adapter = :test
          expect {
            NotificationsMailer.signup.deliver_later(wait_until: Date.tomorrow.noon)
          }.to have_enqueued_mail.at(Date.tomorrow.noon)
        end
      end
      """
    When I run `rspec spec/mailers/user_mailer_spec.rb`
    Then the examples should all pass

  Scenario: Checking mailer arguments
    Given a file named "app/mailers/my_mailer.rb" with:
      """ruby
      class MyMailer < ApplicationMailer

        def signup(user = nil)
          @user = user

          mail to: "<EMAIL>"
        end
      end
      """
    Given a file named "spec/mailers/my_mailer_spec.rb" with:
      """ruby
      require "rails_helper"

      RSpec.describe MyMailer do
        it "matches with enqueued mailer" do
          ActiveJob::Base.queue_adapter = :test
          # Works with plain args
          expect {
            MyMailer.signup('user').deliver_later
          }.to have_enqueued_mail(MyMailer, :signup).with('user')
        end
      end
      """
    When I run `rspec spec/mailers/my_mailer_spec.rb`
    Then the examples should all pass

  Scenario: Parameterize the mailer
    Given a file named "app/mailers/my_mailer.rb" with:
      """ruby
      class MyMailer < ApplicationMailer

        def signup(user = nil)
          @user = user

          mail to: "<EMAIL>"
        end
      end
      """
    Given a file named "spec/mailers/my_mailer_spec.rb" with:
      """ruby
      require "rails_helper"

      RSpec.describe MyMailer do
        it "matches with enqueued mailer" do
          ActiveJob::Base.queue_adapter = :test
          # Works with named parameters
          expect {
            MyMailer.with(foo: 'bar').signup.deliver_later
          }.to have_enqueued_mail(MyMailer, :signup).with(foo: 'bar')
        end
      end
      """
    When I run `rspec spec/mailers/my_mailer_spec.rb`
    Then the examples should all pass

  Scenario: Parameterize and pass an argument to the mailer
    Given a file named "app/mailers/my_mailer.rb" with:
      """ruby
      class MyMailer < ApplicationMailer

        def signup(user = nil)
          @user = user

          mail to: "<EMAIL>"
        end
      end
      """
    Given a file named "spec/mailers/my_mailer_spec.rb" with:
      """ruby
      require "rails_helper"

      RSpec.describe MyMailer do
        it "matches with enqueued mailer" do
          ActiveJob::Base.queue_adapter = :test
          # Works also with both, named parameters match first argument
          expect {
            MyMailer.with('foo' => 'bar').signup('user').deliver_later
          }.to have_enqueued_mail(MyMailer, :signup).with({foo: 'bar'}, 'user')
        end
      end
      """
    When I run `rspec spec/mailers/my_mailer_spec.rb`
    Then the examples should all pass
{'fraction_non_alphanumeric': 0.08489253131281893, 'fraction_numerical': 0.0, 'mean_word_length': 2.303370786516854, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '250314', 'n_tokens_mistral': 2015, 'n_tokens_neox': 1938, 'n_words': 537}