Sha256: 80ddefbb502c003ca9e290a881146864b17c37516e45594397a64226bab47513

Contents?: true

Size: 631 Bytes

Versions: 1

Compression:

Stored size: 631 Bytes

Contents

module AssemblyLine
  class GenericContext

    def let(name, &block)
      define_method name do
        let_values[name] ||= instance_eval(&block)
      end
      AssemblyLine.def_delegator :generic_context, name
    end

    # there are no tests so just run the block
    def before(scope=:each, &block)
      instance_eval &block
    end

    def clear
      instance_variables.each do |name|
        instance_variable_set(name, nil)
      end
    end

    protected

    def let_values
      @let_values ||= {}
    end

    def define_method(name, &block)
      self.class.send(:define_method, name, &block)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
assembly_line-0.2.1 lib/assembly_line/generic_context.rb