Project

rspec-que

0.01
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
RSpec matchers for Que: * expect { method }.to queue_up(MyJob).with(some_arguments)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

RSpec Que matchers

This gem defines a matcher for checking that Que jobs have been enqueued, in the style of rspec-activejob.

Installation

Add the dependency to your application's Gemfile:

gem 'rspec-que', '~> 1.1.0'

And then install from your Gemfile:

$ bundle

Usage

The matcher expects a block of code, and will expect that code to enqueue a job in Que. The matcher can take a class for the job as its arguments. It can also expect the job to be queued with arguments via .with(arg1, arg2) or at a specific time via .at(time).

If the matcher does not match, it will display informations about jobs queued at the last stage of the matcher which did match. (For instance, if you specify a job class, arguments, and a time, the matcher will display information about jobs of the right class and arguments but at the wrong time.)

# spec/spec_helper.rb
require 'rspec/que'

RSpec.configure do |config|
  config.include(RSpec::Que)

  # clean out the queue after each spec
  config.after(:each) do
    RSpec::Que.purge_jobs
  end
end

# spec/controllers/my_controller_spec.rb
RSpec.describe MyController do
  let(:user) { create(:user) }
  let(:params) { { user_id: user.id } }
  let(:later_time) { DateTime.parse("2038-01-01T01:02:03+00:00").utc }
  subject(:make_request) { described_class.make_request(params) }

  specify { expect { make_request }.to queue_up(RequestMaker).with(user) }
  specify { expect { make_request }.to queue_up(DelayedRequest).at(later_time) }
end

Development

Setup:

bundle install

Run tests:

bundle exec rake