Skip to content

Commit ab6e6e8

Browse files
committed
Refactor check method
Previous PR had split this up to avoid a rubocop rule infringment but did so in a way making it less clear what happened, we could turn off the rule instead for this method but refactoring the job matching method also satisfies the rule without sacrificing readability.
1 parent 6f9977f commit ab6e6e8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/rspec/rails/matchers/active_job.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def supports_block_expectations?
109109

110110
def check(jobs)
111111
@matching_jobs, @unmatching_jobs = jobs.partition do |job|
112-
if job_match?(job) && arguments_match?(job) && queue_match?(job) && at_match?(job) && priority_match?(job)
112+
if matches_constraints?(job)
113113
args = deserialize_arguments(job)
114114
@block.call(*args)
115115
true
@@ -123,10 +123,6 @@ def check(jobs)
123123
return false
124124
end
125125

126-
check_countable
127-
end
128-
129-
def check_countable
130126
@matching_jobs_count = @matching_jobs.size
131127

132128
case @expectation_type
@@ -163,7 +159,11 @@ def base_job_message(job)
163159
end
164160
end
165161

166-
def job_match?(job)
162+
def matches_constraints?(job)
163+
job_matches?(job) && arguments_match?(job) && queue_match?(job) && at_match?(job) && priority_match?(job)
164+
end
165+
166+
def job_matches?(job)
167167
@job ? @job == job[:job] : true
168168
end
169169

0 commit comments

Comments
 (0)