Sha256: 9ba250065fd34c623f2aabbf10b11f4b3c254d0c5a99764a3b1bc51d6d98abe3

Contents?: true

Size: 1.59 KB

Versions: 13

Compression:

Stored size: 1.59 KB

Contents

# frozen_string_literal: true

module LucidOperation
  module Steps
    def procedure(gherkin_text)
      feature_line = gherkin_text.include?('Operation: ') ? '' : "Operation: #{self.name}\n"
      scenario_line = feature_line == '' || gherkin_text.include?('Procedure: ') ? '' : "  Procedure: #{self.name} executing\n"
      @procedure = feature_line + scenario_line + gherkin_text
    end

    def gherkin
      @gherkin ||= LucidOperation::Gherkin.parse(@procedure)
    end

    def ensure_steps
      @ensure_steps ||= []
    end

    def failure_steps
      @failure_steps ||= []
    end

    def steps
      @steps ||= []
    end

    def First(regular_expression, &block)
      Isomorfeus.raise_error(message: "#{self}: First already defined, can only be defined once!") if @first_defined
      @first_defined = true
      steps << [regular_expression, block]
    end

    def Given(regular_expression, &block)
      steps << [regular_expression, block]
    end
    alias :And :Given
    alias :Then :Given
    alias :When :Given

    def Finally(regular_expression, &block)
      Isomorfeus.raise_error(message: "#{self}: Finally already defined, can only be defined once!") if @finally_defined
      @finally_defined = true
      steps << [regular_expression, block]
    end

    def Ensure(regular_expression, &block)
      ensure_steps << [regular_expression, block]
    end

    def Failed(regular_expression, &block)
      failure_steps << [regular_expression, block]
    end
    alias :If_failing :Failed
    alias :When_failing :Failed
    alias :If_this_failed :Failed
    alias :If_that_failed :Failed
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
isomorfeus-operation-1.0.0.zeta25 lib/isomorfeus_operation/lucid_operation/steps.rb
isomorfeus-operation-1.0.0.zeta24 lib/isomorfeus_operation/lucid_operation/steps.rb
isomorfeus-operation-1.0.0.zeta23 lib/isomorfeus_operation/lucid_operation/steps.rb
isomorfeus-operation-1.0.0.zeta22 lib/isomorfeus_operation/lucid_operation/steps.rb
isomorfeus-operation-1.0.0.zeta21 lib/isomorfeus_operation/lucid_operation/steps.rb
isomorfeus-operation-1.0.0.zeta20 lib/isomorfeus_operation/lucid_operation/steps.rb
isomorfeus-operation-1.0.0.zeta19 lib/isomorfeus_operation/lucid_operation/steps.rb
isomorfeus-operation-1.0.0.zeta18 lib/isomorfeus_operation/lucid_operation/steps.rb
isomorfeus-operation-1.0.0.zeta17 lib/isomorfeus_operation/lucid_operation/steps.rb
isomorfeus-operation-1.0.0.zeta16 lib/isomorfeus_operation/lucid_operation/steps.rb
isomorfeus-operation-1.0.0.zeta15 lib/isomorfeus_operation/lucid_operation/steps.rb
isomorfeus-operation-1.0.0.zeta14 lib/isomorfeus_operation/lucid_operation/steps.rb
isomorfeus-operation-1.0.0.zeta13 lib/isomorfeus_operation/lucid_operation/steps.rb