tailor 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -38,19 +38,19 @@ describe Tailor::Rulers::IndentationSpacesRuler do
38
38
  it 'sets @embexpr_nesting to [true]' do
39
39
  subject.instance_variable_set(:@embexpr_nesting, [])
40
40
  subject.embexpr_beg_update(lexed_line, 1, 1)
41
- subject.instance_variable_get(:@embexpr_nesting).should == [true]
41
+ expect(subject.instance_variable_get(:@embexpr_nesting)).to eq [true]
42
42
  end
43
43
  end
44
44
 
45
45
  describe '#embexpr_end_update' do
46
46
  before do
47
- lexed_line.should_receive(:only_embexpr_end?).and_return(false)
47
+ expect(lexed_line).to receive(:only_embexpr_end?).and_return(false)
48
48
  end
49
49
 
50
50
  it 'pops @embexpr_nesting' do
51
51
  subject.instance_variable_set(:@embexpr_nesting, [true])
52
52
  subject.embexpr_end_update(lexed_line, 1, 1)
53
- subject.instance_variable_get(:@embexpr_nesting).should == []
53
+ expect(subject.instance_variable_get(:@embexpr_nesting)).to eq []
54
54
  end
55
55
  end
56
56
 
@@ -98,18 +98,18 @@ describe Tailor::Rulers::IndentationSpacesRuler do
98
98
  let(:manager) { double 'IndentationManager' }
99
99
 
100
100
  it 'calls #stop on the indentation_manager object' do
101
- manager.should_receive(:update_actual_indentation).with lexed_line
102
- manager.should_receive(:stop)
101
+ expect(manager).to receive(:update_actual_indentation).with lexed_line
102
+ expect(manager).to receive(:stop)
103
103
  subject.instance_variable_set(:@manager, manager)
104
104
  subject.tstring_beg_update(lexed_line, 1)
105
105
  end
106
106
 
107
107
  it 'adds the lineno to @tstring_nesting' do
108
- manager.stub(:update_actual_indentation)
109
- manager.stub(:stop)
108
+ allow(manager).to receive(:update_actual_indentation)
109
+ allow(manager).to receive(:stop)
110
110
  subject.instance_variable_set(:@manager, manager)
111
111
  subject.tstring_beg_update(lexed_line, 1)
112
- subject.instance_variable_get(:@tstring_nesting).should == [1]
112
+ expect(subject.instance_variable_get(:@tstring_nesting)).to eq [1]
113
113
  end
114
114
  end
115
115
 
@@ -118,19 +118,19 @@ describe Tailor::Rulers::IndentationSpacesRuler do
118
118
  let(:manager) { double 'IndentationManager' }
119
119
 
120
120
  it 'calls #start' do
121
- manager.should_receive(:start)
121
+ expect(manager).to receive(:start)
122
122
  subject.instance_variable_set(:@manager, manager)
123
123
  subject.tstring_end_update(2)
124
124
  end
125
125
 
126
126
  it 'removes the lineno to @tstring_nesting then calls @manager.start' do
127
- manager.should_receive(:actual_indentation)
128
- manager.should_receive(:start)
127
+ expect(manager).to receive(:actual_indentation)
128
+ expect(manager).to receive(:start)
129
129
  subject.instance_variable_set(:@manager, manager)
130
130
  subject.instance_variable_set(:@tstring_nesting, [1])
131
- subject.should_receive(:measure)
131
+ expect(subject).to receive(:measure)
132
132
  subject.tstring_end_update(2)
133
- subject.instance_variable_get(:@tstring_nesting).should be_empty
133
+ expect(subject.instance_variable_get(:@tstring_nesting)).to be_empty
134
134
  end
135
135
  end
136
136
  end
@@ -7,7 +7,7 @@ describe Tailor::Rulers::SpacesAfterCommaRuler do
7
7
  describe '#comma_update' do
8
8
  it 'adds the column number to @comma_columns' do
9
9
  subject.comma_update(',', 2, 1)
10
- subject.instance_variable_get(:@comma_columns).should == [1]
10
+ expect(subject.instance_variable_get(:@comma_columns)).to eq [1]
11
11
  end
12
12
  end
13
13
 
@@ -15,14 +15,14 @@ describe Tailor::Rulers::SpacesAfterCommaRuler do
15
15
  context 'no event after comma' do
16
16
  let(:lexed_line) do
17
17
  l = double 'LexedLine'
18
- l.stub(:event_at)
19
- l.stub(:index)
18
+ allow(l).to receive(:event_at)
19
+ allow(l).to receive(:index)
20
20
 
21
21
  l
22
22
  end
23
23
 
24
24
  it 'does not detect any problems' do
25
- Tailor::Problem.should_not_receive(:new)
25
+ expect(Tailor::Problem).to_not receive(:new)
26
26
  expect { subject.check_spaces_after_comma(lexed_line, 1) }.
27
27
  to_not raise_error
28
28
  end
@@ -7,14 +7,14 @@ describe Tailor::Rulers::SpacesAfterLbraceRuler do
7
7
  describe '#comment_update' do
8
8
  context 'token has a trailing newline' do
9
9
  it 'calls #ignored_nl_update' do
10
- subject.should_receive(:ignored_nl_update)
10
+ expect(subject).to receive(:ignored_nl_update)
11
11
  subject.comment_update("\n", '', '', 1, 1)
12
12
  end
13
13
  end
14
14
 
15
15
  context 'token does not have a trailing newline' do
16
16
  it 'does not call #ignored_nl_update' do
17
- subject.should_not_receive(:ignored_nl_update)
17
+ expect(subject).to_not receive(:ignored_nl_update)
18
18
  subject.comment_update('# comment', '', '', 1, 1)
19
19
  end
20
20
  end
@@ -22,7 +22,7 @@ describe Tailor::Rulers::SpacesAfterLbraceRuler do
22
22
 
23
23
  describe '#ignored_nl_update' do
24
24
  it 'calls #check_spaces_after_lbrace' do
25
- subject.should_receive(:check_spaces_after_lbrace)
25
+ expect(subject).to receive(:check_spaces_after_lbrace)
26
26
  subject.ignored_nl_update('', 1, 1)
27
27
  end
28
28
  end
@@ -30,13 +30,13 @@ describe Tailor::Rulers::SpacesAfterLbraceRuler do
30
30
  describe '#lbrace_update' do
31
31
  it 'adds column to @lbrace_columns' do
32
32
  subject.lbrace_update('', 1, 1)
33
- subject.instance_variable_get(:@lbrace_columns).should == [1]
33
+ expect(subject.instance_variable_get(:@lbrace_columns)).to eq [1]
34
34
  end
35
35
  end
36
36
 
37
37
  describe '#nl_update' do
38
38
  it 'calls #ignored_nl_update' do
39
- subject.should_receive(:ignored_nl_update)
39
+ expect(subject).to receive(:ignored_nl_update)
40
40
  subject.nl_update('', 1, 1)
41
41
  end
42
42
  end
@@ -51,8 +51,8 @@ describe Tailor::Rulers::SpacesAfterLbraceRuler do
51
51
  end
52
52
 
53
53
  it 'breaks from the loop and returns nil' do
54
- lexed_line.should_not_receive(:at)
55
- subject.count_spaces(lexed_line, 1).should be_nil
54
+ expect(lexed_line).to_not receive(:at)
55
+ expect(subject.count_spaces(lexed_line, 1)).to be_nil
56
56
  end
57
57
  end
58
58
 
@@ -66,7 +66,7 @@ describe Tailor::Rulers::SpacesAfterLbraceRuler do
66
66
  end
67
67
 
68
68
  it 'returns 0' do
69
- subject.count_spaces(lexed_line, 1).should be_zero
69
+ expect(subject.count_spaces(lexed_line, 1)).to be_zero
70
70
  end
71
71
  end
72
72
 
@@ -77,14 +77,14 @@ describe Tailor::Rulers::SpacesAfterLbraceRuler do
77
77
 
78
78
  let(:lexed_line) do
79
79
  l = double 'LexedLine'
80
- l.stub(:event_index).and_return 1
81
- l.should_receive(:at).with(2).and_return next_event
80
+ allow(l).to receive(:event_index).and_return 1
81
+ expect(l).to receive(:at).with(2).and_return next_event
82
82
 
83
83
  l
84
84
  end
85
85
 
86
86
  it 'returns 0' do
87
- subject.count_spaces(lexed_line, 1).should be_zero
87
+ expect(subject.count_spaces(lexed_line, 1)).to be_zero
88
88
  end
89
89
  end
90
90
 
@@ -95,8 +95,8 @@ describe Tailor::Rulers::SpacesAfterLbraceRuler do
95
95
 
96
96
  let(:lexed_line) do
97
97
  l = double 'LexedLine'
98
- l.stub(:event_index).and_return 1
99
- l.should_receive(:at).with(2).and_return next_event
98
+ allow(l).to receive(:event_index).and_return 1
99
+ expect(l).to receive(:at).with(2).and_return next_event
100
100
 
101
101
  l
102
102
  end
@@ -113,14 +113,14 @@ describe Tailor::Rulers::SpacesAfterLbraceRuler do
113
113
 
114
114
  let(:lexed_line) do
115
115
  l = double 'LexedLine'
116
- l.stub(:event_index).and_return 1
117
- l.stub(:at).and_return next_event
116
+ allow(l).to receive(:event_index).and_return 1
117
+ allow(l).to receive(:at).and_return next_event
118
118
 
119
119
  l
120
120
  end
121
121
 
122
122
  it 'returns 0' do
123
- subject.count_spaces(lexed_line, 1).should be_zero
123
+ expect(subject.count_spaces(lexed_line, 1)).to be_zero
124
124
  end
125
125
  end
126
126
 
@@ -131,14 +131,14 @@ describe Tailor::Rulers::SpacesAfterLbraceRuler do
131
131
 
132
132
  let(:lexed_line) do
133
133
  l = double 'LexedLine'
134
- l.stub(:event_index).and_return 1
135
- l.stub(:at).and_return next_event
134
+ allow(l).to receive(:event_index).and_return 1
135
+ allow(l).to receive(:at).and_return next_event
136
136
 
137
137
  l
138
138
  end
139
139
 
140
140
  it 'returns 2' do
141
- subject.count_spaces(lexed_line, 1).should == 2
141
+ expect(subject.count_spaces(lexed_line, 1)).to eq 2
142
142
  end
143
143
  end
144
144
  end
@@ -15,12 +15,12 @@ describe Tailor::Rulers::SpacesBeforeLbraceRuler do
15
15
  l
16
16
  end
17
17
 
18
- specify { subject.count_spaces(lexed_line, 1).should be_zero }
18
+ specify { expect(subject.count_spaces(lexed_line, 1)).to be_zero }
19
19
 
20
20
  it 'sets @do_measurement to false' do
21
21
  expect { subject.count_spaces(lexed_line, 1) }.
22
- to change{subject.instance_variable_get(:@do_measurement)}.from(true).
23
- to(false)
22
+ to change { subject.instance_variable_get(:@do_measurement) }.
23
+ from(true).to(false)
24
24
  end
25
25
  end
26
26
 
@@ -33,7 +33,7 @@ describe Tailor::Rulers::SpacesBeforeLbraceRuler do
33
33
  l
34
34
  end
35
35
 
36
- specify { subject.count_spaces(lexed_line, 1).should be_zero }
36
+ specify { expect(subject.count_spaces(lexed_line, 1)).to be_zero }
37
37
  end
38
38
 
39
39
  context '1 space before lbrace' do
@@ -45,7 +45,7 @@ describe Tailor::Rulers::SpacesBeforeLbraceRuler do
45
45
  l
46
46
  end
47
47
 
48
- specify { subject.count_spaces(lexed_line, 1).should == 1 }
48
+ specify { expect(subject.count_spaces(lexed_line, 1)).to eq 1 }
49
49
  end
50
50
 
51
51
  context '> 1 space before lbrace' do
@@ -57,7 +57,7 @@ describe Tailor::Rulers::SpacesBeforeLbraceRuler do
57
57
  l
58
58
  end
59
59
 
60
- specify { subject.count_spaces(lexed_line, 3).should == 2 }
60
+ specify { expect(subject.count_spaces(lexed_line, 3)).to eq 2 }
61
61
  end
62
62
  end
63
63
  end
@@ -15,12 +15,12 @@ describe Tailor::Rulers::SpacesBeforeRbraceRuler do
15
15
  l
16
16
  end
17
17
 
18
- specify { subject.count_spaces(lexed_line, 1).should be_zero }
18
+ specify { expect(subject.count_spaces(lexed_line, 1)).to be_zero }
19
19
 
20
20
  it 'sets @do_measurement to false' do
21
21
  expect { subject.count_spaces(lexed_line, 1) }.
22
- to change{subject.instance_variable_get(:@do_measurement)}.from(true).
23
- to(false)
22
+ to change { subject.instance_variable_get(:@do_measurement) }.
23
+ from(true).to(false)
24
24
  end
25
25
  end
26
26
 
@@ -33,7 +33,7 @@ describe Tailor::Rulers::SpacesBeforeRbraceRuler do
33
33
  l
34
34
  end
35
35
 
36
- specify { subject.count_spaces(lexed_line, 1).should be_zero }
36
+ specify { expect(subject.count_spaces(lexed_line, 1)).to be_zero }
37
37
  end
38
38
 
39
39
  context '1 space before rbrace' do
@@ -45,7 +45,7 @@ describe Tailor::Rulers::SpacesBeforeRbraceRuler do
45
45
  l
46
46
  end
47
47
 
48
- specify { subject.count_spaces(lexed_line, 1).should == 1 }
48
+ specify { expect(subject.count_spaces(lexed_line, 1)).to eq 1 }
49
49
  end
50
50
 
51
51
  context '> 1 space before rbrace' do
@@ -57,7 +57,7 @@ describe Tailor::Rulers::SpacesBeforeRbraceRuler do
57
57
  l
58
58
  end
59
59
 
60
- specify { subject.count_spaces(lexed_line, 1).should == 2 }
60
+ specify { expect(subject.count_spaces(lexed_line, 1)).to eq 2 }
61
61
  end
62
62
  end
63
63
  end
@@ -4,6 +4,6 @@ require 'tailor/rulers'
4
4
  describe Tailor::Rulers do
5
5
  it 'requires all of its children' do
6
6
  # if it does one, it'll have done them all.
7
- subject.const_get('AllowCamelCaseMethodsRuler').should be_true
7
+ expect(subject.const_get('AllowCamelCaseMethodsRuler')).to be_truthy
8
8
  end
9
9
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
  require 'tailor/version'
3
3
 
4
-
5
4
  describe Tailor::VERSION do
6
- it { should == '1.4.0' }
5
+ it { is_expected.to eq '1.4.1' }
7
6
  end
@@ -6,12 +6,12 @@ describe Tailor do
6
6
 
7
7
  describe '.config' do
8
8
  it 'creates a new Configuration object' do
9
- Tailor::Configuration.should_receive(:new)
9
+ expect(Tailor::Configuration).to receive(:new)
10
10
  Tailor.config
11
11
  end
12
12
 
13
13
  it 'returns a Configuration object' do
14
- Tailor.config.should be_a Tailor::Configuration
14
+ expect(Tailor.config).to be_a Tailor::Configuration
15
15
  end
16
16
  end
17
17
  end
@@ -26,7 +26,7 @@ project, whatever style that may be.
26
26
  s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
27
27
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
28
28
 
29
- s.add_runtime_dependency 'log_switch', '>= 0.3.0'
29
+ s.add_runtime_dependency 'log_switch', '~> 0.3.0'
30
30
  s.add_runtime_dependency 'nokogiri', '>= 1.6.0'
31
31
  s.add_runtime_dependency 'term-ansicolor', '>= 1.0.5'
32
32
  s.add_runtime_dependency 'text-table', '>= 1.2.2'
@@ -36,8 +36,8 @@ project, whatever style that may be.
36
36
  s.add_development_dependency 'cucumber', '>= 1.0.2'
37
37
  s.add_development_dependency 'fakefs', '>= 0.4.2'
38
38
  s.add_development_dependency 'rake'
39
- s.add_development_dependency 'rspec', '>= 2.5.0'
39
+ s.add_development_dependency 'rspec', '~> 3.1'
40
+ s.add_development_dependency 'rspec-its'
40
41
  s.add_development_dependency 'simplecov', '>= 0.4.0'
41
42
  s.add_development_dependency 'yard', '>= 0.7.0'
42
43
  end
43
-
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tailor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Loveless
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-24 00:00:00.000000000 Z
11
+ date: 2014-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: log_switch
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.3.0
27
27
  - !ruby/object:Gem::Dependency
@@ -138,18 +138,32 @@ dependencies:
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '3.1'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '3.1'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rspec-its
141
155
  requirement: !ruby/object:Gem::Requirement
142
156
  requirements:
143
157
  - - ">="
144
158
  - !ruby/object:Gem::Version
145
- version: 2.5.0
159
+ version: '0'
146
160
  type: :development
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
164
  - - ">="
151
165
  - !ruby/object:Gem::Version
152
- version: 2.5.0
166
+ version: '0'
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: simplecov
155
169
  requirement: !ruby/object:Gem::Requirement