GithubHelp home page GithubHelp logo

que-testing's Introduction

que-testing Build Status

Testing support for the Que queue. que-testing allows you to enqueue jobs without a database and without synchronous running.

Installation

Add this line to your application's Gemfile:

gem 'que-testing', :require => false

And then execute:

$ bundle

Or install it yourself as:

$ gem install que-testing

Usage

In your test, require 'que/testing' and enqueue jobs as normal. Jobs are stored under a MyJob.jobs array. Because they're static, the stored jobs should be cleared between test runs.

require "que/testing"

describe "Testing" do
  after { MyJob.jobs.clear }

  it "Stores a job" do
    MyJob.enqueue("foo")

    js = MyJob.jobs
    js.length.must_equal 1
    js.first["args"].must_equal ["foo"]
    js.first["job_class"].must_equal "MyJob"
  end
end

que-testing's People

Contributors

joehorsnell avatar statianzo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

joehorsnell

que-testing's Issues

May not work with Que 0.11.4?

After installing que-testing, I get:

/Users/llimllib/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/que-0.11.4/lib/que/job.rb:139:in `work': undefined method `cleanup!' for #<Que::Testing::Adapter:0x007fd825456de8> (NoMethodError)
        from /Users/llimllib/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/que-0.11.4/lib/que/worker.rb:80:in `block in work_loop'
        from /Users/llimllib/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/que-0.11.4/lib/que/worker.rb:75:in `loop'
        from /Users/llimllib/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/que-0.11.4/lib/que/worker.rb:75:in `work_loop'
        from /Users/llimllib/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/que-0.11.4/lib/que/worker.rb:19:in `block in initialize'

Enqueued job is immediately destroyed

Hello,

I have simple test to check if job was scheduled or not, but it fails because of queue is empty

 it "runs job immediately if it scheduled between 16:00 and 17:30" do
      [DateTime.now.change(hour: 16), DateTime.now.change(hour: 17, min: 30)].each_with_index do |moment, i|
        Timecop.freeze(moment) do
          described_class.new(channel).today
          expect(jobs.["i"]["run_at"]).to eq(moment)
        end
      end

The job is put in a queue like this: PublicationJob.enqueue channel_name, @channel.id and returns following: <PublicationJob:0x007fbb11bd7080 @attrs={:args=>[channel_name, 3]}, @destroyed=true>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.