Sha256: 01f3b8fc74d7278d1268ce2e1093cb29b0c0d2448e247c467b5abf8ad618e992

Contents?: true

Size: 503 Bytes

Versions: 2

Compression:

Stored size: 503 Bytes

Contents

module Coulda
  class Scenario
    attr_reader :name

    Statement = Struct.new(:type, :name, :block)

    def initialize(name, &block)
      @name = name.to_s
      @block = block
      @statements = []
      @pending = !block_given?
    end

    %w[Given When Then].each do |statement|
      eval <<-HERE
        def #{statement}(name, &block)
          @statements << stmt = Statement.new(:#{statement}, name, block)
        end
      HERE
    end

    def pending?
      @pending
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
elight-coulda-0.2.0 lib/coulda/scenario.rb
coulda-0.2.0 lib/coulda/scenario.rb