tailor 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -3
- data/Gemfile.lock +39 -31
- data/History.md +220 -207
- data/README.md +58 -45
- data/features/step_definitions/indentation_steps.rb +1 -1
- data/lib/tailor/reporter.rb +19 -7
- data/lib/tailor/rulers/spaces_before_lbrace_ruler.rb +0 -1
- data/lib/tailor/rulers/spaces_before_rbrace_ruler.rb +0 -1
- data/lib/tailor/rulers/spaces_in_empty_braces_ruler.rb +0 -1
- data/lib/tailor/version.rb +1 -1
- data/spec/functional/conditional_parentheses_spec.rb +1 -1
- data/spec/functional/conditional_spacing_spec.rb +1 -1
- data/spec/functional/configuration_spec.rb +61 -52
- data/spec/functional/horizontal_spacing/braces_spec.rb +134 -134
- data/spec/functional/horizontal_spacing/brackets_spec.rb +34 -36
- data/spec/functional/horizontal_spacing/comma_spacing_spec.rb +25 -27
- data/spec/functional/horizontal_spacing/hard_tabs_spec.rb +42 -42
- data/spec/functional/horizontal_spacing/long_lines_spec.rb +15 -17
- data/spec/functional/horizontal_spacing/long_methods_spec.rb +4 -4
- data/spec/functional/horizontal_spacing/parens_spec.rb +45 -45
- data/spec/functional/horizontal_spacing/trailing_whitespace_spec.rb +7 -8
- data/spec/functional/horizontal_spacing_spec.rb +10 -11
- data/spec/functional/indentation_spacing/argument_alignment_spec.rb +33 -62
- data/spec/functional/indentation_spacing/bad_indentation_spec.rb +176 -179
- data/spec/functional/indentation_spacing_spec.rb +13 -14
- data/spec/functional/naming/camel_case_methods_spec.rb +4 -6
- data/spec/functional/naming/screaming_snake_case_classes_spec.rb +28 -31
- data/spec/functional/naming_spec.rb +3 -3
- data/spec/functional/rake_task_spec.rb +9 -28
- data/spec/functional/string_interpolation_spec.rb +1 -1
- data/spec/functional/string_quoting_spec.rb +1 -1
- data/spec/functional/vertical_spacing/class_length_spec.rb +4 -6
- data/spec/functional/vertical_spacing/method_length_spec.rb +15 -17
- data/spec/functional/vertical_spacing_spec.rb +3 -3
- data/spec/spec_helper.rb +2 -0
- data/spec/support/argument_alignment_cases.rb +32 -32
- data/spec/support/conditional_parentheses_cases.rb +26 -26
- data/spec/support/good_indentation_cases.rb +205 -205
- data/spec/support/horizontal_spacing_cases.rb +53 -54
- data/spec/support/line_indentation_cases.rb +20 -20
- data/spec/support/naming_cases.rb +12 -12
- data/spec/support/string_interpolation_cases.rb +17 -17
- data/spec/support/string_quoting_cases.rb +12 -12
- data/spec/support/vertical_spacing_cases.rb +8 -8
- data/spec/unit/tailor/cli/options_spec.rb +20 -14
- data/spec/unit/tailor/cli_spec.rb +29 -43
- data/spec/unit/tailor/composite_observable_spec.rb +1 -1
- data/spec/unit/tailor/configuration/file_set_spec.rb +10 -11
- data/spec/unit/tailor/configuration/style_spec.rb +41 -42
- data/spec/unit/tailor/configuration_spec.rb +14 -12
- data/spec/unit/tailor/formatter_spec.rb +3 -3
- data/spec/unit/tailor/formatters/yaml_spec.rb +12 -13
- data/spec/unit/tailor/lexed_line_spec.rb +67 -69
- data/spec/unit/tailor/lexer/token_spec.rb +7 -7
- data/spec/unit/tailor/lexer_spec.rb +24 -24
- data/spec/unit/tailor/problem_spec.rb +12 -12
- data/spec/unit/tailor/reporter_spec.rb +8 -9
- data/spec/unit/tailor/ruler_spec.rb +10 -10
- data/spec/unit/tailor/rulers/indentation_spaces_ruler/indentation_manager_spec.rb +90 -86
- data/spec/unit/tailor/rulers/indentation_spaces_ruler_spec.rb +13 -13
- data/spec/unit/tailor/rulers/spaces_after_comma_ruler_spec.rb +4 -4
- data/spec/unit/tailor/rulers/spaces_after_lbrace_ruler_spec.rb +19 -19
- data/spec/unit/tailor/rulers/spaces_before_lbrace_ruler_spec.rb +6 -6
- data/spec/unit/tailor/rulers/spaces_before_rbrace_ruler_spec.rb +6 -6
- data/spec/unit/tailor/rulers_spec.rb +1 -1
- data/spec/unit/tailor/version_spec.rb +1 -2
- data/spec/unit/tailor_spec.rb +2 -2
- data/tailor.gemspec +3 -3
- metadata +20 -6
@@ -3,7 +3,7 @@ require 'tailor/configuration'
|
|
3
3
|
require 'tailor/cli'
|
4
4
|
|
5
5
|
describe Tailor::Configuration do
|
6
|
-
before { Tailor::Logger.
|
6
|
+
before { allow(Tailor::Logger).to receive(:log) }
|
7
7
|
|
8
8
|
subject do
|
9
9
|
Tailor::Configuration.new('.')
|
@@ -13,14 +13,14 @@ describe Tailor::Configuration do
|
|
13
13
|
context 'param is nil' do
|
14
14
|
it 'returns the pre-exisiting @formatters' do
|
15
15
|
subject.instance_variable_set(:@formatters, [:blah])
|
16
|
-
subject.formatters.
|
16
|
+
expect(subject.formatters).to eq [:blah]
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
context 'param is some value' do
|
21
21
|
it 'sets @formatters to that value' do
|
22
22
|
subject.formatters 'blah'
|
23
|
-
subject.instance_variable_get(:@formatters).
|
23
|
+
expect(subject.instance_variable_get(:@formatters)).to eq ['blah']
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -35,7 +35,7 @@ describe Tailor::Configuration do
|
|
35
35
|
style.trailing_newlines 2
|
36
36
|
end
|
37
37
|
|
38
|
-
subject.instance_variable_get(:@file_sets).
|
38
|
+
expect(subject.instance_variable_get(:@file_sets)).to eq(
|
39
39
|
bobo: {
|
40
40
|
file_list: [],
|
41
41
|
style: {
|
@@ -65,13 +65,13 @@ describe Tailor::Configuration do
|
|
65
65
|
trailing_newlines: [2, { level: :error }]
|
66
66
|
}
|
67
67
|
}
|
68
|
-
|
68
|
+
)
|
69
69
|
end
|
70
70
|
|
71
71
|
context 'first param is nil' do
|
72
72
|
it 'uses :default as the label' do
|
73
73
|
subject.file_set
|
74
|
-
subject.instance_variable_get(:@file_sets).
|
74
|
+
expect(subject.instance_variable_get(:@file_sets)).to include(:default)
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
@@ -81,14 +81,14 @@ describe Tailor::Configuration do
|
|
81
81
|
it 'returns @config_file' do
|
82
82
|
subject.instance_variable_set(:@config_file, 'pants')
|
83
83
|
subject.config_file
|
84
|
-
subject.instance_variable_get(:@config_file).
|
84
|
+
expect(subject.instance_variable_get(:@config_file)).to eq 'pants'
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
88
|
context '@config_file is nil' do
|
89
89
|
context 'DEFAULT_PROJECT_CONFIG exists' do
|
90
90
|
before do
|
91
|
-
File.
|
91
|
+
expect(File).to receive(:exists?).with(/\.tailor/).and_return true
|
92
92
|
end
|
93
93
|
|
94
94
|
it "returns Dir.pwd + './tailor'" do
|
@@ -98,14 +98,14 @@ describe Tailor::Configuration do
|
|
98
98
|
|
99
99
|
context 'DEFAULT_PROJECT_CONFIG does not exist' do
|
100
100
|
before do
|
101
|
-
File.
|
102
|
-
File.
|
101
|
+
expect(File).to receive(:exists?).with(/\.tailor/).and_return false
|
102
|
+
expect(File).to receive(:exists?).with(/\.tailorrc/).and_return true
|
103
103
|
end
|
104
104
|
|
105
105
|
it 'returns DEFAULT_RC_FILE' do
|
106
106
|
subject.config_file
|
107
|
-
subject.instance_variable_get(:@config_file).
|
108
|
-
Tailor::Configuration::DEFAULT_RC_FILE
|
107
|
+
expect(subject.instance_variable_get(:@config_file)).
|
108
|
+
to eq Tailor::Configuration::DEFAULT_RC_FILE
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
@@ -115,11 +115,13 @@ describe Tailor::Configuration do
|
|
115
115
|
before do
|
116
116
|
subject.instance_variable_set(:@file_sets, {})
|
117
117
|
end
|
118
|
+
|
118
119
|
it 'yields if a block is provided' do
|
119
120
|
expect do |config|
|
120
121
|
subject.recursive_file_set('*.rb', &config)
|
121
122
|
end.to yield_control
|
122
123
|
end
|
124
|
+
|
123
125
|
it 'does not raise if a block is not provided' do
|
124
126
|
expect { subject.recursive_file_set('*.rb') }.not_to raise_error
|
125
127
|
end
|
@@ -22,7 +22,7 @@ describe Tailor::Formatter do
|
|
22
22
|
|
23
23
|
context 'problems are empty' do
|
24
24
|
it 'returns an empty Array' do
|
25
|
-
subject.problems_at_level({}, :error).
|
25
|
+
expect(subject.problems_at_level({}, :error)).to eq []
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -31,7 +31,7 @@ describe Tailor::Formatter do
|
|
31
31
|
msg = 'File contains invalid Ruby; '
|
32
32
|
msg << 'run `ruby -c [your_file.rb]` for more details.'
|
33
33
|
|
34
|
-
subject.problems_at_level(problems, :warn).
|
34
|
+
expect(subject.problems_at_level(problems, :warn)).to eq [
|
35
35
|
{
|
36
36
|
type: 'allow_invalid_ruby',
|
37
37
|
line: 0,
|
@@ -45,7 +45,7 @@ describe Tailor::Formatter do
|
|
45
45
|
|
46
46
|
context 'the level asked for does not exist in the problems' do
|
47
47
|
it 'returns an empty Array' do
|
48
|
-
subject.problems_at_level(problems, :error).
|
48
|
+
expect(subject.problems_at_level(problems, :error)).to eq []
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -2,7 +2,6 @@ require 'spec_helper'
|
|
2
2
|
require 'tailor/formatters/yaml'
|
3
3
|
require 'yaml'
|
4
4
|
|
5
|
-
|
6
5
|
describe Tailor::Formatters::Yaml do
|
7
6
|
describe '#summary_report' do
|
8
7
|
context 'no files have problems' do
|
@@ -16,7 +15,7 @@ describe Tailor::Formatters::Yaml do
|
|
16
15
|
it 'returns YAML with no body' do
|
17
16
|
result = subject.summary_report(problems)
|
18
17
|
hash = YAML.load(result)
|
19
|
-
hash.
|
18
|
+
expect(hash).to eq({})
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
@@ -34,10 +33,10 @@ describe Tailor::Formatters::Yaml do
|
|
34
33
|
it 'returns YAML that contains the problem file and its problem' do
|
35
34
|
result = subject.summary_report(problems)
|
36
35
|
hash = YAML.load(result)
|
37
|
-
hash.keys.size.
|
38
|
-
hash.keys.first.
|
39
|
-
hash.
|
40
|
-
hash['/path_to/file1.rb'].first[:type].
|
36
|
+
expect(hash.keys.size).to eq 1
|
37
|
+
expect(hash.keys.first).to eq '/path_to/file1.rb'
|
38
|
+
expect(hash).to_not include '/path_to/file2.rb'
|
39
|
+
expect(hash['/path_to/file1.rb'].first[:type]).to eq 'type1'
|
41
40
|
end
|
42
41
|
end
|
43
42
|
|
@@ -62,13 +61,13 @@ describe Tailor::Formatters::Yaml do
|
|
62
61
|
it 'returns YAML that contains the problem files and their problems' do
|
63
62
|
result = subject.summary_report(problems)
|
64
63
|
hash = YAML.load(result)
|
65
|
-
hash.keys.size.
|
66
|
-
hash.keys.first.
|
67
|
-
hash.keys.last.
|
68
|
-
hash.
|
69
|
-
hash['/path_to/file1.rb'].first[:type].
|
70
|
-
hash['/path_to/file3.rb'].first[:type].
|
71
|
-
hash['/path_to/file3.rb'].last[:type].
|
64
|
+
expect(hash.keys.size).to eq 2
|
65
|
+
expect(hash.keys.first).to eq '/path_to/file1.rb'
|
66
|
+
expect(hash.keys.last).to eq '/path_to/file3.rb'
|
67
|
+
expect(hash).to_not include '/path_to/file2.rb'
|
68
|
+
expect(hash['/path_to/file1.rb'].first[:type]).to eq 'type1'
|
69
|
+
expect(hash['/path_to/file3.rb'].first[:type]).to eq 'type2'
|
70
|
+
expect(hash['/path_to/file3.rb'].last[:type]).to eq 'type3'
|
72
71
|
end
|
73
72
|
end
|
74
73
|
end
|
@@ -3,7 +3,7 @@ require 'tailor/lexed_line'
|
|
3
3
|
|
4
4
|
describe Tailor::LexedLine do
|
5
5
|
before do
|
6
|
-
Tailor::Logger.
|
6
|
+
allow(Tailor::Logger).to receive(:log)
|
7
7
|
end
|
8
8
|
|
9
9
|
subject { Tailor::LexedLine.new(lexed_output, 1) }
|
@@ -29,7 +29,7 @@ describe Tailor::LexedLine do
|
|
29
29
|
it 'returns all lexed output from line 1 when self.lineno is 1' do
|
30
30
|
line = Tailor::LexedLine.new(lexed_output, 1)
|
31
31
|
|
32
|
-
line.
|
32
|
+
expect(line).to eq [
|
33
33
|
[[1, 0], :on_ident, 'require'],
|
34
34
|
[[1, 7], :on_sp, ' '],
|
35
35
|
[[1, 8], :on_tstring_beg, "'"],
|
@@ -44,24 +44,24 @@ describe Tailor::LexedLine do
|
|
44
44
|
context '0 length line, no \n ending' do
|
45
45
|
let(:lexed_output) { [[[1, 0], :on_sp, ' ']] }
|
46
46
|
|
47
|
-
it '
|
48
|
-
subject.only_spaces
|
47
|
+
it 'is true' do
|
48
|
+
expect(subject.only_spaces?).to eq true
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
context '0 length line, with \n ending' do
|
53
53
|
let(:lexed_output) { [[[1, 0], :on_nl, "\n"]] }
|
54
54
|
|
55
|
-
it '
|
56
|
-
subject.only_spaces
|
55
|
+
it 'is true' do
|
56
|
+
expect(subject.only_spaces?).to eq true
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
context 'comment line, starting at column 0' do
|
61
61
|
let(:lexed_output) { [[[1, 0], :on_comment, '# comment']] }
|
62
62
|
|
63
|
-
it '
|
64
|
-
subject.only_spaces
|
63
|
+
it 'is false' do
|
64
|
+
expect(subject.only_spaces?).to eq false
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -73,8 +73,8 @@ describe Tailor::LexedLine do
|
|
73
73
|
]
|
74
74
|
end
|
75
75
|
|
76
|
-
it '
|
77
|
-
subject.only_spaces
|
76
|
+
it 'is false' do
|
77
|
+
expect(subject.only_spaces?).to eq false
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
@@ -90,8 +90,8 @@ describe Tailor::LexedLine do
|
|
90
90
|
]
|
91
91
|
end
|
92
92
|
|
93
|
-
it '
|
94
|
-
subject.only_spaces
|
93
|
+
it 'is false' do
|
94
|
+
expect(subject.only_spaces?).to eq false
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
@@ -113,7 +113,7 @@ describe Tailor::LexedLine do
|
|
113
113
|
end
|
114
114
|
|
115
115
|
it 'returns true' do
|
116
|
-
subject.ends_with_op
|
116
|
+
expect(subject.ends_with_op?).to eq true
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
@@ -130,7 +130,7 @@ describe Tailor::LexedLine do
|
|
130
130
|
end
|
131
131
|
|
132
132
|
it 'returns false' do
|
133
|
-
subject.ends_with_op
|
133
|
+
expect(subject.ends_with_op?).to eq false
|
134
134
|
end
|
135
135
|
end
|
136
136
|
end
|
@@ -148,10 +148,10 @@ describe Tailor::LexedLine do
|
|
148
148
|
]
|
149
149
|
end
|
150
150
|
|
151
|
-
before { subject.
|
151
|
+
before { allow(subject).to receive(:ends_with_kw?).and_return true }
|
152
152
|
|
153
153
|
it 'returns false' do
|
154
|
-
subject.ends_with_modifier_kw
|
154
|
+
expect(subject.ends_with_modifier_kw?).to eq false
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
@@ -173,29 +173,25 @@ describe Tailor::LexedLine do
|
|
173
173
|
|
174
174
|
context 'the keyword is a modifier' do
|
175
175
|
before do
|
176
|
-
token.
|
177
|
-
Tailor::Lexer::Token.
|
178
|
-
subject.
|
176
|
+
allow(token).to receive(:modifier_keyword?).and_return true
|
177
|
+
allow(Tailor::Lexer::Token).to receive(:new).and_return token
|
178
|
+
allow(subject).to receive(:ends_with_kw?).and_return true
|
179
179
|
end
|
180
180
|
|
181
|
-
after { Tailor::Lexer::Token.unstub(:new) }
|
182
|
-
|
183
181
|
it 'returns true' do
|
184
|
-
subject.ends_with_modifier_kw
|
182
|
+
expect(subject.ends_with_modifier_kw?).to eq true
|
185
183
|
end
|
186
184
|
end
|
187
185
|
|
188
186
|
context 'the keyword is not a modifier' do
|
189
187
|
before do
|
190
|
-
token.
|
191
|
-
Tailor::Lexer::Token.
|
192
|
-
subject.
|
188
|
+
allow(token).to receive(:modifier_keyword?).and_return false
|
189
|
+
allow(Tailor::Lexer::Token).to receive(:new).and_return token
|
190
|
+
allow(subject).to receive(:ends_with_kw?).and_return true
|
193
191
|
end
|
194
192
|
|
195
|
-
|
196
|
-
|
197
|
-
it 'returns true' do
|
198
|
-
subject.ends_with_modifier_kw?.should be_false
|
193
|
+
it 'returns false' do
|
194
|
+
expect(subject.ends_with_modifier_kw?).to eq false
|
199
195
|
end
|
200
196
|
end
|
201
197
|
end
|
@@ -214,13 +210,13 @@ describe Tailor::LexedLine do
|
|
214
210
|
|
215
211
|
context 'line ends with the event' do
|
216
212
|
it 'returns true' do
|
217
|
-
subject.does_line_end_with(:on_sp).
|
213
|
+
expect(subject.does_line_end_with(:on_sp)).to eq true
|
218
214
|
end
|
219
215
|
end
|
220
216
|
|
221
217
|
context 'line does not even with event' do
|
222
218
|
it 'returns false' do
|
223
|
-
subject.does_line_end_with(:on_kw).
|
219
|
+
expect(subject.does_line_end_with(:on_kw)).to eq false
|
224
220
|
end
|
225
221
|
end
|
226
222
|
end
|
@@ -238,7 +234,7 @@ describe Tailor::LexedLine do
|
|
238
234
|
end
|
239
235
|
|
240
236
|
it 'returns the space' do
|
241
|
-
subject.last_non_line_feed_event.
|
237
|
+
expect(subject.last_non_line_feed_event).to eq [[1, 9], :on_sp, ' ']
|
242
238
|
end
|
243
239
|
end
|
244
240
|
|
@@ -253,7 +249,8 @@ describe Tailor::LexedLine do
|
|
253
249
|
end
|
254
250
|
|
255
251
|
it 'returns the event before it' do
|
256
|
-
subject.last_non_line_feed_event.
|
252
|
+
expect(subject.last_non_line_feed_event).
|
253
|
+
to eq [[1, 4], :on_ident, 'thing']
|
257
254
|
end
|
258
255
|
end
|
259
256
|
end
|
@@ -272,7 +269,7 @@ describe Tailor::LexedLine do
|
|
272
269
|
end
|
273
270
|
|
274
271
|
it 'returns true' do
|
275
|
-
subject.loop_with_do
|
272
|
+
expect(subject.loop_with_do?).to eq true
|
276
273
|
end
|
277
274
|
end
|
278
275
|
|
@@ -288,7 +285,7 @@ describe Tailor::LexedLine do
|
|
288
285
|
end
|
289
286
|
|
290
287
|
it 'returns false' do
|
291
|
-
subject.loop_with_do
|
288
|
+
expect(subject.loop_with_do?).to eq false
|
292
289
|
end
|
293
290
|
end
|
294
291
|
|
@@ -305,7 +302,7 @@ describe Tailor::LexedLine do
|
|
305
302
|
end
|
306
303
|
|
307
304
|
it 'returns true' do
|
308
|
-
subject.loop_with_do
|
305
|
+
expect(subject.loop_with_do?).to eq true
|
309
306
|
end
|
310
307
|
end
|
311
308
|
|
@@ -321,7 +318,7 @@ describe Tailor::LexedLine do
|
|
321
318
|
end
|
322
319
|
|
323
320
|
it 'returns false' do
|
324
|
-
subject.loop_with_do
|
321
|
+
expect(subject.loop_with_do?).to eq false
|
325
322
|
end
|
326
323
|
end
|
327
324
|
|
@@ -344,7 +341,7 @@ describe Tailor::LexedLine do
|
|
344
341
|
end
|
345
342
|
|
346
343
|
it 'returns true' do
|
347
|
-
subject.loop_with_do
|
344
|
+
expect(subject.loop_with_do?).to eq true
|
348
345
|
end
|
349
346
|
end
|
350
347
|
|
@@ -366,7 +363,7 @@ describe Tailor::LexedLine do
|
|
366
363
|
end
|
367
364
|
|
368
365
|
it 'returns false' do
|
369
|
-
subject.loop_with_do
|
366
|
+
expect(subject.loop_with_do?).to eq false
|
370
367
|
end
|
371
368
|
end
|
372
369
|
end
|
@@ -376,15 +373,15 @@ describe Tailor::LexedLine do
|
|
376
373
|
let(:lexed_output) { [[[1, 0], :on_sp, ' ']] }
|
377
374
|
|
378
375
|
it 'returns nil' do
|
379
|
-
subject.first_non_space_element.
|
376
|
+
expect(subject.first_non_space_element).to be_nil
|
380
377
|
end
|
381
378
|
end
|
382
379
|
|
383
|
-
context
|
380
|
+
context 'lexed line contains only \n' do
|
384
381
|
let(:lexed_output) { [[[1, 0], :on_ignored_nl, "\n"]] }
|
385
382
|
|
386
383
|
it 'returns nil' do
|
387
|
-
subject.first_non_space_element.
|
384
|
+
expect(subject.first_non_space_element).to be_nil
|
388
385
|
end
|
389
386
|
end
|
390
387
|
|
@@ -397,8 +394,8 @@ describe Tailor::LexedLine do
|
|
397
394
|
]
|
398
395
|
end
|
399
396
|
|
400
|
-
it 'returns
|
401
|
-
subject.first_non_space_element.
|
397
|
+
it 'returns the token array' do
|
398
|
+
expect(subject.first_non_space_element).to eq [[1, 2], :on_rbrace, '}']
|
402
399
|
end
|
403
400
|
end
|
404
401
|
end
|
@@ -408,13 +405,13 @@ describe Tailor::LexedLine do
|
|
408
405
|
|
409
406
|
context 'self contains an event at the given column' do
|
410
407
|
it 'returns that event' do
|
411
|
-
subject.event_at(0).
|
408
|
+
expect(subject.event_at(0)).to eq lexed_output.first
|
412
409
|
end
|
413
410
|
end
|
414
411
|
|
415
412
|
context 'self does not contain an event at the given column' do
|
416
413
|
it 'returns nil' do
|
417
|
-
subject.event_at(1234).
|
414
|
+
expect(subject.event_at(1234)).to be_nil
|
418
415
|
end
|
419
416
|
end
|
420
417
|
end
|
@@ -423,13 +420,13 @@ describe Tailor::LexedLine do
|
|
423
420
|
let(:lexed_output) { [[[1, 0], :on_sp, ' ']] }
|
424
421
|
|
425
422
|
context '#event_at returns nil' do
|
426
|
-
before { subject.
|
427
|
-
specify { subject.event_index(1234).
|
423
|
+
before { allow(subject).to receive(:event_at).and_return nil }
|
424
|
+
specify { expect(subject.event_index(1234)).to be_nil }
|
428
425
|
end
|
429
426
|
|
430
427
|
context '#event_at returns a valid column' do
|
431
428
|
it 'returns the event' do
|
432
|
-
subject.event_index(0).
|
429
|
+
expect(subject.event_index(0)).to be_zero
|
433
430
|
end
|
434
431
|
end
|
435
432
|
end
|
@@ -446,7 +443,7 @@ describe Tailor::LexedLine do
|
|
446
443
|
end
|
447
444
|
|
448
445
|
it "returns the String made up of self's tokens" do
|
449
|
-
subject.to_s.
|
446
|
+
expect(subject.to_s).to eq "def thing \n"
|
450
447
|
end
|
451
448
|
end
|
452
449
|
|
@@ -471,7 +468,7 @@ describe Tailor::LexedLine do
|
|
471
468
|
end
|
472
469
|
|
473
470
|
it 'replaces the comment with an :on_ignored_nl' do
|
474
|
-
subject.remove_trailing_comment(file_text).
|
471
|
+
expect(subject.remove_trailing_comment(file_text)).to eq [
|
475
472
|
[[1, 0], :on_kw, 'def'],
|
476
473
|
[[1, 3], :on_sp, ' '],
|
477
474
|
[[1, 4], :on_ident, 'thing'],
|
@@ -501,7 +498,7 @@ describe Tailor::LexedLine do
|
|
501
498
|
end
|
502
499
|
|
503
500
|
it 'replaces the comment with an :on_ignored_nl' do
|
504
|
-
subject.remove_trailing_comment(file_text).
|
501
|
+
expect(subject.remove_trailing_comment(file_text)).to eq [
|
505
502
|
[[1, 0], :on_kw, 'def'],
|
506
503
|
[[1, 3], :on_sp, ' '],
|
507
504
|
[[1, 4], :on_ident, 'thing'],
|
@@ -533,7 +530,7 @@ describe Tailor::LexedLine do
|
|
533
530
|
end
|
534
531
|
|
535
532
|
it 'replaces the comment with an :on_nl' do
|
536
|
-
subject.remove_trailing_comment(file_text).
|
533
|
+
expect(subject.remove_trailing_comment(file_text)).to eq [
|
537
534
|
[[1, 0], :on_kw, 'def'],
|
538
535
|
[[1, 3], :on_sp, ' '],
|
539
536
|
[[1, 4], :on_ident, 'thing'],
|
@@ -561,7 +558,7 @@ describe Tailor::LexedLine do
|
|
561
558
|
end
|
562
559
|
|
563
560
|
it 'replaces the comment with an :on_nl' do
|
564
|
-
subject.remove_trailing_comment(file_text).
|
561
|
+
expect(subject.remove_trailing_comment(file_text)).to eq [
|
565
562
|
[[1, 0], :on_kw, 'def'],
|
566
563
|
[[1, 3], :on_sp, ' '],
|
567
564
|
[[1, 4], :on_ident, 'thing'],
|
@@ -572,8 +569,8 @@ describe Tailor::LexedLine do
|
|
572
569
|
end
|
573
570
|
|
574
571
|
it 'returns a LexedLine' do
|
575
|
-
subject.remove_trailing_comment(file_text).
|
576
|
-
|
572
|
+
expect(subject.remove_trailing_comment(file_text)).
|
573
|
+
to be_a Tailor::LexedLine
|
577
574
|
end
|
578
575
|
end
|
579
576
|
end
|
@@ -586,7 +583,7 @@ describe Tailor::LexedLine do
|
|
586
583
|
end
|
587
584
|
|
588
585
|
it 'returns true' do
|
589
|
-
subject.end_of_multi_line_string
|
586
|
+
expect(subject.end_of_multi_line_string?).to eq true
|
590
587
|
end
|
591
588
|
end
|
592
589
|
|
@@ -595,8 +592,8 @@ describe Tailor::LexedLine do
|
|
595
592
|
[[[1, 11], :on_comma, ','], [[1, 12], :on_nl, "\n"]]
|
596
593
|
end
|
597
594
|
|
598
|
-
it 'returns
|
599
|
-
subject.end_of_multi_line_string
|
595
|
+
it 'returns false' do
|
596
|
+
expect(subject.end_of_multi_line_string?).to eq false
|
600
597
|
end
|
601
598
|
end
|
602
599
|
|
@@ -609,8 +606,8 @@ describe Tailor::LexedLine do
|
|
609
606
|
]
|
610
607
|
end
|
611
608
|
|
612
|
-
it 'returns
|
613
|
-
subject.end_of_multi_line_string
|
609
|
+
it 'returns false' do
|
610
|
+
expect(subject.end_of_multi_line_string?).to eq false
|
614
611
|
end
|
615
612
|
end
|
616
613
|
end
|
@@ -626,10 +623,11 @@ describe Tailor::LexedLine do
|
|
626
623
|
end
|
627
624
|
|
628
625
|
before do
|
629
|
-
subject.
|
626
|
+
allow(subject).to receive(:last_non_line_feed_event).
|
627
|
+
and_return last_event
|
630
628
|
end
|
631
629
|
|
632
|
-
specify { subject.is_line_only_a(:on_period).
|
630
|
+
specify { expect(subject.is_line_only_a(:on_period)).to eq false }
|
633
631
|
end
|
634
632
|
|
635
633
|
context 'last event is the last event passed in' do
|
@@ -641,7 +639,7 @@ describe Tailor::LexedLine do
|
|
641
639
|
[[1, 12], :on_nl, "\n"]]
|
642
640
|
end
|
643
641
|
|
644
|
-
specify { subject.is_line_only_a(:on_comma).
|
642
|
+
specify { expect(subject.is_line_only_a(:on_comma)).to eq true }
|
645
643
|
end
|
646
644
|
|
647
645
|
context 'there is non-spaces before the last event' do
|
@@ -653,7 +651,7 @@ describe Tailor::LexedLine do
|
|
653
651
|
[[1, 12], :on_nl, "\n"]]
|
654
652
|
end
|
655
653
|
|
656
|
-
specify { subject.is_line_only_a(:on_comma).
|
654
|
+
specify { expect(subject.is_line_only_a(:on_comma)).to eq false }
|
657
655
|
end
|
658
656
|
end
|
659
657
|
end
|
@@ -669,7 +667,7 @@ describe Tailor::LexedLine do
|
|
669
667
|
end
|
670
668
|
|
671
669
|
it 'returns false' do
|
672
|
-
subject.keyword_is_symbol
|
670
|
+
expect(subject.keyword_is_symbol?).to eq false
|
673
671
|
end
|
674
672
|
end
|
675
673
|
|
@@ -682,7 +680,7 @@ describe Tailor::LexedLine do
|
|
682
680
|
end
|
683
681
|
|
684
682
|
it 'returns false' do
|
685
|
-
subject.keyword_is_symbol
|
683
|
+
expect(subject.keyword_is_symbol?).to eq false
|
686
684
|
end
|
687
685
|
end
|
688
686
|
|
@@ -695,7 +693,7 @@ describe Tailor::LexedLine do
|
|
695
693
|
end
|
696
694
|
|
697
695
|
it 'returns false' do
|
698
|
-
subject.keyword_is_symbol
|
696
|
+
expect(subject.keyword_is_symbol?).to eq false
|
699
697
|
end
|
700
698
|
end
|
701
699
|
|
@@ -709,7 +707,7 @@ describe Tailor::LexedLine do
|
|
709
707
|
end
|
710
708
|
|
711
709
|
it 'returns true' do
|
712
|
-
subject.keyword_is_symbol
|
710
|
+
expect(subject.keyword_is_symbol?).to eq true
|
713
711
|
end
|
714
712
|
end
|
715
713
|
end
|