class Clockwork::Test::RSpec::Matchers::HaveRun

Public Class Methods

new(job_name = nil, opts = {}) click to toggle source
# File lib/clockwork/test/rspec/matchers/have_run.rb, line 6
def initialize(job_name = nil, opts = {})
  @job_name = job_name
  @times_run = opts[:times] || 1
  @exactly = false
end

Public Instance Methods

description() click to toggle source
# File lib/clockwork/test/rspec/matchers/have_run.rb, line 41
def description
  "run \"#{@job_name}\" #{@times_run} #{@times_run == 1 ? 'time' : 'times'}"
end
exactly(times) click to toggle source
# File lib/clockwork/test/rspec/matchers/have_run.rb, line 24
def exactly(times)
  time(times)
end
failure_message() click to toggle source
# File lib/clockwork/test/rspec/matchers/have_run.rb, line 45
def failure_message
  "expected Clockwork::Test to have " + description
end
failure_message_when_negated() click to toggle source
# File lib/clockwork/test/rspec/matchers/have_run.rb, line 49
def failure_message_when_negated
  "expected Clockwork::Test to not have run \"#{@job_name}\"."
end
matches?(clock_test) click to toggle source
# File lib/clockwork/test/rspec/matchers/have_run.rb, line 12
def matches?(clock_test)
  if @exactly
    clock_test.manager.times_run(@job_name) == @times_run
  else
    clock_test.manager.ran_job?(@job_name)
  end
end
once() click to toggle source
# File lib/clockwork/test/rspec/matchers/have_run.rb, line 20
def once
  time(1)
end
time(times = nil) click to toggle source
# File lib/clockwork/test/rspec/matchers/have_run.rb, line 32
def time(times = nil)
  if times
    @times_run = times
    @exactly = true
  end

  self
end
times(times = nil) click to toggle source
# File lib/clockwork/test/rspec/matchers/have_run.rb, line 28
def times(times = nil)
  time(times)
end