Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the delay method in Rails? What library is it coming from?

I see this code:

Event.delay.create!(
  event_type: event_type,
  description: 'Automatically populated',
  date: Time.now.utc,
  eventable_id: subscription.id,
  eventable_type: subscription.class.name,
  app_context: app_context)

And this is the associated test:

  it 'logs events' do
    expect(Event).to receive(:delay).and_call_original
    subject
  end

What is the and_call_original method? What is the delay method?

like image 687
Jwan622 Avatar asked Nov 01 '25 15:11

Jwan622


1 Answers

The :delay method is probably from Delayed Job, a queueing framework:

Delayed Job Github Site

'and_call_original' is a delegator in the rspec framework.

From rspec mocks

like image 83
jjk Avatar answered Nov 03 '25 06:11

jjk