Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* `have_been_performed` is like `have_been_enqueued`, but for performed jobs * `have_performed_job`/`perform_job` is like `have_enqueued_job`/`enqueue_job`, but for performed jobs Co-authored-by: Phil Pirozhkov hello@fili.pp.ru
- Loading branch information
1 parent
7d68eb2
commit bcf77ba
Showing
6 changed files
with
552 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
Feature: have_been_performed matcher | ||
|
||
The `have_been_performed` matcher is used to check if given ActiveJob job was performed. | ||
|
||
Background: | ||
Given active job is available | ||
|
||
Scenario: Checking job class name | ||
Given a file named "spec/jobs/upload_backups_job_spec.rb" with: | ||
"""ruby | ||
require "rails_helper" | ||
RSpec.describe UploadBackupsJob do | ||
it "matches with performed job" do | ||
ActiveJob::Base.queue_adapter = :test | ||
ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true | ||
UploadBackupsJob.perform_later | ||
expect(UploadBackupsJob).to have_been_performed | ||
end | ||
end | ||
""" | ||
When I run `rspec spec/jobs/upload_backups_job_spec.rb` | ||
Then the examples should all pass | ||
|
||
Scenario: Checking passed arguments to job | ||
Given a file named "spec/jobs/upload_backups_job_spec.rb" with: | ||
"""ruby | ||
require "rails_helper" | ||
RSpec.describe UploadBackupsJob do | ||
it "matches with performed job" do | ||
ActiveJob::Base.queue_adapter = :test | ||
ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true | ||
UploadBackupsJob.perform_later("users-backup.txt", "products-backup.txt") | ||
expect(UploadBackupsJob).to( | ||
have_been_performed.with("users-backup.txt", "products-backup.txt") | ||
) | ||
end | ||
end | ||
""" | ||
When I run `rspec spec/jobs/upload_backups_job_spec.rb` | ||
Then the examples should all pass | ||
|
||
Scenario: Checking job performed time | ||
Given a file named "spec/jobs/upload_backups_job_spec.rb" with: | ||
"""ruby | ||
require "rails_helper" | ||
RSpec.describe UploadBackupsJob do | ||
it "matches with performed job" do | ||
ActiveJob::Base.queue_adapter = :test | ||
ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true | ||
ActiveJob::Base.queue_adapter.perform_enqueued_at_jobs = true | ||
UploadBackupsJob.set(:wait_until => Date.tomorrow.noon).perform_later | ||
expect(UploadBackupsJob).to have_been_performed.at(Date.tomorrow.noon) | ||
end | ||
end | ||
""" | ||
When I run `rspec spec/jobs/upload_backups_job_spec.rb` | ||
Then the examples should all pass | ||
|
||
Scenario: Checking job queue name | ||
Given a file named "spec/jobs/upload_backups_job_spec.rb" with: | ||
"""ruby | ||
require "rails_helper" | ||
RSpec.describe UploadBackupsJob do | ||
it "matches with performed job" do | ||
ActiveJob::Base.queue_adapter = :test | ||
ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true | ||
UploadBackupsJob.perform_later | ||
expect(UploadBackupsJob).to have_been_performed.on_queue("default") | ||
end | ||
end | ||
""" | ||
When I run `rspec spec/jobs/upload_backups_job_spec.rb` | ||
Then the examples should all pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
Feature: have_performed_job matcher | ||
|
||
The `have_performed_job` (also aliased as `perform_job`) matcher is used to check if given ActiveJob job was performed. | ||
|
||
Background: | ||
Given active job is available | ||
|
||
Scenario: Checking job class name | ||
Given a file named "spec/jobs/upload_backups_job_spec.rb" with: | ||
"""ruby | ||
require "rails_helper" | ||
RSpec.describe UploadBackupsJob do | ||
it "matches with performed job" do | ||
ActiveJob::Base.queue_adapter = :test | ||
ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true | ||
expect { | ||
UploadBackupsJob.perform_later | ||
}.to have_performed_job(UploadBackupsJob) | ||
end | ||
end | ||
""" | ||
When I run `rspec spec/jobs/upload_backups_job_spec.rb` | ||
Then the examples should all pass | ||
|
||
Scenario: Checking passed arguments to job | ||
Given a file named "spec/jobs/upload_backups_job_spec.rb" with: | ||
"""ruby | ||
require "rails_helper" | ||
RSpec.describe UploadBackupsJob do | ||
it "matches with performed job" do | ||
ActiveJob::Base.queue_adapter = :test | ||
ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true | ||
expect { | ||
UploadBackupsJob.perform_later("users-backup.txt", "products-backup.txt") | ||
}.to have_performed_job.with("users-backup.txt", "products-backup.txt") | ||
end | ||
end | ||
""" | ||
When I run `rspec spec/jobs/upload_backups_job_spec.rb` | ||
Then the examples should all pass | ||
|
||
Scenario: Checking job performed time | ||
Given a file named "spec/jobs/upload_backups_job_spec.rb" with: | ||
"""ruby | ||
require "rails_helper" | ||
RSpec.describe UploadBackupsJob do | ||
it "matches with performed job" do | ||
ActiveJob::Base.queue_adapter = :test | ||
ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true | ||
ActiveJob::Base.queue_adapter.perform_enqueued_at_jobs = true | ||
expect { | ||
UploadBackupsJob.set(:wait_until => Date.tomorrow.noon).perform_later | ||
}.to have_performed_job.at(Date.tomorrow.noon) | ||
end | ||
end | ||
""" | ||
When I run `rspec spec/jobs/upload_backups_job_spec.rb` | ||
Then the examples should all pass | ||
|
||
Scenario: Checking job queue name | ||
Given a file named "spec/jobs/upload_backups_job_spec.rb" with: | ||
"""ruby | ||
require "rails_helper" | ||
RSpec.describe UploadBackupsJob do | ||
it "matches with performed job" do | ||
ActiveJob::Base.queue_adapter = :test | ||
ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true | ||
expect { | ||
UploadBackupsJob.perform_later | ||
}.to have_performed_job.on_queue("default") | ||
end | ||
end | ||
""" | ||
When I run `rspec spec/jobs/upload_backups_job_spec.rb` | ||
Then the examples should all pass | ||
|
||
Scenario: Using alias method | ||
Given a file named "spec/jobs/upload_backups_job_spec.rb" with: | ||
"""ruby | ||
require "rails_helper" | ||
RSpec.describe UploadBackupsJob do | ||
it "matches with performed job" do | ||
ActiveJob::Base.queue_adapter = :test | ||
ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true | ||
expect { | ||
UploadBackupsJob.perform_later | ||
}.to perform_job(UploadBackupsJob) | ||
end | ||
end | ||
""" | ||
When I run `rspec spec/jobs/upload_backups_job_spec.rb` | ||
Then the examples should all pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.