require 'spec_helper'
require 'rspec/version'

describe "Resque RSpec custom matchers" do
  include Resqutils::Spec::ResqueHelpers

  context "have_job_queued" do
    class BackgroundJob
      @queue = :low

      def self.perform
      end
    end

    class Service
      def expensive
        Resque.enqueue(BackgroundJob)
      end
    end

    before do
      clear_queue(BackgroundJob)
    end

    it "asserts Resque job has been queued" do
      Service.new.expensive

      if RSpec::Version::STRING.start_with?("2")
        "low".should have_job_queued(class: BackgroundJob, args: [])
      else
        expect("low").to have_job_queued(class: BackgroundJob, args: [])
      end
    end
  end
end

Add Resque RSpec custom matchers specs
Add Resque RSpec custom matchers specs

  - Add spec for have_job_queued custom matcher
    - Assert a job has been queued
    - Require and use RSpec version constant to test multiple versions
      of RSpec against have_job_queued
