/
better_errors_spec.rb
113 lines (97 loc) · 3.46 KB
/
better_errors_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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://"
end
end
["idea"].each do |editor|
it "uses idea:// scheme when EDITOR=#{editor}" do
ENV["EDITOR"] = editor
subject.editor = subject.default_editor
expect(subject.editor[]).to start_with "idea://"
end
end
["vscode", "code"].each do |editor|
it "uses vscode:// scheme when EDITOR=#{editor}" do
ENV["EDITOR"] = editor
subject.editor = subject.default_editor
expect(subject.editor[]).to start_with "vscode://"
end
end
end
end