RSpec

Library providing tools for writing and running RSpec tests.

Module: RSpec::SleepingKingStudios::Deferred::Dependencies

Parent Namespace
RSpec::SleepingKingStudios::Deferred
Extended Modules
SleepingKingStudios::Tools::Toolbox::Mixin
Defined In
lib/rspec/sleeping_king_studios/deferred/dependencies.rb

Table Of Contents

Overview

Mixin for declaring dependent methods for deferred example groups.

Each dependent method is expected to have a definition, either as a direct method definition (using the def keyword or define_method), or via a memoized helper (such as let).

When the deferred examples are included in an example group and that example group is run, a before(:context) hook will check for all of the declared dependencies of that example group. If any of the expected dependencies are not defined, the hook will raise an exception listing the missing methods, the deferred examples that expect that method, and the description provided.

Examples

module RocketExamples
  include RSpec::SleepingKingStudios::Deferred::Provider

  deferred_examples 'should launch the rocket' do
    include RSpec::SleepingKingStudios::Deferred::Dependencies

    depends_on :rocket,
      'an instance of Rocket where #launched? returns false'

    describe '#launch' do
      it 'should launch the rocket' do
        expect { rocket.launch }.to change(rocket, :launched?).to be true
      end
    end
  end
end

Back To Top

Defined Under Namespace

Classes
MissingDependenciesError
Modules
ClassMethods

Back To Top

Class Methods

.check_dependencies_for(example) => Object

Checks for missing dependent methods for the given example.

Parameters

Raises

Back To Top


Back to Documentation | Versions | 2.8 | Reference | RSpec | RSpec::SleepingKingStudios | RSpec::SleepingKingStudios::Deferred