Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1f9c0ff

Browse files
committedJan 23, 2022
wip: Extract arg condition method
1 parent a485fd0 commit 1f9c0ff

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed
 

‎lib/rspec/rails/feature_check.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ def has_action_mailbox?
4343
defined?(::ActionMailbox)
4444
end
4545

46-
def ruby_3_1?
47-
RUBY_VERSION >= "3.1"
46+
# TODO: add a self-explanatory method name. See https://github.com/rspec/rspec-rails/pull/2552#issuecomment-1009508693 for hints
47+
def rails_6_1_and_ruby_3_1?
48+
return false if RUBY_VERSION < "3.1"
49+
50+
::Rails::VERSION::STRING >= "6.1" && ::Rails::VERSION::STRING < "7"
4851
end
4952

5053
def type_metatag(type)

‎lib/rspec/rails/matchers/have_enqueued_mail.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,11 @@ def process_arguments(job, given_mail_args)
102102

103103
def use_given_mail_args?(job)
104104
return true if FeatureCheck.has_action_mailer_parameterized? && job[:job] <= ActionMailer::Parameterized::DeliveryJob
105-
return false if rails_6_1_and_ruby_3_1?
105+
return false if FeatureCheck.rails_6_1_and_ruby_3_1?
106106

107107
!(FeatureCheck.has_action_mailer_unified_delivery? && job[:job] <= ActionMailer::MailDeliveryJob)
108108
end
109109

110-
# TODO: move to FeatureCheck
111-
def rails_6_1_and_ruby_3_1?
112-
return false unless RUBY_VERSION >= "3.1"
113-
return false unless ::Rails::VERSION::STRING >= '6.1'
114-
115-
::Rails::VERSION::STRING < '7'
116-
end
117-
118110
def base_mailer_args
119111
[mailer_class_name, @method_name.to_s, MAILER_JOB_METHOD]
120112
end

0 commit comments

Comments
 (0)
Please sign in to comment.