Skip to content

Commit

Permalink
Merge pull request #190 from wspurgin/jumpstart
Browse files Browse the repository at this point in the history
👋 Hi I'm the new maintainer
  • Loading branch information
packrat386 authored Jul 21, 2023
2 parents ccce13c + 3d6e04e commit 66b4ebc
Show file tree
Hide file tree
Showing 23 changed files with 258 additions and 199 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby

name: main build
run-name: ${{ github.actor }} 🚀 ${{github.ref_name}}
on: [push]

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version:
- '2.7'
- '3.0'
- '3.1'
- '3.2'
gemfile:
- 'Gemfile'
- 'gemfiles/sidekiq5_rails6.gemfile'
- 'gemfiles/sidekiq6_4_rails6.gemfile'
- 'gemfiles/sidekiq6_4_rails7.gemfile'
- 'gemfiles/sidekiq6_5_rails6.gemfile'
- 'gemfiles/sidekiq6_5_rails7.gemfile'
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }}
steps:
- uses: actions/checkout@v3
- name: Set up using Ruby ${{ matrix.ruby-version }} with Gemfile '${{ matrix.gemfile }}'
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
# uses: ruby/setup-ruby@v1
uses: ruby/setup-ruby@ee2113536afb7f793eed4ce60e8d3b26db912da4 # v1.127.0
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run tests
run: bundle exec rspec spec
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
Gemfile.lock
tmp
tmp
/gemfiles/*.lock
.tool-versions
.rspec
4 changes: 0 additions & 4 deletions .rspec

This file was deleted.

3 changes: 3 additions & 0 deletions .rspec.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--colour
--tty
--format documentation
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.1.3
5 changes: 0 additions & 5 deletions .simplecov

This file was deleted.

21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Unreleased - 4.0.0
---
* [BREAKING] Dropped support for matching jobs on ActiveJob's private API args, (e.g. `_aj_globalid` and `_aj_ruby2_keywords`). `_aj_globalid` can be replaced with the object itself, e.g. `have_enqueued_sidekiq_job(user)`.
* [BREAKING] Dropped support for Ruby 2.6
* [Possible breaking] Dropped support for Sidekiq 5
* [Possible breaking] Dropped support for Rails 5
* Clarified `have_enqueued_sidekiq_job` error message to make it clear that the "actual arguments" list is a list of argument-lists across all jobs.
* Switched to GitHub Actions for CI
* README updates to clarify new author and build links

3.1.0
---
* Add support for latest ruby and Rails 5 (coding-bunny #156)
Expand Down
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
source 'https://rubygems.org'

platforms :rbx do
gem 'rubysl', '~> 2.0'
gem 'psych'
gem 'rubinius-developer_tools'
end
Expand Down
57 changes: 31 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
**Welcome @packrat386 as new maintainer for `rspec-sidekiq`!**
**Welcome @wspurgin as new maintainer for `rspec-sidekiq`!**

# RSpec for Sidekiq

[![RubyGems][gem_version_badge]][ruby_gems]
[![Code Climate][code_climate_badge]][code_climate]
[![Travis CI][travis_ci_badge]][travis_ci]
[![Coveralls][coveralls_badge]][coveralls]
[![Gemnasium][gemnasium_badge]][gemnasium]

***Simple testing of Sidekiq jobs via a collection of matchers and helpers***

[RubyGems][ruby_gems] |
[Code Climate][code_climate] |
[GitHub][github] |
[Travis CI][travis_ci] |
[Coveralls][coveralls] |
[Gemnasium][gemnasium] |
[RubyDoc][ruby_doc] |
[Ruby Toolbox][ruby_toolbox]
[![Github Actions CI][github_actions_badge]][github_actions]

Simple testing of Sidekiq jobs via a collection of matchers and helpers.

[Jump to Matchers »](#matchers) | [Jump to Helpers »](#helpers)

Expand Down Expand Up @@ -108,7 +96,7 @@ sidekiq_options backtrace: 5
# test with...
expect(AwesomeJob).to save_backtrace # or
it { is_expected.to save_backtrace }
# ...or alternatively specifiy the number of lines that should be saved
# ...or alternatively specify the number of lines that should be saved
expect(AwesomeJob).to save_backtrace 5 # or
it { is_expected.to save_backtrace 5 }
# ...or when it should not save the backtrace
Expand Down Expand Up @@ -153,7 +141,9 @@ expect(AwesomeJob).to have_enqueued_job('Awesome', true)
```

#### Testing scheduled jobs

*Use chainable matchers `#at` and `#in`*

```ruby
time = 5.minutes.from_now
Awesomejob.perform_at time, 'Awesome', true
Expand All @@ -166,6 +156,21 @@ Awesomejob.perform_in 5.minutes, 'Awesome', true
expect(AwesomeJob).to have_enqueued_sidekiq_job('Awesome', true).in(5.minutes)
```

#### Testing ActiveMailer jobs

```ruby
user = User.first
AwesomeActionMailer.invite(user, true).deliver_later

expect(Sidekiq::Worker).to have_enqueued_sidekiq_job(
"AwesomeActionMailer",
"invite",
"deliver_now",
user,
true
)
```

## Example matcher usage
```ruby
require 'spec_helper'
Expand Down Expand Up @@ -203,9 +208,15 @@ FooClass.within_sidekiq_retries_exhausted_block {
```

## Testing
```bundle exec rspec spec```
```
bundle exec rspec spec
```

## Maintainers
* @wspurgin

### Alumni

* @packrat386
* @philostler

Expand All @@ -214,19 +225,13 @@ Please do! If there's a feature missing that you'd love to see then get in on th

Issues/Pull Requests/Comments all welcome...

[code_climate]: https://codeclimate.com/github/philostler/rspec-sidekiq
[code_climate_badge]: https://codeclimate.com/github/philostler/rspec-sidekiq.svg
[coveralls]: https://coveralls.io/r/philostler/rspec-sidekiq
[coveralls_badge]: https://img.shields.io/coveralls/philostler/rspec-sidekiq.svg?branch=develop
[gem_version_badge]: https://badge.fury.io/rb/rspec-sidekiq.svg
[gemnasium]: https://gemnasium.com/philostler/rspec-sidekiq
[gemnasium_badge]: https://gemnasium.com/philostler/rspec-sidekiq.svg
[github]: http://github.com/philostler/rspec-sidekiq
[ruby_doc]: http://rubydoc.info/gems/rspec-sidekiq/frames
[ruby_gems]: http://rubygems.org/gems/rspec-sidekiq
[ruby_toolbox]: http://www.ruby-toolbox.com/projects/rspec-sidekiq
[travis_ci]: http://travis-ci.org/philostler/rspec-sidekiq
[travis_ci_badge]: https://travis-ci.org/philostler/rspec-sidekiq.svg?branch=develop
[github_actions]: https://github.com/adsteel/rspec-sidekiq/actions
[github_actions_badge]: https://github.com/adsteel/rspec-sidekiq/actions/workflows/main.yml/badge.svg

[rspec_sidekiq_wiki_faq_&_troubleshooting]: https://github.com/philostler/rspec-sidekiq/wiki/FAQ-&-Troubleshooting
[sidekiq_wiki_batches]: https://github.com/mperham/sidekiq/wiki/Batches
Expand Down
12 changes: 0 additions & 12 deletions gemfiles/sidekiq52_rails42.gemfile

This file was deleted.

12 changes: 0 additions & 12 deletions gemfiles/sidekiq52_rails52.gemfile

This file was deleted.

10 changes: 10 additions & 0 deletions gemfiles/sidekiq5_rails6.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
source 'https://rubygems.org'

gem 'sidekiq', '~> 5.0'
gem 'activejob', '~> 6.0'
gem 'actionmailer', '~> 6.0'
gem 'activerecord', '~> 6.0'
gem "activemodel", "~> 6.0"
gem "railties", "~> 6.0"

gemspec :path => '../'
12 changes: 0 additions & 12 deletions gemfiles/sidekiq60_rails52.gemfile

This file was deleted.

10 changes: 10 additions & 0 deletions gemfiles/sidekiq6_4_rails6.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
source 'https://rubygems.org'

gem 'sidekiq', '~> 6.4.0'
gem 'activejob', '~> 6.0'
gem 'actionmailer', '~> 6.0'
gem 'activerecord', '~> 6.0'
gem "activemodel", "~> 6.0"
gem "railties", "~> 6.0"

gemspec :path => '../'
10 changes: 10 additions & 0 deletions gemfiles/sidekiq6_4_rails7.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
source 'https://rubygems.org'

gem 'sidekiq', '~> 6.4.0'
gem 'activejob', '~> 7.0'
gem 'actionmailer', '~> 7.0'
gem 'activerecord', '~> 7.0'
gem "activemodel", "~> 7.0"
gem "railties", "~> 7.0"

gemspec :path => '../'
10 changes: 10 additions & 0 deletions gemfiles/sidekiq6_5_rails6.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
source 'https://rubygems.org'

gem 'sidekiq', '~> 6.5'
gem 'activejob', '~> 6.0'
gem 'actionmailer', '~> 6.0'
gem 'activerecord', '~> 6.0'
gem "activemodel", "~> 6.0"
gem "railties", "~> 6.0"

gemspec :path => '../'
10 changes: 10 additions & 0 deletions gemfiles/sidekiq6_5_rails7.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
source 'https://rubygems.org'

gem 'sidekiq', '~> 6.5'
gem 'activejob', '~> 7.0'
gem 'actionmailer', '~> 7.0'
gem 'activerecord', '~> 7.0'
gem "activemodel", "~> 7.0"
gem "railties", "~> 7.0"

gemspec :path => '../'
7 changes: 6 additions & 1 deletion lib/rspec/sidekiq/matchers/be_delayed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ def until(time)

def find_job(method, arguments, &block)
job = (::Sidekiq::Extensions::DelayedClass.jobs + ::Sidekiq::Extensions::DelayedModel.jobs + ::Sidekiq::Extensions::DelayedMailer.jobs).find do |job|
yaml = YAML.load(job['args'].first)
arg = job['args'].first
yaml = begin
YAML.load(arg, aliases: true) # Psych 4 required syntax
rescue ArgumentError
YAML.load(arg) # Pysch < 4 syntax
end
@expected_method_receiver == yaml[0] && @expected_method.name == yaml[1] && (@expected_arguments <=> yaml[2]) == 0
end

Expand Down
Loading

0 comments on commit 66b4ebc

Please sign in to comment.