tailor 1.0.1 → 1.1.0

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 (69) hide show
  1. data/.tailor +1 -0
  2. data/Gemfile.lock +1 -1
  3. data/History.rdoc +34 -0
  4. data/README.rdoc +17 -1
  5. data/features/valid_ruby.feature +1 -1
  6. data/lib/ext/string_ext.rb +0 -4
  7. data/lib/tailor/cli/options.rb +9 -2
  8. data/lib/tailor/configuration.rb +103 -150
  9. data/lib/tailor/configuration/file_set.rb +110 -0
  10. data/lib/tailor/formatters/text.rb +108 -79
  11. data/lib/tailor/rake_task.rb +148 -0
  12. data/lib/tailor/tailorrc.erb +1 -1
  13. data/lib/tailor/version.rb +1 -1
  14. data/spec/functional/configuration_spec.rb +244 -0
  15. data/spec/functional/horizontal_spacing/braces_spec.rb +238 -0
  16. data/spec/functional/horizontal_spacing/brackets_spec.rb +88 -0
  17. data/spec/functional/horizontal_spacing/comma_spacing_spec.rb +68 -0
  18. data/spec/functional/horizontal_spacing/hard_tabs_spec.rb +110 -0
  19. data/spec/functional/horizontal_spacing/long_lines_spec.rb +51 -0
  20. data/spec/functional/horizontal_spacing/parens_spec.rb +102 -0
  21. data/spec/functional/horizontal_spacing/trailing_whitespace_spec.rb +66 -0
  22. data/spec/functional/horizontal_spacing_spec.rb +59 -0
  23. data/spec/functional/indentation_spacing/bad_indentation_spec.rb +372 -0
  24. data/spec/functional/indentation_spacing_spec.rb +85 -0
  25. data/spec/functional/naming/camel_case_methods_spec.rb +56 -0
  26. data/spec/functional/naming/screaming_snake_case_classes_spec.rb +83 -0
  27. data/spec/functional/naming_spec.rb +35 -0
  28. data/spec/functional/vertical_spacing/class_length_spec.rb +67 -0
  29. data/spec/functional/vertical_spacing/method_length_spec.rb +61 -0
  30. data/spec/functional/vertical_spacing_spec.rb +35 -0
  31. data/spec/support/bad_indentation_cases.rb +265 -0
  32. data/{features/support/file_cases/indentation_cases.rb → spec/support/good_indentation_cases.rb} +6 -266
  33. data/spec/support/horizontal_spacing_cases.rb +136 -0
  34. data/spec/support/naming_cases.rb +26 -0
  35. data/{features/support/file_cases → spec/support}/vertical_spacing_cases.rb +0 -33
  36. data/spec/{tailor → unit/tailor}/cli_spec.rb +1 -1
  37. data/spec/{tailor → unit/tailor}/composite_observable_spec.rb +1 -1
  38. data/spec/unit/tailor/configuration/file_set_spec.rb +65 -0
  39. data/spec/{tailor → unit/tailor}/configuration/style_spec.rb +1 -1
  40. data/spec/{tailor → unit/tailor}/configuration_spec.rb +1 -59
  41. data/spec/{tailor → unit/tailor}/critic_spec.rb +1 -1
  42. data/spec/{tailor → unit/tailor}/formatter_spec.rb +1 -1
  43. data/spec/{tailor → unit/tailor}/lexed_line_spec.rb +1 -1
  44. data/spec/{tailor → unit/tailor}/lexer/token_spec.rb +1 -1
  45. data/spec/{tailor → unit/tailor}/lexer_spec.rb +1 -2
  46. data/spec/{tailor → unit/tailor}/options_spec.rb +1 -1
  47. data/spec/{tailor → unit/tailor}/problem_spec.rb +1 -1
  48. data/spec/{tailor → unit/tailor}/reporter_spec.rb +1 -1
  49. data/spec/{tailor → unit/tailor}/ruler_spec.rb +1 -1
  50. data/spec/{tailor → unit/tailor}/rulers/indentation_spaces_ruler/indentation_manager_spec.rb +1 -1
  51. data/spec/{tailor → unit/tailor}/rulers/indentation_spaces_ruler_spec.rb +1 -1
  52. data/spec/{tailor → unit/tailor}/rulers/spaces_after_comma_ruler_spec.rb +1 -1
  53. data/spec/{tailor → unit/tailor}/rulers/spaces_after_lbrace_ruler_spec.rb +1 -1
  54. data/spec/{tailor → unit/tailor}/rulers/spaces_before_lbrace_ruler_spec.rb +1 -1
  55. data/spec/{tailor → unit/tailor}/rulers/spaces_before_rbrace_ruler_spec.rb +1 -1
  56. data/spec/{tailor → unit/tailor}/rulers_spec.rb +1 -1
  57. data/spec/unit/tailor/version_spec.rb +6 -0
  58. data/spec/{tailor_spec.rb → unit/tailor_spec.rb} +1 -1
  59. data/tasks/spec.rake +8 -3
  60. metadata +121 -93
  61. data/features/horizontal_spacing.feature +0 -263
  62. data/features/indentation/bad_files_with_no_trailing_newline.feature +0 -91
  63. data/features/indentation/good_files_with_no_trailing_newline.feature +0 -219
  64. data/features/name_detection.feature +0 -72
  65. data/features/support/file_cases/horizontal_spacing_cases.rb +0 -266
  66. data/features/support/file_cases/naming_cases.rb +0 -51
  67. data/features/vertical_spacing.feature +0 -135
  68. data/m.rb +0 -15
  69. data/spec/tailor/version_spec.rb +0 -6
@@ -82,6 +82,6 @@
82
82
  Tailor.config do |config|
83
83
  config.formatters "<%= formatters.join(", ") %>"
84
84
  config.file_set '<%= file_list %>' do |style|<% style.each do |rule, value| %>
85
- style.<%= rule %> <%= value.first %>, <% value.last.each { |k, v| %><%= k %>: <%= v %><% } end %>
85
+ style.<%= rule %> <%= value.first %>, <% value.last.each { |k, v| %><%= k %>: :<%= v %><% } end %>
86
86
  end
87
87
  end
@@ -1,3 +1,3 @@
1
1
  class Tailor
2
- VERSION = '1.0.1'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -0,0 +1,244 @@
1
+ require_relative '../spec_helper'
2
+ require 'tailor/configuration'
3
+
4
+ describe "Config File" do
5
+ before do
6
+ Tailor::Logger.stub(:log)
7
+ FakeFS.deactivate!
8
+ end
9
+
10
+ after do
11
+ FakeFS.activate!
12
+ end
13
+
14
+ context "files aren't given at runtime" do
15
+ let(:config) do
16
+ config = Tailor::Configuration.new
17
+ config.load!
18
+
19
+ config
20
+ end
21
+
22
+ context ".tailor does not exist" do
23
+ before do
24
+ Tailor::Configuration.any_instance.stub(:config_file).and_return false
25
+ end
26
+
27
+ it "sets formatters to 'text'" do
28
+ config.formatters.should == %w(text)
29
+ end
30
+
31
+ it "sets file_sets[:default].style to the default style" do
32
+ config.file_sets[:default].style.should_not be_nil
33
+ config.file_sets[:default].style.should == Tailor::Configuration::Style.new.to_hash
34
+ end
35
+
36
+ it "sets file_sets[:default].file_list to the files in lib/**/*.rb" do
37
+ config.file_sets[:default].file_list.all? do |path|
38
+ path =~ /tailor\/lib/
39
+ end.should be_true
40
+ end
41
+ end
42
+
43
+ context ".tailor defines the default file set" do
44
+ context "and another file set" do
45
+ let(:config_file) do
46
+ <<-CONFIG
47
+ Tailor.config do |config|
48
+ config.file_set 'lib/**/*.rb'
49
+
50
+ config.file_set 'features/**/*.rb', :features do |style|
51
+ style.max_line_length 90, level: :warn
52
+ end
53
+ end
54
+ CONFIG
55
+ end
56
+
57
+ before do
58
+ File.should_receive(:read).and_return config_file
59
+ end
60
+
61
+ it "creates the default file set" do
62
+ config.file_sets[:default].style.should == Tailor::Configuration::Style.new.to_hash
63
+ config.file_sets[:default].file_list.all? do |path|
64
+ path =~ /tailor\/lib/
65
+ end.should be_true
66
+ end
67
+
68
+ it "creates the :features file set" do
69
+ style = Tailor::Configuration::Style.new
70
+ style.max_line_length(90, level: :warn)
71
+ config.file_sets[:features].style.should == style.to_hash
72
+ config.file_sets[:features].file_list.all? do |path|
73
+ path =~ /features/
74
+ end.should be_true
75
+ end
76
+ end
77
+ end
78
+
79
+ context ".tailor defines NO default file set" do
80
+ let(:config_file) do
81
+ <<-CONFIG
82
+ Tailor.config do |config|
83
+ config.file_set 'features/**/*.rb', :features do |style|
84
+ style.max_line_length 90, level: :warn
85
+ end
86
+ end
87
+ CONFIG
88
+ end
89
+
90
+ before do
91
+ File.should_receive(:read).and_return config_file
92
+ end
93
+
94
+ it "does not create a :default file set" do
95
+ config.file_sets.should_not include :default
96
+ end
97
+
98
+ it "creates the non-default file set" do
99
+ config.file_sets.should include :features
100
+ end
101
+ end
102
+
103
+ context '.tailor defines a single recursive file set' do
104
+ let(:config_file) do
105
+ <<-CONFIG
106
+ Tailor.config do |config|
107
+ config.recursive_file_set '*spec.rb' do |style|
108
+ style.max_line_length 90, level: :warn
109
+ end
110
+ end
111
+ CONFIG
112
+ end
113
+
114
+ before do
115
+ File.should_receive(:read).and_return config_file
116
+ end
117
+
118
+ it 'creates a :default file set' do
119
+ config.file_sets.keys.should == [:default]
120
+ end
121
+
122
+ it 'has files in the file list levels deep' do
123
+ config.file_sets[:default].file_list.all? do |file|
124
+ file =~ /spec\.rb$/
125
+ end.should be_true
126
+ end
127
+ end
128
+ end
129
+
130
+ context 'files are given at runtime' do
131
+ let(:config) do
132
+ config = Tailor::Configuration.new('lib/tailor.rb')
133
+ config.load!
134
+
135
+ config
136
+ end
137
+
138
+ context ".tailor does not exist" do
139
+ before do
140
+ Tailor::Configuration.any_instance.stub(:config_file).and_return false
141
+ end
142
+
143
+ it "sets formatters to 'text'" do
144
+ config.formatters.should == %w(text)
145
+ end
146
+
147
+ it "sets file_sets[:default].style to the default style" do
148
+ config.file_sets[:default].style.should_not be_nil
149
+ config.file_sets[:default].style.should == Tailor::Configuration::Style.new.to_hash
150
+ end
151
+
152
+ it "sets file_sets[:default].file_list to the runtime files" do
153
+ config.file_sets[:default].file_list.size.should be 1
154
+ config.file_sets[:default].file_list.first.match /lib\/tailor\.rb$/
155
+ end
156
+ end
157
+
158
+ context ".tailor defines the default file set" do
159
+ context "and another file set" do
160
+ let(:config_file) do
161
+ <<-CONFIG
162
+ Tailor.config do |config|
163
+ config.file_set 'lib/**/*.rb' do |style|
164
+ style.max_line_length 85
165
+ end
166
+
167
+ config.file_set 'features/**/*.rb', :features do |style|
168
+ style.max_line_length 90, level: :warn
169
+ end
170
+ end
171
+ CONFIG
172
+ end
173
+
174
+ before do
175
+ File.should_receive(:read).and_return config_file
176
+ end
177
+
178
+ it "creates the default file set using the runtime files" do
179
+ style = Tailor::Configuration::Style.new
180
+ style.max_line_length 85
181
+ config.file_sets[:default].style.should == style.to_hash
182
+ config.file_sets[:default].file_list.size.should be 1
183
+ config.file_sets[:default].file_list.first.match /lib\/tailor\.rb$/
184
+ end
185
+
186
+ it "does not create the :features file set" do
187
+ config.file_sets.should_not include :features
188
+ end
189
+ end
190
+ end
191
+
192
+ context ".tailor defines NO default file set" do
193
+ let(:config_file) do
194
+ <<-CONFIG
195
+ Tailor.config do |config|
196
+ config.file_set 'features/**/*.rb', :features do |style|
197
+ style.max_line_length 90, level: :warn
198
+ end
199
+ end
200
+ CONFIG
201
+ end
202
+
203
+ before do
204
+ File.should_receive(:read).and_return config_file
205
+ end
206
+
207
+ it "creates a :default file set with the runtime file and default style" do
208
+ config.file_sets[:default].style.should == Tailor::Configuration::Style.new.to_hash
209
+ config.file_sets[:default].file_list.size.should be 1
210
+ config.file_sets[:default].file_list.first.match /lib\/tailor\.rb$/
211
+ end
212
+
213
+ it "does not create the non-default file set" do
214
+ config.file_sets.should_not include :features
215
+ end
216
+ end
217
+
218
+ context '.tailor defines a single recursive file set' do
219
+ let(:config_file) do
220
+ <<-CONFIG
221
+ Tailor.config do |config|
222
+ config.recursive_file_set '*_spec.rb' do |style|
223
+ style.max_line_length 90, level: :warn
224
+ end
225
+ end
226
+ CONFIG
227
+ end
228
+
229
+ before do
230
+ File.should_receive(:read).and_return config_file
231
+ end
232
+
233
+ it 'creates a :default file set' do
234
+ config.file_sets.keys.should == [:default]
235
+ end
236
+
237
+ it "creates a :default file set with the runtime file and default style" do
238
+ config.file_sets[:default].style.should == Tailor::Configuration::Style.new.to_hash
239
+ config.file_sets[:default].file_list.size.should be 1
240
+ config.file_sets[:default].file_list.first.match /lib\/tailor\.rb$/
241
+ end
242
+ end
243
+ end
244
+ end
@@ -0,0 +1,238 @@
1
+ require_relative '../../spec_helper'
2
+ require 'tailor/critic'
3
+ require 'tailor/configuration/style'
4
+
5
+ BRACES = {}
6
+ BRACES[:single_line_hash_0_spaces_before_lbrace] =
7
+ %Q{thing ={ :one => 'one' }}
8
+
9
+ BRACES[:single_line_hash_2_spaces_before_lbrace] =
10
+ %Q{thing = { :one => 'one' }}
11
+
12
+ BRACES[:single_line_hash_2_spaces_before_rbrace] =
13
+ %Q{thing = { :one => 'one' }}
14
+
15
+ BRACES[:single_line_hash_2_spaces_after_lbrace] =
16
+ %Q{thing = { :one => 'one' }}
17
+
18
+ BRACES[:two_line_hash_2_spaces_before_lbrace] = %Q{thing1 =
19
+ thing2 = { :one => 'one' }}
20
+
21
+ BRACES[:two_line_hash_2_spaces_before_rbrace] = %Q{thing1 =
22
+ thing2 = { :one => 'one' }}
23
+
24
+ BRACES[:two_line_hash_2_spaces_before_lbrace_lonely_braces] =
25
+ %Q{thing1 =
26
+ thing2 = {
27
+ :one => 'one'
28
+ }}
29
+
30
+ BRACES[:space_in_empty_hash_in_string_in_block] =
31
+ %Q{[1].map { |n| { :first => "\#{n}-\#{{ }}" } }}
32
+
33
+ BRACES[:single_line_block_2_spaces_before_lbrace] =
34
+ %Q{1..10.times { |n| puts n }}
35
+
36
+ BRACES[:single_line_block_in_string_interp_2_spaces_before_lbrace] =
37
+ %Q{"I did this \#{1..10.times { |n| puts n }} times."}
38
+
39
+ BRACES[:single_line_block_0_spaces_before_lbrace] =
40
+ %Q{1..10.times{ |n| puts n }}
41
+
42
+ BRACES[:two_line_braces_block_2_spaces_before_lbrace] =
43
+ %Q{1..10.times { |n|
44
+ puts n}}
45
+
46
+ BRACES[:two_line_braces_block_0_spaces_before_lbrace_trailing_comment] =
47
+ %Q{1..10.times{ |n| # comment
48
+ puts n}}
49
+
50
+ BRACES[:no_space_after_l_before_r_after_string_interp] =
51
+ %Q{logger.debug "from \#{current} to \#{new_ver}", {:format => :short}}
52
+
53
+ BRACES[:no_space_before_consecutive_rbraces] =
54
+ %Q{thing = { 'id' => "\#{source}", 'attributes' => { 'height' => "\#{height}"}}}
55
+
56
+ describe "Detection of spacing around braces" do
57
+ before do
58
+ Tailor::Logger.stub(:log)
59
+ FakeFS.activate!
60
+ File.open(file_name.to_s, 'w') { |f| f.write contents }
61
+ critic.check_file(file_name.to_s, style.to_hash)
62
+ end
63
+
64
+ let(:critic) do
65
+ Tailor::Critic.new
66
+ end
67
+
68
+ let(:contents) { BRACES[file_name]}
69
+
70
+ let(:style) do
71
+ style = Tailor::Configuration::Style.new
72
+ style.trailing_newlines 0, level: :off
73
+ style.allow_invalid_ruby true, level: :off
74
+
75
+ style
76
+ end
77
+
78
+ context "single-line Hash" do
79
+ context "0 spaces before lbrace" do
80
+ let(:file_name) { :single_line_hash_0_spaces_before_lbrace }
81
+ specify { critic.problems[file_name.to_s].size.should be 1 }
82
+ specify { critic.problems[file_name.to_s].first[:type].should == "spaces_before_lbrace" }
83
+ specify { critic.problems[file_name.to_s].first[:line].should be 1 }
84
+ specify { critic.problems[file_name.to_s].first[:column].should be 7 }
85
+ specify { critic.problems[file_name.to_s].first[:level].should be :error }
86
+ end
87
+
88
+ context "2 spaces before lbrace" do
89
+ let(:file_name) { :single_line_hash_2_spaces_before_lbrace }
90
+ specify { critic.problems[file_name.to_s].size.should be 1 }
91
+ specify { critic.problems[file_name.to_s].first[:type].should == "spaces_before_lbrace" }
92
+ specify { critic.problems[file_name.to_s].first[:line].should be 1 }
93
+ specify { critic.problems[file_name.to_s].first[:column].should be 9 }
94
+ specify { critic.problems[file_name.to_s].first[:level].should be :error }
95
+ end
96
+
97
+ context "2 spaces after lbrace" do
98
+ let(:file_name) { :single_line_hash_2_spaces_after_lbrace }
99
+ specify { critic.problems[file_name.to_s].size.should be 1 }
100
+ specify { critic.problems[file_name.to_s].first[:type].should == "spaces_after_lbrace" }
101
+ specify { critic.problems[file_name.to_s].first[:line].should be 1 }
102
+ specify { critic.problems[file_name.to_s].first[:column].should be 9 }
103
+ specify { critic.problems[file_name.to_s].first[:level].should be :error }
104
+ end
105
+
106
+ context "2 spaces before rbrace" do
107
+ let(:file_name) { :single_line_hash_2_spaces_before_rbrace }
108
+ specify { critic.problems[file_name.to_s].size.should be 1 }
109
+ specify { critic.problems[file_name.to_s].first[:type].should == "spaces_before_rbrace" }
110
+ specify { critic.problems[file_name.to_s].first[:line].should be 1 }
111
+ specify { critic.problems[file_name.to_s].first[:column].should be 25 }
112
+ specify { critic.problems[file_name.to_s].first[:level].should be :error }
113
+ end
114
+ end
115
+
116
+ context "two-line Hash" do
117
+ context "2 spaces before lbrace" do
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 }
124
+ end
125
+
126
+ context "2 spaces before rbrace" do
127
+ let(:file_name) { :two_line_hash_2_spaces_before_rbrace }
128
+ specify { critic.problems[file_name.to_s].size.should be 1 }
129
+ specify { critic.problems[file_name.to_s].first[:type].should == "spaces_before_rbrace" }
130
+ specify { critic.problems[file_name.to_s].first[:line].should be 2 }
131
+ specify { critic.problems[file_name.to_s].first[:column].should be 28 }
132
+ specify { critic.problems[file_name.to_s].first[:level].should be :error }
133
+ end
134
+
135
+ context "2 spaces before lbrace, lonely braces" do
136
+ let(:file_name) { :two_line_hash_2_spaces_before_lbrace_lonely_braces }
137
+ specify { critic.problems[file_name.to_s].size.should be 1 }
138
+ specify { critic.problems[file_name.to_s].first[:type].should == "spaces_before_lbrace" }
139
+ specify { critic.problems[file_name.to_s].first[:line].should be 2 }
140
+ specify { critic.problems[file_name.to_s].first[:column].should be 12 }
141
+ specify { critic.problems[file_name.to_s].first[:level].should be :error }
142
+ end
143
+ end
144
+
145
+ context "single-line block" do
146
+ context "space in empty Hash" do
147
+ let(:file_name) { :space_in_empty_hash_in_string_in_block }
148
+ specify { critic.problems[file_name.to_s].size.should be 1 }
149
+ specify { critic.problems[file_name.to_s].first[:type].should == "spaces_in_empty_braces" }
150
+ specify { critic.problems[file_name.to_s].first[:line].should be 1 }
151
+ specify { critic.problems[file_name.to_s].first[:column].should be 36 }
152
+ specify { critic.problems[file_name.to_s].first[:level].should be :error }
153
+ end
154
+
155
+ context "0 spaces before lbrace" do
156
+ let(:file_name) { :single_line_block_0_spaces_before_lbrace }
157
+ specify { critic.problems[file_name.to_s].size.should be 1 }
158
+ specify { critic.problems[file_name.to_s].first[:type].should == "spaces_before_lbrace" }
159
+ specify { critic.problems[file_name.to_s].first[:line].should be 1 }
160
+ specify { critic.problems[file_name.to_s].first[:column].should be 11 }
161
+ specify { critic.problems[file_name.to_s].first[:level].should be :error }
162
+ end
163
+
164
+ context "2 spaces before lbrace" do
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 }
171
+ end
172
+
173
+ context "in String interpolation, 2 spaces before lbrace" do
174
+ let(:file_name) { :single_line_block_in_string_interp_2_spaces_before_lbrace }
175
+ specify { critic.problems[file_name.to_s].size.should be 1 }
176
+ specify { critic.problems[file_name.to_s].first[:type].should == "spaces_before_lbrace" }
177
+ specify { critic.problems[file_name.to_s].first[:line].should be 1 }
178
+ specify { critic.problems[file_name.to_s].first[:column].should be 27 }
179
+ specify { critic.problems[file_name.to_s].first[:level].should be :error }
180
+ end
181
+ end
182
+
183
+ context "multi-line block" do
184
+ context "2 spaces before lbrace" do
185
+ let(:file_name) { :two_line_braces_block_2_spaces_before_lbrace }
186
+ specify { critic.problems[file_name.to_s].size.should be 2 }
187
+ specify { critic.problems[file_name.to_s].first[:type].should == "spaces_before_lbrace" }
188
+ specify { critic.problems[file_name.to_s].first[:line].should be 1 }
189
+ specify { critic.problems[file_name.to_s].first[:column].should be 13 }
190
+ specify { critic.problems[file_name.to_s].first[:level].should be :error }
191
+ specify { critic.problems[file_name.to_s].last[:type].should == "spaces_before_rbrace" }
192
+ specify { critic.problems[file_name.to_s].last[:line].should be 2 }
193
+ specify { critic.problems[file_name.to_s].last[:column].should be 8 }
194
+ specify { critic.problems[file_name.to_s].last[:level].should be :error }
195
+ end
196
+
197
+ context "0 spaces before lbrace, with trailing comment" do
198
+ let(:file_name) { :two_line_braces_block_0_spaces_before_lbrace_trailing_comment }
199
+ specify { critic.problems[file_name.to_s].size.should be 2 }
200
+ specify { critic.problems[file_name.to_s].first[:type].should == "spaces_before_lbrace" }
201
+ specify { critic.problems[file_name.to_s].first[:line].should be 1 }
202
+ specify { critic.problems[file_name.to_s].first[:column].should be 11 }
203
+ specify { critic.problems[file_name.to_s].first[:level].should be :error }
204
+ specify { critic.problems[file_name.to_s].last[:type].should == "spaces_before_rbrace" }
205
+ specify { critic.problems[file_name.to_s].last[:line].should be 2 }
206
+ specify { critic.problems[file_name.to_s].last[:column].should be 8 }
207
+ specify { critic.problems[file_name.to_s].last[:level].should be :error }
208
+ end
209
+ end
210
+
211
+ context "String interpolation" do
212
+ context "0 spaces after lbrace or before rbrace" do
213
+ let(:file_name) { :no_space_after_l_before_r_after_string_interp }
214
+ specify { critic.problems[file_name.to_s].size.should be 2 }
215
+ specify { critic.problems[file_name.to_s].first[:type].should == "spaces_after_lbrace" }
216
+ specify { critic.problems[file_name.to_s].first[:line].should be 1 }
217
+ specify { critic.problems[file_name.to_s].first[:column].should be 47 }
218
+ specify { critic.problems[file_name.to_s].first[:level].should be :error }
219
+ specify { critic.problems[file_name.to_s].last[:type].should == "spaces_before_rbrace" }
220
+ specify { critic.problems[file_name.to_s].last[:line].should be 1 }
221
+ specify { critic.problems[file_name.to_s].last[:column].should be 64 }
222
+ specify { critic.problems[file_name.to_s].last[:level].should be :error }
223
+ end
224
+
225
+ context "no space before consecutive rbraces" do
226
+ let(:file_name) { :no_space_before_consecutive_rbraces }
227
+ specify { critic.problems[file_name.to_s].size.should be 2 }
228
+ specify { critic.problems[file_name.to_s].first[:type].should == "spaces_before_rbrace" }
229
+ specify { critic.problems[file_name.to_s].first[:line].should be 1 }
230
+ specify { critic.problems[file_name.to_s].first[:column].should be 72 }
231
+ specify { critic.problems[file_name.to_s].first[:level].should be :error }
232
+ specify { critic.problems[file_name.to_s].last[:type].should == "spaces_before_rbrace" }
233
+ specify { critic.problems[file_name.to_s].last[:line].should be 1 }
234
+ specify { critic.problems[file_name.to_s].last[:column].should be 73 }
235
+ specify { critic.problems[file_name.to_s].last[:level].should be :error }
236
+ end
237
+ end
238
+ end