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` is like `have_enqueued_job`, but for performed jobs
- Loading branch information
1 parent
82340ff
commit 627d979
Showing
5 changed files
with
548 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
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_performed_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_performed_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_performed_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_performed_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,96 @@ | ||
Feature: have_performed_job matcher | ||
|
||
The `have_performed_job` (also aliased as `enqueue_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_adatper.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_adatper.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_adatper.perform_enqueued_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_adatper.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_adatper.perform_enqueued_jobs = true | ||
expect { | ||
UploadBackupsJob.perform_later | ||
}.to enqueue_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.