<commit_before>module Coulda
  class Scenario
    attr_reader :name

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

    def initialize(name, &block)
      @name = name.to_s
      @block = block
      @statements = []
      check_statements
      @pending = @statements.empty? || @statements.any? { |s| s.block.nil? }
      @last_stmt_type = nil
    end

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

    def pending?
      @pending
    end

    private

    def check_statements
      @validating_semantics = true
      if @block
        instance_eval &@block
        assert_statements
      end<commit_msg>Must've missed adding this on the big update that makes the example/sample.rb work properly<commit_after>module Coulda
  class Scenario
    attr_reader :name

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

    def initialize(name, &block)
      @name = name.to_s
      @block = block
      @statements = []
      check_statements
      @pending = @statements.empty? || @statements.any? { |s| s.block.nil? }
      @last_stmt_type = nil
    end

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

    def pending?
      @pending
    end

    private

    def check_statements
      @validating_semantics = true
      if @block
        instance_eval &@block
        assert_statements
      end
{'fraction_non_alphanumeric': 0.09373326191751473, 'fraction_numerical': 0.0, 'mean_word_length': 1.9556962025316456, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5249316', 'n_tokens_mistral': 565, 'n_tokens_neox': 535, 'n_words': 147}