Giter Site home page Giter Site logo

Comments (5)

philostler avatar philostler commented on July 30, 2024

I've not had need to use the delayed extensions kit in Sidekiq so haven't given this any thought up to now.

FYI from looking at some of the Sidekiq code there are comments that using the delayed methods are discouraged anyway due to serialization of the entire object to JSON.

However, if I read Sidekiq's source correctly, this should be testable with the current matchers (don't hold me to that).

Scanning over the extensions directory in Sidekiq's source, everything hangs round the Proxy class and it's method_missing method. The end game appears to be the job enqueued via the usual #client_push method but with some additional arguments added (most importantly the name of the method being called). I've not looked any further but there must be logic in Sidekiq that looks at arguments and calls the relevant method when the job is invoked.

So you should be able check a job in enqueued correctly and the expected arguments (You'll have to take a peek to see what those arguments are). As for the method being called, I'd test that the job is enqueued as expected (as above) and then test the method itself separately (else your testing that Sidekiq is actually performing it's job correctly which is already tested in Sidekiq itself).

from rspec-sidekiq.

dfguo avatar dfguo commented on July 30, 2024

It's discouraged to use active_record extension. Using class methods actually will not have any serialization problem as long as the arguments are plain.

I'm actually interested in testing if arguments are correctly passed in, using have_enqueued_job. Currently I can only test if the size of the DelayClass has changed using Sidekiq::Extensions::DelayedClass.jobs.

Using have_enqueud_job on Sidekiq::Extensions::DelayedClass gives me:

[["---\n- !ruby/class 'EmailListManager'\n- :add_user_to_list\n- - 1\n - free\n"]]

when I called EmailListManager.delay.add_user_to_lis(1, 'free')

I'll look into how this argument get parsed.

from rspec-sidekiq.

philostler avatar philostler commented on July 30, 2024

Did you get any further with this?

from rspec-sidekiq.

dfguo avatar dfguo commented on July 30, 2024

Hi Phil,

I realized that It's not very readable to test Sidekiq::Extensions::DelayedClass. So I wrote a simple dsl to generate sidekiq job class instead.

from rspec-sidekiq.

sosaucily avatar sosaucily commented on July 30, 2024

I've got some helper methods for testing the delay class methods. Will create a pull request.

from rspec-sidekiq.

Related Issues (20)

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.