|
3 | 3 | describe BetterErrors do |
4 | 4 | context ".editor" do |
5 | 5 | it "defaults to textmate" do |
6 | | - expect(subject.editor["foo.rb", 123]).to eq("txmt://open?url=file://foo.rb&line=123") |
| 6 | + expect(subject.editor.url("foo.rb", 123)).to eq("txmt://open?url=file://foo.rb&line=123") |
7 | 7 | end |
8 | 8 |
|
9 | 9 | it "url escapes the filename" do |
10 | | - expect(subject.editor["&.rb", 0]).to eq("txmt://open?url=file://%26.rb&line=0") |
| 10 | + expect(subject.editor.url("&.rb", 0)).to eq("txmt://open?url=file://%26.rb&line=0") |
11 | 11 | end |
12 | 12 |
|
13 | 13 | [:emacs, :emacsclient].each do |editor| |
14 | 14 | it "uses emacs:// scheme when set to #{editor.inspect}" do |
15 | 15 | subject.editor = editor |
16 | | - expect(subject.editor[]).to start_with "emacs://" |
| 16 | + expect(subject.editor.url("file", 42)).to start_with "emacs://" |
17 | 17 | end |
18 | 18 | end |
19 | 19 |
|
20 | 20 | [:macvim, :mvim].each do |editor| |
21 | 21 | it "uses mvim:// scheme when set to #{editor.inspect}" do |
22 | 22 | subject.editor = editor |
23 | | - expect(subject.editor[]).to start_with "mvim://" |
| 23 | + expect(subject.editor.url("file", 42)).to start_with "mvim://" |
24 | 24 | end |
25 | 25 | end |
26 | 26 |
|
27 | 27 | [:sublime, :subl, :st].each do |editor| |
28 | 28 | it "uses subl:// scheme when set to #{editor.inspect}" do |
29 | 29 | subject.editor = editor |
30 | | - expect(subject.editor[]).to start_with "subl://" |
| 30 | + expect(subject.editor.url("file", 42)).to start_with "subl://" |
31 | 31 | end |
32 | 32 | end |
33 | 33 |
|
34 | 34 | [:textmate, :txmt, :tm].each do |editor| |
35 | 35 | it "uses txmt:// scheme when set to #{editor.inspect}" do |
36 | 36 | subject.editor = editor |
37 | | - expect(subject.editor[]).to start_with "txmt://" |
| 37 | + expect(subject.editor.url("file", 42)).to start_with "txmt://" |
38 | 38 | end |
39 | 39 | end |
40 | 40 |
|
41 | 41 | [:atom].each do |editor| |
42 | 42 | it "uses atom:// scheme when set to #{editor.inspect}" do |
43 | 43 | subject.editor = editor |
44 | | - expect(subject.editor[]).to start_with "atom://" |
| 44 | + expect(subject.editor.url("file", 42)).to start_with "atom://" |
45 | 45 | end |
46 | 46 | end |
47 | 47 |
|
48 | 48 | ["emacsclient", "/usr/local/bin/emacsclient"].each do |editor| |
49 | 49 | it "uses emacs:// scheme when EDITOR=#{editor}" do |
50 | 50 | ENV["EDITOR"] = editor |
51 | 51 | subject.editor = subject.default_editor |
52 | | - expect(subject.editor[]).to start_with "emacs://" |
| 52 | + expect(subject.editor.url("file", 42)).to start_with "emacs://" |
53 | 53 | end |
54 | 54 | end |
55 | 55 |
|
56 | 56 | ["mvim -f", "/usr/local/bin/mvim -f"].each do |editor| |
57 | 57 | it "uses mvim:// scheme when EDITOR=#{editor}" do |
58 | 58 | ENV["EDITOR"] = editor |
59 | 59 | subject.editor = subject.default_editor |
60 | | - expect(subject.editor[]).to start_with "mvim://" |
| 60 | + expect(subject.editor.url("file", 42)).to start_with "mvim://" |
61 | 61 | end |
62 | 62 | end |
63 | 63 |
|
64 | 64 | ["subl -w", "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"].each do |editor| |
65 | 65 | it "uses subl:// scheme when EDITOR=#{editor}" do |
66 | 66 | ENV["EDITOR"] = editor |
67 | 67 | subject.editor = subject.default_editor |
68 | | - expect(subject.editor[]).to start_with "subl://" |
| 68 | + expect(subject.editor.url("file", 42)).to start_with "subl://" |
69 | 69 | end |
70 | 70 | end |
71 | 71 |
|
72 | 72 | ["mate -w", "/usr/bin/mate -w"].each do |editor| |
73 | 73 | it "uses txmt:// scheme when EDITOR=#{editor}" do |
74 | 74 | ENV["EDITOR"] = editor |
75 | 75 | subject.editor = subject.default_editor |
76 | | - expect(subject.editor[]).to start_with "txmt://" |
| 76 | + expect(subject.editor.url("file", 42)).to start_with "txmt://" |
77 | 77 | end |
78 | 78 | end |
79 | 79 |
|
|
82 | 82 | it "uses atom:// scheme when EDITOR=#{editor}" do |
83 | 83 | ENV["EDITOR"] = editor |
84 | 84 | subject.editor = subject.default_editor |
85 | | - expect(subject.editor[]).to start_with "atom://" |
| 85 | + expect(subject.editor.url("file", 42)).to start_with "atom://" |
86 | 86 | end |
87 | 87 | end |
88 | 88 |
|
89 | 89 | ["mine"].each do |editor| |
90 | 90 | it "uses x-mine:// scheme when EDITOR=#{editor}" do |
91 | 91 | ENV["EDITOR"] = editor |
92 | 92 | subject.editor = subject.default_editor |
93 | | - expect(subject.editor[]).to start_with "x-mine://" |
| 93 | + expect(subject.editor.url("file", 42)).to start_with "x-mine://" |
94 | 94 | end |
95 | 95 | end |
96 | 96 |
|
97 | 97 | ["idea"].each do |editor| |
98 | 98 | it "uses idea:// scheme when EDITOR=#{editor}" do |
99 | 99 | ENV["EDITOR"] = editor |
100 | 100 | subject.editor = subject.default_editor |
101 | | - expect(subject.editor[]).to start_with "idea://" |
| 101 | + expect(subject.editor.url("file", 42)).to start_with "idea://" |
102 | 102 | end |
103 | 103 | end |
104 | 104 |
|
105 | 105 | ["vscode", "code"].each do |editor| |
106 | 106 | it "uses vscode:// scheme when EDITOR=#{editor}" do |
107 | 107 | ENV["EDITOR"] = editor |
108 | 108 | subject.editor = subject.default_editor |
109 | | - expect(subject.editor[]).to start_with "vscode://" |
| 109 | + expect(subject.editor.url("file", 42)).to start_with "vscode://" |
110 | 110 | end |
111 | 111 | end |
112 | 112 | end |
|
0 commit comments