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.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -3
  3. data/Gemfile.lock +39 -31
  4. data/History.md +220 -207
  5. data/README.md +58 -45
  6. data/features/step_definitions/indentation_steps.rb +1 -1
  7. data/lib/tailor/reporter.rb +19 -7
  8. data/lib/tailor/rulers/spaces_before_lbrace_ruler.rb +0 -1
  9. data/lib/tailor/rulers/spaces_before_rbrace_ruler.rb +0 -1
  10. data/lib/tailor/rulers/spaces_in_empty_braces_ruler.rb +0 -1
  11. data/lib/tailor/version.rb +1 -1
  12. data/spec/functional/conditional_parentheses_spec.rb +1 -1
  13. data/spec/functional/conditional_spacing_spec.rb +1 -1
  14. data/spec/functional/configuration_spec.rb +61 -52
  15. data/spec/functional/horizontal_spacing/braces_spec.rb +134 -134
  16. data/spec/functional/horizontal_spacing/brackets_spec.rb +34 -36
  17. data/spec/functional/horizontal_spacing/comma_spacing_spec.rb +25 -27
  18. data/spec/functional/horizontal_spacing/hard_tabs_spec.rb +42 -42
  19. data/spec/functional/horizontal_spacing/long_lines_spec.rb +15 -17
  20. data/spec/functional/horizontal_spacing/long_methods_spec.rb +4 -4
  21. data/spec/functional/horizontal_spacing/parens_spec.rb +45 -45
  22. data/spec/functional/horizontal_spacing/trailing_whitespace_spec.rb +7 -8
  23. data/spec/functional/horizontal_spacing_spec.rb +10 -11
  24. data/spec/functional/indentation_spacing/argument_alignment_spec.rb +33 -62
  25. data/spec/functional/indentation_spacing/bad_indentation_spec.rb +176 -179
  26. data/spec/functional/indentation_spacing_spec.rb +13 -14
  27. data/spec/functional/naming/camel_case_methods_spec.rb +4 -6
  28. data/spec/functional/naming/screaming_snake_case_classes_spec.rb +28 -31
  29. data/spec/functional/naming_spec.rb +3 -3
  30. data/spec/functional/rake_task_spec.rb +9 -28
  31. data/spec/functional/string_interpolation_spec.rb +1 -1
  32. data/spec/functional/string_quoting_spec.rb +1 -1
  33. data/spec/functional/vertical_spacing/class_length_spec.rb +4 -6
  34. data/spec/functional/vertical_spacing/method_length_spec.rb +15 -17
  35. data/spec/functional/vertical_spacing_spec.rb +3 -3
  36. data/spec/spec_helper.rb +2 -0
  37. data/spec/support/argument_alignment_cases.rb +32 -32
  38. data/spec/support/conditional_parentheses_cases.rb +26 -26
  39. data/spec/support/good_indentation_cases.rb +205 -205
  40. data/spec/support/horizontal_spacing_cases.rb +53 -54
  41. data/spec/support/line_indentation_cases.rb +20 -20
  42. data/spec/support/naming_cases.rb +12 -12
  43. data/spec/support/string_interpolation_cases.rb +17 -17
  44. data/spec/support/string_quoting_cases.rb +12 -12
  45. data/spec/support/vertical_spacing_cases.rb +8 -8
  46. data/spec/unit/tailor/cli/options_spec.rb +20 -14
  47. data/spec/unit/tailor/cli_spec.rb +29 -43
  48. data/spec/unit/tailor/composite_observable_spec.rb +1 -1
  49. data/spec/unit/tailor/configuration/file_set_spec.rb +10 -11
  50. data/spec/unit/tailor/configuration/style_spec.rb +41 -42
  51. data/spec/unit/tailor/configuration_spec.rb +14 -12
  52. data/spec/unit/tailor/formatter_spec.rb +3 -3
  53. data/spec/unit/tailor/formatters/yaml_spec.rb +12 -13
  54. data/spec/unit/tailor/lexed_line_spec.rb +67 -69
  55. data/spec/unit/tailor/lexer/token_spec.rb +7 -7
  56. data/spec/unit/tailor/lexer_spec.rb +24 -24
  57. data/spec/unit/tailor/problem_spec.rb +12 -12
  58. data/spec/unit/tailor/reporter_spec.rb +8 -9
  59. data/spec/unit/tailor/ruler_spec.rb +10 -10
  60. data/spec/unit/tailor/rulers/indentation_spaces_ruler/indentation_manager_spec.rb +90 -86
  61. data/spec/unit/tailor/rulers/indentation_spaces_ruler_spec.rb +13 -13
  62. data/spec/unit/tailor/rulers/spaces_after_comma_ruler_spec.rb +4 -4
  63. data/spec/unit/tailor/rulers/spaces_after_lbrace_ruler_spec.rb +19 -19
  64. data/spec/unit/tailor/rulers/spaces_before_lbrace_ruler_spec.rb +6 -6
  65. data/spec/unit/tailor/rulers/spaces_before_rbrace_ruler_spec.rb +6 -6
  66. data/spec/unit/tailor/rulers_spec.rb +1 -1
  67. data/spec/unit/tailor/version_spec.rb +1 -2
  68. data/spec/unit/tailor_spec.rb +2 -2
  69. data/tailor.gemspec +3 -3
  70. metadata +20 -6
@@ -4,58 +4,58 @@ require 'tailor/configuration/style'
4
4
 
5
5
  BRACES = {}
6
6
  BRACES['single_line_hash_0_spaces_before_lbrace'] =
7
- %Q{thing ={ :one => 'one' }}
7
+ %(thing ={ :one => 'one' })
8
8
 
9
9
  BRACES['single_line_hash_2_spaces_before_lbrace'] =
10
- %Q{thing = { :one => 'one' }}
10
+ %(thing = { :one => 'one' })
11
11
 
12
12
  BRACES['single_line_hash_2_spaces_before_rbrace'] =
13
- %Q{thing = { :one => 'one' }}
13
+ %(thing = { :one => 'one' })
14
14
 
15
15
  BRACES['single_line_hash_2_spaces_after_lbrace'] =
16
- %Q{thing = { :one => 'one' }}
16
+ %(thing = { :one => 'one' })
17
17
 
18
- BRACES['two_line_hash_2_spaces_before_lbrace'] = %Q{thing1 =
19
- thing2 = { :one => 'one' }}
18
+ BRACES['two_line_hash_2_spaces_before_lbrace'] = %(thing1 =
19
+ thing2 = { :one => 'one' })
20
20
 
21
- BRACES['two_line_hash_2_spaces_before_rbrace'] = %Q{thing1 =
22
- thing2 = { :one => 'one' }}
21
+ BRACES['two_line_hash_2_spaces_before_rbrace'] = %(thing1 =
22
+ thing2 = { :one => 'one' })
23
23
 
24
24
  BRACES['two_line_hash_2_spaces_before_lbrace_lonely_braces'] =
25
- %Q{thing1 =
25
+ %(thing1 =
26
26
  thing2 = {
27
27
  :one => 'one'
28
- }}
28
+ })
29
29
 
30
30
  BRACES['space_in_empty_hash_in_string_in_block'] =
31
- %Q{[1].map { |n| { :first => "\#{n}-\#{{ }}" } }}
31
+ %([1].map { |n| { :first => "\#{n}-\#{{ }}" } })
32
32
 
33
33
  BRACES['single_line_block_2_spaces_before_lbrace'] =
34
- %Q{1..10.times { |n| puts n }}
34
+ %(1..10.times { |n| puts n })
35
35
 
36
36
  BRACES['single_line_block_in_string_interp_2_spaces_before_lbrace'] =
37
- %Q{"I did this \#{1..10.times { |n| puts n }} times."}
37
+ %("I did this \#{1..10.times { |n| puts n }} times.")
38
38
 
39
39
  BRACES['single_line_block_0_spaces_before_lbrace'] =
40
- %Q{1..10.times{ |n| puts n }}
40
+ %(1..10.times{ |n| puts n })
41
41
 
42
42
  BRACES['two_line_braces_block_2_spaces_before_lbrace'] =
43
- %Q{1..10.times { |n|
44
- puts n}}
43
+ %(1..10.times { |n|
44
+ puts n})
45
45
 
46
46
  BRACES['two_line_braces_block_0_spaces_before_lbrace_trailing_comment'] =
47
- %Q{1..10.times{ |n| # comment
48
- puts n}}
47
+ %(1..10.times{ |n| # comment
48
+ puts n})
49
49
 
50
50
  BRACES['no_space_after_l_before_r_after_string_interp'] =
51
- %Q{logger.debug "from \#{current} to \#{new_ver}", {:format => :short}}
51
+ %(logger.debug "from \#{current} to \#{new_ver}", {:format => :short})
52
52
 
53
53
  BRACES['no_space_before_consecutive_rbraces'] =
54
- %Q{thing = { 'id' => "\#{source}", 'attributes' => { 'height' => "\#{height}"}}}
54
+ %(thing = { 'id' => "\#{source}", 'attributes' => { 'height' => "\#{height}"}})
55
55
 
56
- describe "Detection of spacing around braces" do
56
+ describe 'Detection of spacing around braces' do
57
57
  before do
58
- Tailor::Logger.stub(:log)
58
+ allow(Tailor::Logger).to receive(:log)
59
59
  FakeFS.activate!
60
60
  File.open(file_name, 'w') { |f| f.write contents }
61
61
  critic.check_file(file_name, style.to_hash)
@@ -65,7 +65,7 @@ describe "Detection of spacing around braces" do
65
65
  Tailor::Critic.new
66
66
  end
67
67
 
68
- let(:contents) { BRACES[file_name]}
68
+ let(:contents) { BRACES[file_name] }
69
69
 
70
70
  let(:style) do
71
71
  style = Tailor::Configuration::Style.new
@@ -75,165 +75,165 @@ describe "Detection of spacing around braces" do
75
75
  style
76
76
  end
77
77
 
78
- context "single-line Hash" do
79
- context "0 spaces before lbrace" do
78
+ context 'single-line Hash' do
79
+ context '0 spaces before lbrace' do
80
80
  let!(:file_name) { 'single_line_hash_0_spaces_before_lbrace' }
81
- specify { critic.problems[file_name].size.should be 1 }
82
- specify { critic.problems[file_name].first[:type].should == "spaces_before_lbrace" }
83
- specify { critic.problems[file_name].first[:line].should be 1 }
84
- specify { critic.problems[file_name].first[:column].should be 7 }
85
- specify { critic.problems[file_name].first[:level].should be :error }
81
+ specify { expect(critic.problems[file_name].size).to eq 1 }
82
+ specify { expect(critic.problems[file_name].first[:type]).to eq 'spaces_before_lbrace' }
83
+ specify { expect(critic.problems[file_name].first[:line]).to eq 1 }
84
+ specify { expect(critic.problems[file_name].first[:column]).to eq 7 }
85
+ specify { expect(critic.problems[file_name].first[:level]).to eq :error }
86
86
  end
87
87
 
88
- context "2 spaces before lbrace" do
88
+ context '2 spaces before lbrace' do
89
89
  let!(:file_name) { 'single_line_hash_2_spaces_before_lbrace' }
90
- specify { critic.problems[file_name].size.should be 1 }
91
- specify { critic.problems[file_name].first[:type].should == "spaces_before_lbrace" }
92
- specify { critic.problems[file_name].first[:line].should be 1 }
93
- specify { critic.problems[file_name].first[:column].should be 9 }
94
- specify { critic.problems[file_name].first[:level].should be :error }
90
+ specify { expect(critic.problems[file_name].size).to eq 1 }
91
+ specify { expect(critic.problems[file_name].first[:type]).to eq 'spaces_before_lbrace' }
92
+ specify { expect(critic.problems[file_name].first[:line]).to eq 1 }
93
+ specify { expect(critic.problems[file_name].first[:column]).to eq 9 }
94
+ specify { expect(critic.problems[file_name].first[:level]).to eq :error }
95
95
  end
96
96
 
97
- context "2 spaces after lbrace" do
97
+ context '2 spaces after lbrace' do
98
98
  let!(:file_name) { 'single_line_hash_2_spaces_after_lbrace' }
99
- specify { critic.problems[file_name].size.should be 1 }
100
- specify { critic.problems[file_name].first[:type].should == "spaces_after_lbrace" }
101
- specify { critic.problems[file_name].first[:line].should be 1 }
102
- specify { critic.problems[file_name].first[:column].should be 9 }
103
- specify { critic.problems[file_name].first[:level].should be :error }
99
+ specify { expect(critic.problems[file_name].size).to eq 1 }
100
+ specify { expect(critic.problems[file_name].first[:type]).to eq 'spaces_after_lbrace' }
101
+ specify { expect(critic.problems[file_name].first[:line]).to eq 1 }
102
+ specify { expect(critic.problems[file_name].first[:column]).to eq 9 }
103
+ specify { expect(critic.problems[file_name].first[:level]).to eq :error }
104
104
  end
105
105
 
106
- context "2 spaces before rbrace" do
106
+ context '2 spaces before rbrace' do
107
107
  let!(:file_name) { 'single_line_hash_2_spaces_before_rbrace' }
108
- specify { critic.problems[file_name].size.should be 1 }
109
- specify { critic.problems[file_name].first[:type].should == "spaces_before_rbrace" }
110
- specify { critic.problems[file_name].first[:line].should be 1 }
111
- specify { critic.problems[file_name].first[:column].should be 25 }
112
- specify { critic.problems[file_name].first[:level].should be :error }
108
+ specify { expect(critic.problems[file_name].size).to eq 1 }
109
+ specify { expect(critic.problems[file_name].first[:type]).to eq 'spaces_before_rbrace' }
110
+ specify { expect(critic.problems[file_name].first[:line]).to eq 1 }
111
+ specify { expect(critic.problems[file_name].first[:column]).to eq 25 }
112
+ specify { expect(critic.problems[file_name].first[:level]).to eq :error }
113
113
  end
114
114
  end
115
115
 
116
- context "two-line Hash" do
117
- context "2 spaces before lbrace" do
116
+ context 'two-line Hash' do
117
+ context '2 spaces before lbrace' do
118
118
  let!(:file_name) { 'two_line_hash_2_spaces_before_lbrace' }
119
- specify { critic.problems[file_name.to_s].size.should be 1 }
120
- specify { critic.problems[file_name.to_s].first[:type].should == "spaces_before_lbrace" }
121
- specify { critic.problems[file_name.to_s].first[:line].should be 2 }
122
- specify { critic.problems[file_name.to_s].first[:column].should be 12 }
123
- specify { critic.problems[file_name.to_s].first[:level].should be :error }
119
+ specify { expect(critic.problems[file_name].size).to eq 1 }
120
+ specify { expect(critic.problems[file_name].first[:type]).to eq 'spaces_before_lbrace' }
121
+ specify { expect(critic.problems[file_name].first[:line]).to eq 2 }
122
+ specify { expect(critic.problems[file_name].first[:column]).to eq 12 }
123
+ specify { expect(critic.problems[file_name].first[:level]).to eq :error }
124
124
  end
125
125
 
126
- context "2 spaces before rbrace" do
126
+ context '2 spaces before rbrace' do
127
127
  let!(:file_name) { 'two_line_hash_2_spaces_before_rbrace' }
128
- specify { critic.problems[file_name].size.should be 1 }
129
- specify { critic.problems[file_name].first[:type].should == "spaces_before_rbrace" }
130
- specify { critic.problems[file_name].first[:line].should be 2 }
131
- specify { critic.problems[file_name].first[:column].should be 28 }
132
- specify { critic.problems[file_name].first[:level].should be :error }
128
+ specify { expect(critic.problems[file_name].size).to eq 1 }
129
+ specify { expect(critic.problems[file_name].first[:type]).to eq 'spaces_before_rbrace' }
130
+ specify { expect(critic.problems[file_name].first[:line]).to eq 2 }
131
+ specify { expect(critic.problems[file_name].first[:column]).to eq 28 }
132
+ specify { expect(critic.problems[file_name].first[:level]).to eq :error }
133
133
  end
134
134
 
135
- context "2 spaces before lbrace, lonely braces" do
135
+ context '2 spaces before lbrace, lonely braces' do
136
136
  let!(:file_name) { 'two_line_hash_2_spaces_before_lbrace_lonely_braces' }
137
- specify { critic.problems[file_name].size.should be 1 }
138
- specify { critic.problems[file_name].first[:type].should == "spaces_before_lbrace" }
139
- specify { critic.problems[file_name].first[:line].should be 2 }
140
- specify { critic.problems[file_name].first[:column].should be 12 }
141
- specify { critic.problems[file_name].first[:level].should be :error }
137
+ specify { expect(critic.problems[file_name].size).to eq 1 }
138
+ specify { expect(critic.problems[file_name].first[:type]).to eq 'spaces_before_lbrace' }
139
+ specify { expect(critic.problems[file_name].first[:line]).to eq 2 }
140
+ specify { expect(critic.problems[file_name].first[:column]).to eq 12 }
141
+ specify { expect(critic.problems[file_name].first[:level]).to eq :error }
142
142
  end
143
143
  end
144
144
 
145
- context "single-line block" do
146
- context "space in empty Hash" do
145
+ context 'single-line block' do
146
+ context 'space in empty Hash' do
147
147
  let!(:file_name) { 'space_in_empty_hash_in_string_in_block' }
148
- specify { critic.problems[file_name].size.should be 1 }
149
- specify { critic.problems[file_name].first[:type].should == "spaces_in_empty_braces" }
150
- specify { critic.problems[file_name].first[:line].should be 1 }
151
- specify { critic.problems[file_name].first[:column].should be 36 }
152
- specify { critic.problems[file_name].first[:level].should be :error }
148
+ specify { expect(critic.problems[file_name].size).to eq 1 }
149
+ specify { expect(critic.problems[file_name].first[:type]).to eq 'spaces_in_empty_braces' }
150
+ specify { expect(critic.problems[file_name].first[:line]).to eq 1 }
151
+ specify { expect(critic.problems[file_name].first[:column]).to eq 36 }
152
+ specify { expect(critic.problems[file_name].first[:level]).to eq :error }
153
153
  end
154
154
 
155
- context "0 spaces before lbrace" do
155
+ context '0 spaces before lbrace' do
156
156
  let!(:file_name) { 'single_line_block_0_spaces_before_lbrace' }
157
- specify { critic.problems[file_name].size.should be 1 }
158
- specify { critic.problems[file_name].first[:type].should == "spaces_before_lbrace" }
159
- specify { critic.problems[file_name].first[:line].should be 1 }
160
- specify { critic.problems[file_name].first[:column].should be 11 }
161
- specify { critic.problems[file_name].first[:level].should be :error }
157
+ specify { expect(critic.problems[file_name].size).to eq 1 }
158
+ specify { expect(critic.problems[file_name].first[:type]).to eq 'spaces_before_lbrace' }
159
+ specify { expect(critic.problems[file_name].first[:line]).to eq 1 }
160
+ specify { expect(critic.problems[file_name].first[:column]).to eq 11 }
161
+ specify { expect(critic.problems[file_name].first[:level]).to eq :error }
162
162
  end
163
163
 
164
- context "2 spaces before lbrace" do
164
+ context '2 spaces before lbrace' do
165
165
  let!(:file_name) { 'single_line_block_2_spaces_before_lbrace' }
166
- specify { critic.problems[file_name.to_s].size.should be 1 }
167
- specify { critic.problems[file_name.to_s].first[:type].should == "spaces_before_lbrace" }
168
- specify { critic.problems[file_name.to_s].first[:line].should be 1 }
169
- specify { critic.problems[file_name.to_s].first[:column].should be 13 }
170
- specify { critic.problems[file_name.to_s].first[:level].should be :error }
166
+ specify { expect(critic.problems[file_name].size).to eq 1 }
167
+ specify { expect(critic.problems[file_name].first[:type]).to eq 'spaces_before_lbrace' }
168
+ specify { expect(critic.problems[file_name].first[:line]).to eq 1 }
169
+ specify { expect(critic.problems[file_name].first[:column]).to eq 13 }
170
+ specify { expect(critic.problems[file_name].first[:level]).to eq :error }
171
171
  end
172
172
 
173
- context "in String interpolation, 2 spaces before lbrace" do
173
+ context 'in String interpolation, 2 spaces before lbrace' do
174
174
  let!(:file_name) { 'single_line_block_in_string_interp_2_spaces_before_lbrace' }
175
- specify { critic.problems[file_name].size.should be 1 }
176
- specify { critic.problems[file_name].first[:type].should == "spaces_before_lbrace" }
177
- specify { critic.problems[file_name].first[:line].should be 1 }
178
- specify { critic.problems[file_name].first[:column].should be 27 }
179
- specify { critic.problems[file_name].first[:level].should be :error }
175
+ specify { expect(critic.problems[file_name].size).to eq 1 }
176
+ specify { expect(critic.problems[file_name].first[:type]).to eq 'spaces_before_lbrace' }
177
+ specify { expect(critic.problems[file_name].first[:line]).to eq 1 }
178
+ specify { expect(critic.problems[file_name].first[:column]).to eq 27 }
179
+ specify { expect(critic.problems[file_name].first[:level]).to eq :error }
180
180
  end
181
181
  end
182
182
 
183
- context "multi-line block" do
184
- context "2 spaces before lbrace" do
183
+ context 'multi-line block' do
184
+ context '2 spaces before lbrace' do
185
185
  let!(:file_name) { 'two_line_braces_block_2_spaces_before_lbrace' }
186
- specify { critic.problems[file_name].size.should be 2 }
187
- specify { critic.problems[file_name].first[:type].should == "spaces_before_lbrace" }
188
- specify { critic.problems[file_name].first[:line].should be 1 }
189
- specify { critic.problems[file_name].first[:column].should be 13 }
190
- specify { critic.problems[file_name].first[:level].should be :error }
191
- specify { critic.problems[file_name].last[:type].should == "spaces_before_rbrace" }
192
- specify { critic.problems[file_name].last[:line].should be 2 }
193
- specify { critic.problems[file_name].last[:column].should be 8 }
194
- specify { critic.problems[file_name].last[:level].should be :error }
186
+ specify { expect(critic.problems[file_name].size).to eq 2 }
187
+ specify { expect(critic.problems[file_name].first[:type]).to eq 'spaces_before_lbrace' }
188
+ specify { expect(critic.problems[file_name].first[:line]).to eq 1 }
189
+ specify { expect(critic.problems[file_name].first[:column]).to eq 13 }
190
+ specify { expect(critic.problems[file_name].first[:level]).to eq :error }
191
+ specify { expect(critic.problems[file_name].last[:type]).to eq 'spaces_before_rbrace' }
192
+ specify { expect(critic.problems[file_name].last[:line]).to eq 2 }
193
+ specify { expect(critic.problems[file_name].last[:column]).to eq 8 }
194
+ specify { expect(critic.problems[file_name].last[:level]).to eq :error }
195
195
  end
196
196
 
197
- context "0 spaces before lbrace, with trailing comment" do
197
+ context '0 spaces before lbrace, with trailing comment' do
198
198
  let!(:file_name) { 'two_line_braces_block_0_spaces_before_lbrace_trailing_comment' }
199
- specify { critic.problems[file_name].size.should be 2 }
200
- specify { critic.problems[file_name].first[:type].should == "spaces_before_lbrace" }
201
- specify { critic.problems[file_name].first[:line].should be 1 }
202
- specify { critic.problems[file_name].first[:column].should be 11 }
203
- specify { critic.problems[file_name].first[:level].should be :error }
204
- specify { critic.problems[file_name].last[:type].should == "spaces_before_rbrace" }
205
- specify { critic.problems[file_name].last[:line].should be 2 }
206
- specify { critic.problems[file_name].last[:column].should be 8 }
207
- specify { critic.problems[file_name].last[:level].should be :error }
199
+ specify { expect(critic.problems[file_name].size).to eq 2 }
200
+ specify { expect(critic.problems[file_name].first[:type]).to eq 'spaces_before_lbrace' }
201
+ specify { expect(critic.problems[file_name].first[:line]).to eq 1 }
202
+ specify { expect(critic.problems[file_name].first[:column]).to eq 11 }
203
+ specify { expect(critic.problems[file_name].first[:level]).to eq :error }
204
+ specify { expect(critic.problems[file_name].last[:type]).to eq 'spaces_before_rbrace' }
205
+ specify { expect(critic.problems[file_name].last[:line]).to eq 2 }
206
+ specify { expect(critic.problems[file_name].last[:column]).to eq 8 }
207
+ specify { expect(critic.problems[file_name].last[:level]).to eq :error }
208
208
  end
209
209
  end
210
210
 
211
- context "String interpolation" do
212
- context "0 spaces after lbrace or before rbrace" do
211
+ context 'String interpolation' do
212
+ context '0 spaces after lbrace or before rbrace' do
213
213
  let!(:file_name) { 'no_space_after_l_before_r_after_string_interp' }
214
- specify { critic.problems[file_name].size.should be 2 }
215
- specify { critic.problems[file_name].first[:type].should == "spaces_after_lbrace" }
216
- specify { critic.problems[file_name].first[:line].should be 1 }
217
- specify { critic.problems[file_name].first[:column].should be 47 }
218
- specify { critic.problems[file_name].first[:level].should be :error }
219
- specify { critic.problems[file_name].last[:type].should == "spaces_before_rbrace" }
220
- specify { critic.problems[file_name].last[:line].should be 1 }
221
- specify { critic.problems[file_name].last[:column].should be 64 }
222
- specify { critic.problems[file_name].last[:level].should be :error }
214
+ specify { expect(critic.problems[file_name].size).to eq 2 }
215
+ specify { expect(critic.problems[file_name].first[:type]).to eq 'spaces_after_lbrace' }
216
+ specify { expect(critic.problems[file_name].first[:line]).to eq 1 }
217
+ specify { expect(critic.problems[file_name].first[:column]).to eq 47 }
218
+ specify { expect(critic.problems[file_name].first[:level]).to eq :error }
219
+ specify { expect(critic.problems[file_name].last[:type]).to eq 'spaces_before_rbrace' }
220
+ specify { expect(critic.problems[file_name].last[:line]).to eq 1 }
221
+ specify { expect(critic.problems[file_name].last[:column]).to eq 64 }
222
+ specify { expect(critic.problems[file_name].last[:level]).to eq :error }
223
223
  end
224
224
 
225
- context "no space before consecutive rbraces" do
225
+ context 'no space before consecutive rbraces' do
226
226
  let(:file_name) { 'no_space_before_consecutive_rbraces' }
227
227
  let(:problems) { critic.problems[file_name].select { |p| p[:type] == 'spaces_before_rbrace' } }
228
- specify { problems.size.should be 2 }
229
- specify { problems.first[:type].should == "spaces_before_rbrace" }
230
- specify { problems.first[:line].should be 1 }
231
- specify { problems.first[:column].should be 72 }
232
- specify { problems.first[:level].should be :error }
233
- specify { problems.last[:type].should == "spaces_before_rbrace" }
234
- specify { problems.last[:line].should be 1 }
235
- specify { problems.last[:column].should be 73 }
236
- specify { problems.last[:level].should be :error }
228
+ specify { expect(problems.size).to eq 2 }
229
+ specify { expect(problems.first[:type]).to eq 'spaces_before_rbrace' }
230
+ specify { expect(problems.first[:line]).to eq 1 }
231
+ specify { expect(problems.first[:column]).to eq 72 }
232
+ specify { expect(problems.first[:level]).to eq :error }
233
+ specify { expect(problems.last[:type]).to eq 'spaces_before_rbrace' }
234
+ specify { expect(problems.last[:line]).to eq 1 }
235
+ specify { expect(problems.last[:column]).to eq 73 }
236
+ specify { expect(problems.last[:level]).to eq :error }
237
237
  end
238
238
  end
239
239
  end
@@ -2,22 +2,20 @@ require 'spec_helper'
2
2
  require 'tailor/critic'
3
3
  require 'tailor/configuration/style'
4
4
 
5
-
6
5
  BRACKETS = {}
7
- BRACKETS['space_in_empty_array'] = %Q{[ ]}
8
- BRACKETS['simple_array_space_after_lbracket'] = %Q{[ 1, 2, 3]}
9
- BRACKETS['simple_array_space_before_rbracket'] = %Q{[1, 2, 3 ]}
10
- BRACKETS['hash_key_ref_space_before_rbracket'] = %Q{thing[:one ]}
11
- BRACKETS['hash_key_ref_space_after_lbracket'] = %Q{thing[ :one]}
6
+ BRACKETS['space_in_empty_array'] = %([ ])
7
+ BRACKETS['simple_array_space_after_lbracket'] = %([ 1, 2, 3])
8
+ BRACKETS['simple_array_space_before_rbracket'] = %([1, 2, 3 ])
9
+ BRACKETS['hash_key_ref_space_before_rbracket'] = %(thing[:one ])
10
+ BRACKETS['hash_key_ref_space_after_lbracket'] = %(thing[ :one])
12
11
  BRACKETS['two_d_array_space_after_lbrackets'] =
13
- %Q{[ [1, 2, 3], [ 'a', 'b', 'c']]}
12
+ %([ [1, 2, 3], [ 'a', 'b', 'c']])
14
13
  BRACKETS['two_d_array_space_before_rbrackets'] =
15
- %Q{[[1, 2, 3 ], [ 'a', 'b', 'c'] ]}
16
-
14
+ %([[1, 2, 3 ], [ 'a', 'b', 'c'] ])
17
15
 
18
16
  describe 'Detection of spaces around brackets' do
19
17
  before do
20
- Tailor::Logger.stub(:log)
18
+ allow(Tailor::Logger).to receive(:log)
21
19
  FakeFS.activate!
22
20
  File.open(file_name, 'w') { |f| f.write contents }
23
21
  critic.check_file(file_name, style.to_hash)
@@ -27,7 +25,7 @@ describe 'Detection of spaces around brackets' do
27
25
  Tailor::Critic.new
28
26
  end
29
27
 
30
- let(:contents) { BRACKETS[file_name]}
28
+ let(:contents) { BRACKETS[file_name] }
31
29
 
32
30
  let(:style) do
33
31
  style = Tailor::Configuration::Style.new
@@ -40,49 +38,49 @@ describe 'Detection of spaces around brackets' do
40
38
  context 'Arrays' do
41
39
  context 'empty with space inside' do
42
40
  let(:file_name) { 'space_in_empty_array' }
43
- specify { critic.problems[file_name].size.should be 1 }
44
- specify { critic.problems[file_name].first[:type].should == 'spaces_after_lbracket' }
45
- specify { critic.problems[file_name].first[:line].should be 1 }
46
- specify { critic.problems[file_name].first[:column].should be 1 }
47
- specify { critic.problems[file_name].first[:level].should be :error }
41
+ specify { expect(critic.problems[file_name].size).to eq 1 }
42
+ specify { expect(critic.problems[file_name].first[:type]).to eq 'spaces_after_lbracket' }
43
+ specify { expect(critic.problems[file_name].first[:line]).to eq 1 }
44
+ specify { expect(critic.problems[file_name].first[:column]).to eq 1 }
45
+ specify { expect(critic.problems[file_name].first[:level]).to eq :error }
48
46
  end
49
47
 
50
48
  context 'space after lbracket' do
51
49
  let(:file_name) { 'simple_array_space_after_lbracket' }
52
- specify { critic.problems[file_name].size.should be 1 }
53
- specify { critic.problems[file_name].first[:type].should == 'spaces_after_lbracket' }
54
- specify { critic.problems[file_name].first[:line].should be 1 }
55
- specify { critic.problems[file_name].first[:column].should be 1 }
56
- specify { critic.problems[file_name].first[:level].should be :error }
50
+ specify { expect(critic.problems[file_name].size).to eq 1 }
51
+ specify { expect(critic.problems[file_name].first[:type]).to eq 'spaces_after_lbracket' }
52
+ specify { expect(critic.problems[file_name].first[:line]).to eq 1 }
53
+ specify { expect(critic.problems[file_name].first[:column]).to eq 1 }
54
+ specify { expect(critic.problems[file_name].first[:level]).to eq :error }
57
55
  end
58
56
 
59
57
  context 'space before rbracket' do
60
58
  let(:file_name) { 'simple_array_space_before_rbracket' }
61
- specify { critic.problems[file_name].size.should be 1 }
62
- specify { critic.problems[file_name].first[:type].should == 'spaces_before_rbracket' }
63
- specify { critic.problems[file_name].first[:line].should be 1 }
64
- specify { critic.problems[file_name].first[:column].should be 9 }
65
- specify { critic.problems[file_name].first[:level].should be :error }
59
+ specify { expect(critic.problems[file_name].size).to eq 1 }
60
+ specify { expect(critic.problems[file_name].first[:type]).to eq 'spaces_before_rbracket' }
61
+ specify { expect(critic.problems[file_name].first[:line]).to eq 1 }
62
+ specify { expect(critic.problems[file_name].first[:column]).to eq 9 }
63
+ specify { expect(critic.problems[file_name].first[:level]).to eq :error }
66
64
  end
67
65
  end
68
66
 
69
67
  context 'Hash key references' do
70
68
  context 'space before rbracket' do
71
69
  let(:file_name) { 'hash_key_ref_space_before_rbracket' }
72
- specify { critic.problems[file_name].size.should be 1 }
73
- specify { critic.problems[file_name].first[:type].should == 'spaces_before_rbracket' }
74
- specify { critic.problems[file_name].first[:line].should be 1 }
75
- specify { critic.problems[file_name].first[:column].should be 11 }
76
- specify { critic.problems[file_name].first[:level].should be :error }
70
+ specify { expect(critic.problems[file_name].size).to eq 1 }
71
+ specify { expect(critic.problems[file_name].first[:type]).to eq 'spaces_before_rbracket' }
72
+ specify { expect(critic.problems[file_name].first[:line]).to eq 1 }
73
+ specify { expect(critic.problems[file_name].first[:column]).to eq 11 }
74
+ specify { expect(critic.problems[file_name].first[:level]).to eq :error }
77
75
  end
78
76
 
79
77
  context 'space after lbracket' do
80
78
  let(:file_name) { 'hash_key_ref_space_after_lbracket' }
81
- specify { critic.problems[file_name].size.should be 1 }
82
- specify { critic.problems[file_name].first[:type].should == 'spaces_after_lbracket' }
83
- specify { critic.problems[file_name].first[:line].should be 1 }
84
- specify { critic.problems[file_name].first[:column].should be 6 }
85
- specify { critic.problems[file_name].first[:level].should be :error }
79
+ specify { expect(critic.problems[file_name].size).to eq 1 }
80
+ specify { expect(critic.problems[file_name].first[:type]).to eq 'spaces_after_lbracket' }
81
+ specify { expect(critic.problems[file_name].first[:line]).to eq 1 }
82
+ specify { expect(critic.problems[file_name].first[:column]).to eq 6 }
83
+ specify { expect(critic.problems[file_name].first[:level]).to eq :error }
86
84
  end
87
85
  end
88
86
  end