Sha256: 89cd7065ea258a0310270c65b3de95446698fa60149173b870340a5baf25f7b2

Contents?: true

Size: 1.8 KB

Versions: 34

Compression:

Stored size: 1.8 KB

Contents

class 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(regexp_or_string, &block)
      Isomorfeus.raise_error(message: "#{self}: First already defined, can only be defined once!") if @first_defined
      @first_defined = true
      steps << [_re_from_res(regexp_or_string), block]
    end

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

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

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

    def Failed(regexp_or_string, &block)
      failure_steps << [_re_from_res(regexp_or_string), block]
    end

    def _re_from_res(regexp_or_string)
      regexp_or_string.is_a?(String) ? Regexp.new(regexp_or_string) : regexp_or_string
    end

    alias :If_failing :Failed
    alias :When_failing :Failed
    alias :If_this_failed :Failed
    alias :If_that_failed :Failed
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
isomorfeus-operation-23.9.0.rc7 lib/lucid_operation/steps.rb
isomorfeus-operation-23.9.0.rc6 lib/lucid_operation/steps.rb
isomorfeus-operation-23.9.0.rc5 lib/lucid_operation/steps.rb
isomorfeus-operation-23.9.0.rc4 lib/lucid_operation/steps.rb
isomorfeus-operation-23.9.0.rc3 lib/lucid_operation/steps.rb
isomorfeus-operation-23.9.0.rc2 lib/lucid_operation/steps.rb
isomorfeus-operation-23.9.0.rc1 lib/lucid_operation/steps.rb
isomorfeus-operation-23.8.0.rc3 lib/lucid_operation/steps.rb
isomorfeus-operation-23.8.0.rc2 lib/lucid_operation/steps.rb
isomorfeus-operation-23.8.0.rc1 lib/lucid_operation/steps.rb
isomorfeus-operation-23.7.0.rc5 lib/lucid_operation/steps.rb
isomorfeus-operation-23.7.0.rc4 lib/lucid_operation/steps.rb
isomorfeus-operation-23.7.0.rc3 lib/lucid_operation/steps.rb
isomorfeus-operation-23.7.0.rc2 lib/lucid_operation/steps.rb
isomorfeus-operation-23.7.0.rc1 lib/lucid_operation/steps.rb
isomorfeus-operation-23.6.0.rc5 lib/lucid_operation/steps.rb
isomorfeus-operation-23.6.0.rc4 lib/lucid_operation/steps.rb
isomorfeus-operation-23.6.0.rc3 lib/lucid_operation/steps.rb
isomorfeus-operation-23.6.0.rc2 lib/lucid_operation/steps.rb
isomorfeus-operation-23.6.0.rc1 lib/lucid_operation/steps.rb