Proctor

Classes and functions to support feature testing.

Installation

Add this line to your application's Gemfile:

gem 'govdelivery-proctor'

And then execute:

$ bundle

Or install it yourself as:

$ gem install govdelivery-proctor

Usage

Include it: require 'govdelivery-proctor'

backoff_check

GovDelivery::Proctor.backoff_check will run a provided block, over and over with longer and longer waits between runs, until the provided block either returns a truthy value or exceeds a provided max time to wait. At the end of each unsuccessful run - a run that does not return a truthy value - a message will be written to the log based on the provided message string.

tomorrow = Time.new.day + 1.day
GovDelivery::Proctor.backoff_check(24.hours, "Waiting for tomorrow") do
  Time.new.day == tomorrow
end

accelerating_check

GovDelivery::Proctor.accelerating_check will run a provided block, over and over with shorter and shorter waits between runs, until the provided block either returns a truthy value or exceeds a provided max time to wait. At the end of each unsuccessful run - a run that does not return a truthy value - a message will be written to the log based on the provided message string.

steady_check

GovDelivery::Proctor.steady_check will run a provided block, over and over with the specified wait between every run, until the provided block either returns a truthy value or exceeds a provided max time to wait. At the end of each unsuccessful run - a run that does not return a truthy value - a message will be written to the log based on the provided message string.

log

Returns a logger object for logging/outputing. By default, this logger object will print to STDOUT and have a level of INFO. These can be set via the environment variables TEST_LOG_FILE and TEST_LOG_LEVEL respectively.

GovDelivery::Proctor.log.info('Nothing is real') unless 1 == 1

suppress

Runs a provided block and ignores if a specified exception is thrown.

GovDelivery::Proctor.suppress(ZeroDivisionError) do
  1/0
  puts 'Nothing wrong here'
end

Development

Get Dev Dependencies

$ bundle install

Build

$ gem build proctor.gemspec

Install locally

$ gem install govdelivery-proctor-1.2.0.gem

Test

$ rake test