<commit_before>require 'spec_runner'

class RhoSpecModule
    attr_accessor :before, :after, :tests
    
    def initialize(msg, spec_body)
        @before = {}
        @after = {}
        @tests = {}
        
        @env = Object.new
        
        @spec_message = msg
        @spec_body = spec_body
    end
    
    def run_spec
        puts "TEST: #{@spec_message}"

        @env.instance_eval(&@spec_body) if @spec_body
    end

    def run_test(test_body)
        @env.instance_eval(&test_body) if test_body
    end
end

class RhoSpec
    attr_reader :exc_count, :count, :errorMessages, :code
    @@spec_modules = []
    @@spec_index = 0
    
    def self.current
        @@spec_modules[@@spec_index]
    end
    
    def start
        @exc_count = 0
        @count = 0
        @errorMessages = ""
        $is_network_available = System.get_property('has_network')
        
        run_all_specs()
        
        @code = @exc_count > 0 ? 1 : 0
        
        puts "***Total:  " + @count.to_s
        puts "***Passed: " + (@count - @exc_count).to_s
        puts "***Failed: " + @exc_count.to_s
    end

    def self.describe(mod, msg=nil, options=nil, &block)
        @@spec_modules << RhoSpecModule.new(mod, block)
    end
    
    def run_test(spec_name,test_name, &block)
        begin
            @count += 1
            puts "  - #{test_name}"
            yield if block_given?
        rescue Exception => e
            @exc_count += 1
            ntrace_index = RhoSpec.current.tests.size > 0 ? 2 : 1
            @errorMessages += "<br/>FAIL: '#{spec_name}:#{test_name}' failed: Error: #{e}\n" + 
                "#{e.backtrace[ntrace_index]}" if e.backtrace && e.backtrace.length > 0
            puts "FAIL: '#{spec_name}:#{test_name}' failed: Error: #{e}\n" + 
                "#{e.backtrace[ntrace_index]}" if e.backtrace && e.backtrace.length > 0
            #e.backtrace.each do |item|
            #    puts item
            #end
        end
    end
            
    def run_spec(spec_name)
        begin
            @@spec_modules = []<commit_msg>fix rhospec issue<commit_after>require 'spec_runner'

class RhoSpecModule
    attr_accessor :before, :after, :tests
    
    def initialize(msg, spec_body)
        @before = {}
        @after = {}
        @tests = {}
        
        @env = Object.new
        
        @spec_message = msg
        @spec_body = spec_body
    end
    
    def run_spec
        puts "TEST: #{@spec_message}"

        @env.instance_eval(&@spec_body) if @spec_body
    end

    def run_test(test_body)
        @env.instance_eval(&test_body) if test_body
    end
end

class RhoSpec
    attr_reader :exc_count, :count, :errorMessages, :code
    @@spec_modules = []
    @@spec_index = 0
    
    def self.current
        @@spec_modules[@@spec_index]
    end
    
    def start
        @exc_count = 0
        @count = 0
        @errorMessages = ""
        $is_network_available = System.get_property('has_network')
        
        run_all_specs()
        
        @code = @exc_count > 0 ? 1 : 0
        
        puts "***Total:  " + @count.to_s
        puts "***Passed: " + (@count - @exc_count).to_s
        puts "***Failed: " + @exc_count.to_s
    end

    def self.describe(mod, msg=nil, options=nil, &block)
        @@spec_modules << RhoSpecModule.new(mod, block)
    end
    
    def run_test(spec_name,test_name, &block)
        begin
            @count += 1
            puts "  - #{test_name}"
            yield if block_given?
        rescue Exception => e
            @exc_count += 1
            ntrace_index = RhoSpec.current && RhoSpec.current.tests.size() > 0 ? 2 : 1
            @errorMessages += "<br/>FAIL: '#{spec_name}:#{test_name}' failed: Error: #{e}\n" + 
                "#{e.backtrace[ntrace_index]}" if e.backtrace && e.backtrace.length > 0
            puts "FAIL: '#{spec_name}:#{test_name}' failed: Error: #{e}\n" + 
                "#{e.backtrace[ntrace_index]}" if e.backtrace && e.backtrace.length > 0
            #e.backtrace.each do |item|
            #    puts item
            #end
        end
    end
            
    def run_spec(spec_name)
        begin
            @@spec_modules = []
{'fraction_non_alphanumeric': 0.1255702280912365, 'fraction_numerical': 0.00624249699879952, 'mean_word_length': 1.792225201072386, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, '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': '5875788', 'n_tokens_mistral': 1398, 'n_tokens_neox': 1358, 'n_words': 285}