Module: RSpec::Stepwise

Defined in:
lib/rspec/stepwise.rb,
lib/rspec/stepwise/version.rb

Overview

Provides DSL for defining a series of steps.

Examples:

RSpec.describe 'user registration and sign in' do
  stepwise do
    step 'register' do
      api.register(user)
      mailbox.confirm(user)
    end

    step 'sign in' do
      token = api.(user)
      expect(token).not_to be expired
    end
  end
end

Defined Under Namespace

Classes: Builder, Context

Constant Summary collapse

VERSION =
'0.1.0'

Instance Method Summary collapse

Instance Method Details

#stepwise(name = nil, *args, &block) ⇒ Object

Defines new series of steps. Supports the same arguments as ‘RSpec.describe`.

See Also:

  • RSpec.describe


24
25
26
27
28
29
30
31
32
33
# File 'lib/rspec/stepwise.rb', line 24

def stepwise(name = nil, *args, &block)
  if args.last.is_a?(Hash)
    args.last[:order] = :defined
  else
    args << { order: :defined }
  end
  describe(name, *args) do
    Builder.new(self).instance_eval(&block)
  end
end