Module: GollyUtils::Testing::DeferrableSpecs

Defined in:
lib/golly-utils/testing/rspec/deferrable_specs.rb

Overview

With this module you can create specs that don't start running until manually started elsewhere in another spec.

This is only really useful when writing integration tests in spec format, where specs (aka examples) are not isolated tests but single components of a larger-scale test. This is especially the case when checking asynchronous events, or managing dependencies on state of an external entity.

Usage

Examples:

describe 'Integration test #2' do
  extend GollyUtils::Testing::DeferrableSpecs

  it("Register client, notices and default prefs") do
    scenario.register_client
    scenario.register_notification_groups
    scenario.register_notices
    scenario.set_default_preferences

    start_deferred_test :email1
    start_deferred_test :email2
    start_deferred_test :mq
  end

  # Deferred until registration of client, notices and preferences are complete
  deferrable_spec(:email1, "Sends emails (to unregistered contacts)") do
    assert_sends_email ...
  end

  ...

end

Defined Under Namespace

Modules: ClassMethods, InstanceMethods