Skip to content

Latest commit

 

History

History
92 lines (67 loc) · 2.5 KB

README.md

File metadata and controls

92 lines (67 loc) · 2.5 KB

Build Status Test Coverage Code Climate

fury-little_monster

RSPEC Matchers

Installation

in your spec_helper add the following line

require 'little_monster/rspec'

helpers

generate_job

it takes a job and a hash of parameters and returns a fully configured job instance

generate_job with data

generate_job :my_job, data: { a: :b }

generate_job with task mocked to fail

generate_job :my_job, data: { a: :b }, fails: { task: :my_task, error: MyError.new }

generate_job with multiples tasks mocked to fail

generate_job :my_job, data: { a: :b }, fails: [{ task: :my_task, error: MyError.new }, { task: :my_other_task, error: MyError.new }]

run_job

given a generated job, it returns a JobResult object to make expectation about the run

generate_task

it takes a task class or symbol and returns a fully configured task instance

generate_task with data

generate_task MyJob::MyTask, data: { a: :b }

matchers

have_run

given a JobResult object expects the job to run that list of tasks

expect(run_job(:my_job)).to have_run(:my_task, :my_other_task)

have_run_task

given a JobResult object expects the job to run the a given task with a certain data

expect(run_job(:my_job)).to have_run_task(:my_task).with_data(a: :b)

have_ended_with_status

given a JobResult object expects the job have a given status after the run

expect(run_job(:my_job)).to have_ended_with_status(:success)

have_data

given checks a job or JobResult instance data

expect(run_job(:my_job)).to have_ended_with_status(:success)
expect(generate_job(:my_job)).to have_ended_with_status(:success)

have_retries

given job instance, a class or a class symbol it expects the retries for that class

expect(:my_job).to have_retries(3)

have_callback_retries

given job instance, a class or a class symbol it expects the callback retries for that class

expect(my_job).to have_callback_retries(10)