Skip to content

Commit 016c0ec

Browse files
morgothJonRowe
authored andcommitted
Fixed AJ job name in generated error message (#1814)
1 parent 547e8d1 commit 016c0ec

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/rspec/rails/matchers/active_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def base_job_message(job)
129129
msg_parts << "on queue #{job[:queue]}" if job[:queue]
130130
msg_parts << "at #{Time.at(job[:at])}" if job[:at]
131131

132-
"#{job[:job].class.name} job".tap do |msg|
132+
"#{job[:job].name} job".tap do |msg|
133133
msg << " #{msg_parts.join(', ')}" if msg_parts.any?
134134
end
135135
end

spec/rspec/rails/matchers/active_job_spec.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,22 @@ def to_global_id(options = {})
3838
let(:heavy_lifting_job) do
3939
Class.new(ActiveJob::Base) do
4040
def perform; end
41+
def self.name; "HeavyLiftingJob"; end
4142
end
4243
end
4344

4445
let(:hello_job) do
4546
Class.new(ActiveJob::Base) do
4647
def perform(*)
4748
end
49+
def self.name; "HelloJob"; end
4850
end
4951
end
5052

5153
let(:logging_job) do
5254
Class.new(ActiveJob::Base) do
5355
def perform; end
56+
def self.name; "LoggingJob"; end
5457
end
5558
end
5659

@@ -217,7 +220,7 @@ def perform; end
217220
date = Date.tomorrow.noon
218221
message = "expected to enqueue exactly 2 jobs, with [42], on queue low, at #{date}, but enqueued 0" + \
219222
"\nQueued jobs:" + \
220-
"\n Class job with [1], on queue default"
223+
"\n HelloJob job with [1], on queue default"
221224

222225
expect {
223226
expect {

0 commit comments

Comments
 (0)