<commit_before>require "spec_helper"

describe BetterErrors do
  context ".editor" do
    it "defaults to textmate" do
      expect(subject.editor["foo.rb", 123]).to eq("txmt://open?url=file://foo.rb&line=123")
    end

    it "url escapes the filename" do
      expect(subject.editor["&.rb", 0]).to eq("txmt://open?url=file://%26.rb&line=0")
    end

    [:emacs, :emacsclient].each do |editor|
      it "uses emacs:// scheme when set to #{editor.inspect}" do
        subject.editor = editor
        expect(subject.editor[]).to start_with "emacs://"
      end
    end

    [:macvim, :mvim].each do |editor|
      it "uses mvim:// scheme when set to #{editor.inspect}" do
        subject.editor = editor
        expect(subject.editor[]).to start_with "mvim://"
      end
    end

    [:sublime, :subl, :st].each do |editor|
      it "uses subl:// scheme when set to #{editor.inspect}" do
        subject.editor = editor
        expect(subject.editor[]).to start_with "subl://"
      end
    end

    [:textmate, :txmt, :tm].each do |editor|
      it "uses txmt:// scheme when set to #{editor.inspect}" do
        subject.editor = editor
        expect(subject.editor[]).to start_with "txmt://"
      end
    end

    [:atom].each do |editor|
      it "uses atom:// scheme when set to #{editor.inspect}" do
        subject.editor = editor
        subject.editor[].should start_with "atom://"
      end
    end

    ["emacsclient", "/usr/local/bin/emacsclient"].each do |editor|
      it "uses emacs:// scheme when EDITOR=#{editor}" do
        ENV["EDITOR"] = editor
        subject.editor = subject.default_editor
        expect(subject.editor[]).to start_with "emacs://"
      end
    end

    ["mvim -f", "/usr/local/bin/mvim -f"].each do |editor|
      it "uses mvim:// scheme when EDITOR=#{editor}" do
        ENV["EDITOR"] = editor
        subject.editor = subject.default_editor
        expect(subject.editor[]).to start_with "mvim://"
      end
    end

    ["subl -w", "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"].each do |editor|
      it "uses subl:// scheme when EDITOR=#{editor}" do
        ENV["EDITOR"] = editor
        subject.editor = subject.default_editor
        expect(subject.editor[]).to start_with "subl://"
      end
    end

    ["mate -w", "/usr/bin/mate -w"].each do |editor|
      it "uses txmt:// scheme when EDITOR=#{editor}" do
        ENV["EDITOR"] = editor
        subject.editor = subject.default_editor
        expect(subject.editor[]).to start_with "txmt://"
      end
    end


    ["atom -w", "/usr/bin/atom -w"].each do |editor|
      it "uses atom:// scheme when EDITOR=#{editor}" do
        ENV["EDITOR"] = editor
        subject.editor = subject.default_editor
        subject.editor[].should start_with "atom://"
      end
    end

    ["mine"].each do |editor|
      it "uses x-mine:// scheme when EDITOR=#{editor}" do
        ENV["EDITOR"] = editor
        subject.editor = subject.default_editor
        expect(subject.editor[]).to start_with "x-mine://"<commit_msg>Fix old-style assertions<commit_after>require "spec_helper"

describe BetterErrors do
  context ".editor" do
    it "defaults to textmate" do
      expect(subject.editor["foo.rb", 123]).to eq("txmt://open?url=file://foo.rb&line=123")
    end

    it "url escapes the filename" do
      expect(subject.editor["&.rb", 0]).to eq("txmt://open?url=file://%26.rb&line=0")
    end

    [:emacs, :emacsclient].each do |editor|
      it "uses emacs:// scheme when set to #{editor.inspect}" do
        subject.editor = editor
        expect(subject.editor[]).to start_with "emacs://"
      end
    end

    [:macvim, :mvim].each do |editor|
      it "uses mvim:// scheme when set to #{editor.inspect}" do
        subject.editor = editor
        expect(subject.editor[]).to start_with "mvim://"
      end
    end

    [:sublime, :subl, :st].each do |editor|
      it "uses subl:// scheme when set to #{editor.inspect}" do
        subject.editor = editor
        expect(subject.editor[]).to start_with "subl://"
      end
    end

    [:textmate, :txmt, :tm].each do |editor|
      it "uses txmt:// scheme when set to #{editor.inspect}" do
        subject.editor = editor
        expect(subject.editor[]).to start_with "txmt://"
      end
    end

    [:atom].each do |editor|
      it "uses atom:// scheme when set to #{editor.inspect}" do
        subject.editor = editor
        expect(subject.editor[]).to start_with "atom://"
      end
    end

    ["emacsclient", "/usr/local/bin/emacsclient"].each do |editor|
      it "uses emacs:// scheme when EDITOR=#{editor}" do
        ENV["EDITOR"] = editor
        subject.editor = subject.default_editor
        expect(subject.editor[]).to start_with "emacs://"
      end
    end

    ["mvim -f", "/usr/local/bin/mvim -f"].each do |editor|
      it "uses mvim:// scheme when EDITOR=#{editor}" do
        ENV["EDITOR"] = editor
        subject.editor = subject.default_editor
        expect(subject.editor[]).to start_with "mvim://"
      end
    end

    ["subl -w", "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"].each do |editor|
      it "uses subl:// scheme when EDITOR=#{editor}" do
        ENV["EDITOR"] = editor
        subject.editor = subject.default_editor
        expect(subject.editor[]).to start_with "subl://"
      end
    end

    ["mate -w", "/usr/bin/mate -w"].each do |editor|
      it "uses txmt:// scheme when EDITOR=#{editor}" do
        ENV["EDITOR"] = editor
        subject.editor = subject.default_editor
        expect(subject.editor[]).to start_with "txmt://"
      end
    end


    ["atom -w", "/usr/bin/atom -w"].each do |editor|
      it "uses atom:// scheme when EDITOR=#{editor}" do
        ENV["EDITOR"] = editor
        subject.editor = subject.default_editor
        expect(subject.editor[]).to start_with "atom://"
      end
    end

    ["mine"].each do |editor|
      it "uses x-mine:// scheme when EDITOR=#{editor}" do
        ENV["EDITOR"] = editor
        subject.editor = subject.default_editor
        expect(subject.editor[]).to start_with "x-mine://"
{'fraction_non_alphanumeric': 0.15426318383440119, 'fraction_numerical': 0.0036142598981435846, 'mean_word_length': 2.3973214285714284, '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': '328793', 'n_tokens_mistral': 1962, 'n_tokens_neox': 1880, 'n_words': 509}