lib/lopata/shared_step.rb in lopata-0.1.1 vs lib/lopata/shared_step.rb in lopata-0.1.2

- old
+ new

@@ -1,19 +1,18 @@ module Lopata class SharedStep attr_reader :name, :block - class SharedStepNotFound < StandardError; end + class NotFound < 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(name, &block) + registry[name] = new(name, &block) end def self.find(name) - @shared_steps[name] or raise StandardError, "Shared step '%s' not found" % name + registry[name] or raise NotFound, "Shared step '%s' not found" % name end def initialize(name, &block) @name, @block = name, block end @@ -22,10 +21,17 @@ @steps ||= build_steps end def build_steps builder = Lopata::ScenarioBuilder.new(name) + builder.shared_step = self builder.instance_exec(&block) builder.steps + end + + private + + def self.registry + @shared_steps ||= {} end end end \ No newline at end of file