summaryrefslogtreecommitdiff
path: root/spec/support/background_migrations_matchers.rb
blob: 423c0e4cefcb282f478bab86c229f7d26c94f87a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
RSpec::Matchers.define :be_scheduled_migration do |delay, *expected|
  match do |migration|
    BackgroundMigrationWorker.jobs.any? do |job|
      job['args'] == [migration, expected] &&
        job['at'].to_i == (delay.to_i + Time.now.to_i)
    end
  end

  failure_message do |migration|
    "Migration `#{migration}` with args `#{expected.inspect}` " \
      'not scheduled in expected time!'
  end
end