<commit_before>require 'spec_helper'
require 'nokogiri'

module RSpec
  module Core
    module Formatters
      describe TextMateFormatter do
        let(:jruby?) { ::RUBY_PLATFORM == 'java' }
        let(:root)   { File.expand_path("#{File.dirname(__FILE__)}/../../../..") }
        let(:suffix) { jruby? ? '-jruby' : '' }

        let(:expected_file) do
          "#{File.dirname(__FILE__)}/text_mate_formatted-#{::RUBY_VERSION}#{suffix}.html"
        end

        let(:generated_html) do
          options = RSpec::Core::ConfigurationOptions.new(
            %w[spec/rspec/core/resources/formatter_specs.rb --format textmate]
          )
          options.parse_options
          err, out = StringIO.new, StringIO.new
          command_line = RSpec::Core::CommandLine.new(options)
          command_line.run(err, out)
          out.string.gsub /\d+\.\d+ seconds/, 'x seconds'
        end

        let(:expected_html) do
          raise "There is no HTML file with expected content for this platform: #{expected_file}" unless File.file?(expected_file)
          File.read(expected_file)
        end

        before do
          RSpec.configuration.stub(:load_spec_files) do
            RSpec.configuration.files_to_run.map {|f| load File.expand_path(f) }
          end
        end

        # Uncomment this group temporarily in order to overwrite the expected
        # with actual.  Use with care!!!
        describe "file generator" do
          it "generates a new comparison file" do
            Dir.chdir(root) do
              File.open(expected_file, 'w') {|io| io.write(generated_html)}
            end
          end
        end

        it "should produce HTML identical to the one we designed manually" do
          Dir.chdir(root) do
            actual_doc = Nokogiri::HTML(generated_html)
            backtrace_lines = actual_doc.search("div.backtrace a")
            actual_doc.search("div.backtrace").remove

            expected_doc = Nokogiri::HTML(expected_html)
            expected_doc.search("div.backtrace").remove

            actual_doc.inner_html.should == expected_doc.inner_html

            backtrace_lines.each do |backtrace_line|
              backtrace_line['href'].should include("txmt://open?url=")
            end
          end
        end
      end
    end
  end
end<commit_msg>don't forget to comment out the gold master generator<commit_after>require 'spec_helper'
require 'nokogiri'

module RSpec
  module Core
    module Formatters
      describe TextMateFormatter do
        let(:jruby?) { ::RUBY_PLATFORM == 'java' }
        let(:root)   { File.expand_path("#{File.dirname(__FILE__)}/../../../..") }
        let(:suffix) { jruby? ? '-jruby' : '' }

        let(:expected_file) do
          "#{File.dirname(__FILE__)}/text_mate_formatted-#{::RUBY_VERSION}#{suffix}.html"
        end

        let(:generated_html) do
          options = RSpec::Core::ConfigurationOptions.new(
            %w[spec/rspec/core/resources/formatter_specs.rb --format textmate]
          )
          options.parse_options
          err, out = StringIO.new, StringIO.new
          command_line = RSpec::Core::CommandLine.new(options)
          command_line.run(err, out)
          out.string.gsub /\d+\.\d+ seconds/, 'x seconds'
        end

        let(:expected_html) do
          raise "There is no HTML file with expected content for this platform: #{expected_file}" unless File.file?(expected_file)
          File.read(expected_file)
        end

        before do
          RSpec.configuration.stub(:load_spec_files) do
            RSpec.configuration.files_to_run.map {|f| load File.expand_path(f) }
          end
        end

        # Uncomment this group temporarily in order to overwrite the expected
        # with actual.  Use with care!!!
        # describe "file generator" do
          # it "generates a new comparison file" do
            # Dir.chdir(root) do
              # File.open(expected_file, 'w') {|io| io.write(generated_html)}
            # end
          # end
        # end

        it "should produce HTML identical to the one we designed manually" do
          Dir.chdir(root) do
            actual_doc = Nokogiri::HTML(generated_html)
            backtrace_lines = actual_doc.search("div.backtrace a")
            actual_doc.search("div.backtrace").remove

            expected_doc = Nokogiri::HTML(expected_html)
            expected_doc.search("div.backtrace").remove

            actual_doc.inner_html.should == expected_doc.inner_html

            backtrace_lines.each do |backtrace_line|
              backtrace_line['href'].should include("txmt://open?url=")
            end
          end
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.10807347287483982, 'fraction_numerical': 0.0, 'mean_word_length': 2.1261682242990654, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4888402', 'n_tokens_mistral': 1366, 'n_tokens_neox': 1336, 'n_words': 303}