Sha256: 7690ec0de667e938af1ff8726b55b905b99f68da6bbcf8eb2a1b500601046e00

Contents?: true

Size: 713 Bytes

Versions: 1

Compression:

Stored size: 713 Bytes

Contents

module Lopata
  class SharedStep
    attr_reader :block

    class SharedStepNotFound < StandardError; end

    def self.register(name, &block)
      raise ArgumentError, "Comma is not allowed in shared step name: '%s'" % name if name =~ /,/
      @shared_steps ||= {}
      @shared_steps[name] = new(&block)
    end

    def self.find(name)
      @shared_steps[name] or raise StandardError, "Shared step '%s' not found" % name
    end

    def initialize(&block)
      @block = block
    end

    def steps
      @steps ||= build_steps
    end

    def build_steps
      builder = Lopata::ScenarioBuilder.new
      builder.instance_exec(&block)
      builder.steps
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lopata-0.1.0 lib/lopata/shared_step.rb