tailor 1.2.1 → 1.3.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 (94) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +30 -28
  3. data/History.md +257 -0
  4. data/README.md +486 -0
  5. data/Rakefile +1 -9
  6. data/lib/ext/string_ext.rb +1 -1
  7. data/lib/tailor/cli.rb +3 -1
  8. data/lib/tailor/cli/options.rb +59 -39
  9. data/lib/tailor/configuration.rb +8 -5
  10. data/lib/tailor/configuration/file_set.rb +1 -3
  11. data/lib/tailor/configuration/style.rb +2 -0
  12. data/lib/tailor/critic.rb +2 -2
  13. data/lib/tailor/formatters/text.rb +17 -16
  14. data/lib/tailor/lexed_line.rb +2 -4
  15. data/lib/tailor/lexer.rb +9 -9
  16. data/lib/tailor/lexer/lexer_constants.rb +32 -32
  17. data/lib/tailor/lexer/token.rb +8 -10
  18. data/lib/tailor/logger.rb +1 -1
  19. data/lib/tailor/problem.rb +4 -1
  20. data/lib/tailor/rake_task.rb +4 -1
  21. data/lib/tailor/reporter.rb +3 -3
  22. data/lib/tailor/ruler.rb +2 -2
  23. data/lib/tailor/rulers/allow_camel_case_methods_ruler.rb +2 -2
  24. data/lib/tailor/rulers/allow_hard_tabs_ruler.rb +1 -1
  25. data/lib/tailor/rulers/allow_invalid_ruby_ruler.rb +1 -1
  26. data/lib/tailor/rulers/allow_screaming_snake_case_classes_ruler.rb +2 -2
  27. data/lib/tailor/rulers/indentation_spaces_ruler.rb +24 -22
  28. data/lib/tailor/rulers/indentation_spaces_ruler/indentation_manager.rb +13 -13
  29. data/lib/tailor/rulers/max_code_lines_in_class_ruler.rb +2 -2
  30. data/lib/tailor/rulers/max_code_lines_in_method_ruler.rb +2 -2
  31. data/lib/tailor/rulers/spaces_after_comma_ruler.rb +6 -6
  32. data/lib/tailor/rulers/spaces_after_conditional_ruler.rb +48 -0
  33. data/lib/tailor/rulers/spaces_after_lbrace_ruler.rb +8 -8
  34. data/lib/tailor/rulers/spaces_after_lbracket_ruler.rb +6 -6
  35. data/lib/tailor/rulers/spaces_after_lparen_ruler.rb +6 -6
  36. data/lib/tailor/rulers/spaces_before_comma_ruler.rb +2 -2
  37. data/lib/tailor/rulers/spaces_before_lbrace_ruler.rb +4 -4
  38. data/lib/tailor/rulers/spaces_before_rbrace_ruler.rb +9 -9
  39. data/lib/tailor/rulers/spaces_before_rbracket_ruler.rb +6 -6
  40. data/lib/tailor/rulers/spaces_before_rparen_ruler.rb +6 -6
  41. data/lib/tailor/rulers/spaces_in_empty_braces_ruler.rb +1 -1
  42. data/lib/tailor/rulers/trailing_newlines_ruler.rb +2 -2
  43. data/lib/tailor/tailorrc.erb +1 -1
  44. data/lib/tailor/version.rb +1 -1
  45. data/spec/functional/conditional_spacing_spec.rb +149 -0
  46. data/spec/functional/configuration_spec.rb +36 -26
  47. data/spec/functional/horizontal_spacing/braces_spec.rb +1 -1
  48. data/spec/functional/horizontal_spacing/brackets_spec.rb +14 -14
  49. data/spec/functional/horizontal_spacing/comma_spacing_spec.rb +8 -8
  50. data/spec/functional/horizontal_spacing/hard_tabs_spec.rb +13 -13
  51. data/spec/functional/horizontal_spacing/long_lines_spec.rb +6 -6
  52. data/spec/functional/horizontal_spacing/long_methods_spec.rb +55 -0
  53. data/spec/functional/horizontal_spacing/parens_spec.rb +17 -17
  54. data/spec/functional/horizontal_spacing/trailing_whitespace_spec.rb +8 -8
  55. data/spec/functional/horizontal_spacing_spec.rb +11 -11
  56. data/spec/functional/indentation_spacing/bad_indentation_spec.rb +83 -83
  57. data/spec/functional/indentation_spacing_spec.rb +10 -10
  58. data/spec/functional/naming/camel_case_methods_spec.rb +6 -6
  59. data/spec/functional/naming/screaming_snake_case_classes_spec.rb +10 -10
  60. data/spec/functional/naming_spec.rb +3 -3
  61. data/spec/functional/vertical_spacing/class_length_spec.rb +6 -6
  62. data/spec/functional/vertical_spacing/method_length_spec.rb +6 -6
  63. data/spec/functional/vertical_spacing_spec.rb +3 -3
  64. data/spec/support/conditional_spacing_cases.rb +37 -0
  65. data/spec/support/good_indentation_cases.rb +1 -1
  66. data/spec/unit/tailor/cli/options_spec.rb +50 -0
  67. data/spec/unit/tailor/cli_spec.rb +3 -3
  68. data/spec/unit/tailor/composite_observable_spec.rb +8 -8
  69. data/spec/unit/tailor/configuration/file_set_spec.rb +2 -2
  70. data/spec/unit/tailor/configuration/style_spec.rb +30 -29
  71. data/spec/unit/tailor/configuration_spec.rb +39 -24
  72. data/spec/unit/tailor/critic_spec.rb +18 -17
  73. data/spec/unit/tailor/formatter_spec.rb +15 -15
  74. data/spec/unit/tailor/formatters/yaml_spec.rb +1 -1
  75. data/spec/unit/tailor/lexed_line_spec.rb +258 -258
  76. data/spec/unit/tailor/lexer/token_spec.rb +11 -11
  77. data/spec/unit/tailor/lexer_spec.rb +35 -35
  78. data/spec/unit/tailor/problem_spec.rb +13 -13
  79. data/spec/unit/tailor/reporter_spec.rb +19 -18
  80. data/spec/unit/tailor/ruler_spec.rb +15 -15
  81. data/spec/unit/tailor/rulers/indentation_spaces_ruler/indentation_manager_spec.rb +72 -72
  82. data/spec/unit/tailor/rulers/indentation_spaces_ruler_spec.rb +32 -32
  83. data/spec/unit/tailor/rulers/spaces_after_comma_ruler_spec.rb +8 -8
  84. data/spec/unit/tailor/rulers/spaces_after_lbrace_ruler_spec.rb +36 -36
  85. data/spec/unit/tailor/rulers/spaces_before_lbrace_ruler_spec.rb +14 -14
  86. data/spec/unit/tailor/rulers/spaces_before_rbrace_ruler_spec.rb +14 -14
  87. data/spec/unit/tailor/rulers_spec.rb +2 -2
  88. data/spec/unit/tailor/version_spec.rb +1 -1
  89. data/spec/unit/tailor_spec.rb +4 -4
  90. data/tailor.gemspec +1 -1
  91. metadata +16 -9
  92. data/History.rdoc +0 -189
  93. data/README.rdoc +0 -422
  94. data/spec/unit/tailor/options_spec.rb +0 -6
@@ -1,4 +1,4 @@
1
- require_relative '../../../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'tailor/lexer/token'
3
3
 
4
4
  describe Tailor::Lexer::Token do
@@ -6,39 +6,39 @@ describe Tailor::Lexer::Token do
6
6
  Tailor::Logger.stub(:log)
7
7
  end
8
8
 
9
- describe "#modifier_keyword?" do
9
+ describe '#modifier_keyword?' do
10
10
  subject do
11
11
  options = { full_line_of_text: full_line_of_text }
12
- Tailor::Lexer::Token.new("if", options)
12
+ Tailor::Lexer::Token.new('if', options)
13
13
  end
14
14
 
15
- context "the current line has a keyword that is also a modifier" do
16
- context "the keyword is acting as a modifier" do
15
+ context 'the current line has a keyword that is also a modifier' do
16
+ context 'the keyword is acting as a modifier' do
17
17
  let!(:full_line_of_text) { %q{puts "hi" if true == true} }
18
18
 
19
- it "returns true" do
19
+ it 'returns true' do
20
20
  subject.modifier_keyword?.should be_true
21
21
  end
22
22
  end
23
23
 
24
- context "they keyword is NOT acting as a modifier" do
24
+ context 'they keyword is NOT acting as a modifier' do
25
25
  let!(:full_line_of_text) { %q{if true == true; puts "hi"; end} }
26
26
 
27
- it "returns false" do
27
+ it 'returns false' do
28
28
  subject.modifier_keyword?.should be_false
29
29
  end
30
30
  end
31
31
  end
32
32
 
33
- context "the current line doesn't have a keyword" do
33
+ context 'the current line does not have a keyword' do
34
34
  let!(:full_line_of_text) { %q{puts true} }
35
35
 
36
36
  subject do
37
37
  options = { full_line_of_text: full_line_of_text }
38
- Tailor::Lexer::Token.new("puts", options)
38
+ Tailor::Lexer::Token.new('puts', options)
39
39
  end
40
40
 
41
- it "returns false" do
41
+ it 'returns false' do
42
42
  subject.modifier_keyword?.should be_false
43
43
  end
44
44
  end
@@ -1,10 +1,10 @@
1
- require_relative '../../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'tailor/lexer'
3
3
 
4
4
  describe Tailor::Lexer do
5
- let!(:file_text) { "" }
5
+ let!(:file_text) { '' }
6
6
  let(:style) { {} }
7
- let(:indentation_ruler) { double "IndentationSpacesRuler" }
7
+ let(:indentation_ruler) { double 'IndentationSpacesRuler' }
8
8
 
9
9
  subject do
10
10
  r = Tailor::Lexer.new(file_text)
@@ -19,42 +19,42 @@ describe Tailor::Lexer do
19
19
  and_return(file_text)
20
20
  end
21
21
 
22
- describe "#initialize" do
23
- context "name of file is passed in" do
24
- let(:file_name) { "test" }
22
+ describe '#initialize' do
23
+ context 'name of file is passed in' do
24
+ let(:file_name) { 'test' }
25
25
 
26
26
  before do
27
- File.open(file_name, 'w') { |f| f.write "some text" }
27
+ File.open(file_name, 'w') { |f| f.write 'some text' }
28
28
  end
29
29
 
30
- it "opens and reads the file by the name passed in" do
31
- file = double "File"
30
+ it 'opens and reads the file by the name passed in' do
31
+ file = double 'File'
32
32
  file.should_receive(:read).and_return file_text
33
- File.should_receive(:open).with("test", 'r').and_return file
33
+ File.should_receive(:open).with('test', 'r').and_return file
34
34
  Tailor::Lexer.new(file_name)
35
35
  end
36
36
  end
37
37
 
38
- context "text to lex is passed in" do
39
- let(:text) { "some text" }
38
+ context 'text to lex is passed in' do
39
+ let(:text) { 'some text' }
40
40
 
41
- it "doesn't try to open a file" do
41
+ it 'does not try to open a file' do
42
42
  File.should_not_receive(:open)
43
43
  Tailor::Lexer.new(text)
44
44
  end
45
45
  end
46
46
  end
47
47
 
48
- describe "#on_sp" do
49
- context "token is a backslash then newline" do
50
- it "calls #notify_ignored_nl_observers" do
48
+ describe '#on_sp' do
49
+ context 'token is a backslash then newline' do
50
+ it 'calls #notify_ignored_nl_observers' do
51
51
  subject.should_receive(:notify_ignored_nl_observers)
52
52
  subject.on_sp("\\\n")
53
53
  end
54
54
  end
55
55
  end
56
56
 
57
- describe "#current_line_of_text" do
57
+ describe '#current_line_of_text' do
58
58
  before do
59
59
  subject.instance_variable_set(:@file_text, file_text)
60
60
  subject.stub(:lineno).and_return 1
@@ -63,15 +63,15 @@ describe Tailor::Lexer do
63
63
  context "@file_text is 1 line with 0 \\ns" do
64
64
  let(:file_text) { "puts 'code'" }
65
65
 
66
- it "returns the line" do
66
+ it 'returns the line' do
67
67
  subject.current_line_of_text.should == file_text
68
68
  end
69
69
  end
70
70
 
71
71
  context "@file_text is 1 empty line with 0 \\ns" do
72
- let(:file_text) { "" }
72
+ let(:file_text) { '' }
73
73
 
74
- it "returns the an empty string" do
74
+ it 'returns the an empty string' do
75
75
  subject.current_line_of_text.should == file_text
76
76
  end
77
77
  end
@@ -79,15 +79,15 @@ describe Tailor::Lexer do
79
79
  context "@file_text is 1 empty line with 1 \\n" do
80
80
  let(:file_text) { "\n" }
81
81
 
82
- it "returns an empty string" do
83
- subject.current_line_of_text.should == ""
82
+ it 'returns an empty string' do
83
+ subject.current_line_of_text.should == ''
84
84
  end
85
85
  end
86
86
  end
87
87
 
88
- describe "#count_trailing_newlines" do
88
+ describe '#count_trailing_newlines' do
89
89
  context "text contains 0 trailing \\n" do
90
- let(:text) { "text" }
90
+ let(:text) { 'text' }
91
91
  specify { subject.count_trailing_newlines(text).should be_zero }
92
92
  end
93
93
 
@@ -97,45 +97,45 @@ describe Tailor::Lexer do
97
97
  end
98
98
  end
99
99
 
100
- describe "#ensure_trailing_newline" do
100
+ describe '#ensure_trailing_newline' do
101
101
  before do
102
102
  Tailor::Lexer.any_instance.unstub(:ensure_trailing_newline)
103
103
  end
104
104
 
105
- context "text contains a trailing newline already" do
105
+ context 'text contains a trailing newline already' do
106
106
  let!(:text) { "text\n" }
107
107
 
108
108
  before do
109
109
  subject.stub(:count_trailing_newlines).and_return 1
110
110
  end
111
111
 
112
- it "doesn't alter the text" do
112
+ it 'does not alter the text' do
113
113
  subject.ensure_trailing_newline(text).should == text
114
114
  end
115
115
  end
116
116
 
117
- context "text does not contain a trailing newline" do
118
- let!(:text) { "text" }
117
+ context 'text does not contain a trailing newline' do
118
+ let!(:text) { 'text' }
119
119
 
120
- it "adds a newline at the end" do
120
+ it 'adds a newline at the end' do
121
121
  subject.ensure_trailing_newline(text).should == text + "\n"
122
122
  end
123
123
  end
124
124
  end
125
-
126
- describe "#sub_line_ending_backslashes" do
125
+
126
+ describe '#sub_line_ending_backslashes' do
127
127
  let!(:text) do
128
128
  %Q{command \\
129
129
  'something'}
130
130
  end
131
-
131
+
132
132
  before do
133
133
  def subject.sub_publicly(file_text)
134
134
  sub_line_ending_backslashes(file_text)
135
135
  end
136
136
  end
137
-
138
- it "replaces all line-ending backslashes with a comment" do
137
+
138
+ it 'replaces all line-ending backslashes with a comment' do
139
139
  subject.sub_publicly(text).should == %Q{command # TAILOR REMOVED BACKSLASH
140
140
  'something'}
141
141
  end
@@ -1,4 +1,4 @@
1
- require_relative '../../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'tailor/problem'
3
3
 
4
4
  describe Tailor::Problem do
@@ -9,33 +9,33 @@ describe Tailor::Problem do
9
9
  let(:lineno) { 10 }
10
10
  let(:column) { 11 }
11
11
 
12
- describe "#set_values" do
12
+ describe '#set_values' do
13
13
  before do
14
14
  Tailor::Problem.any_instance.stub(:message)
15
15
  end
16
16
 
17
- it "sets self[:type] to the type param" do
18
- Tailor::Problem.new(:test, lineno, column, "", :b).
17
+ it 'sets self[:type] to the type param' do
18
+ Tailor::Problem.new(:test, lineno, column, '', :b).
19
19
  should include(type: :test)
20
20
  end
21
21
 
22
- it "sets self[:line] to the lineno param" do
23
- Tailor::Problem.new(:test, lineno, column, "", :c).
22
+ it 'sets self[:line] to the lineno param' do
23
+ Tailor::Problem.new(:test, lineno, column, '', :c).
24
24
  should include(line: lineno)
25
25
  end
26
26
 
27
- it "sets self[:column] to the column param" do
28
- Tailor::Problem.new(:test, lineno, column, "", :d).
27
+ it 'sets self[:column] to the column param' do
28
+ Tailor::Problem.new(:test, lineno, column, '', :d).
29
29
  should include(column: column)
30
30
  end
31
31
 
32
- it "sets self[:message] to the message param" do
33
- Tailor::Problem.new(:test, lineno, column, "test", :d).
34
- should include(message: "test")
32
+ it 'sets self[:message] to the message param' do
33
+ Tailor::Problem.new(:test, lineno, column, 'test', :d).
34
+ should include(message: 'test')
35
35
  end
36
36
 
37
- it "sets self[:level] to the level param" do
38
- Tailor::Problem.new(:test, lineno, column, "test", :d).
37
+ it 'sets self[:level] to the level param' do
38
+ Tailor::Problem.new(:test, lineno, column, 'test', :d).
39
39
  should include(level: :d)
40
40
  end
41
41
  end
@@ -1,21 +1,21 @@
1
- require_relative '../../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'tailor/reporter'
3
3
 
4
4
  describe Tailor::Reporter do
5
- describe "#initialize" do
6
- context "text formatter" do
5
+ describe '#initialize' do
6
+ context 'text formatter' do
7
7
  let(:formats) { ['text'] }
8
8
 
9
- it "creates a new Formatter object of the type passed in" do
9
+ it 'creates a new Formatter object of the type passed in' do
10
10
  reporter = Tailor::Reporter.new(formats)
11
11
  reporter.formatters.first.should be_a Tailor::Formatters::Text
12
12
  end
13
13
  end
14
14
  end
15
15
 
16
- describe "#file_report" do
17
- let(:file_problems) { double "file problems" }
18
- let(:formatter) { double "Tailor::Formatters::SomeFormatter" }
16
+ describe '#file_report' do
17
+ let(:file_problems) { double 'file problems' }
18
+ let(:formatter) { double 'Tailor::Formatters::SomeFormatter' }
19
19
 
20
20
  subject do
21
21
  t = Tailor::Reporter.new
@@ -24,7 +24,7 @@ describe Tailor::Reporter do
24
24
  t
25
25
  end
26
26
 
27
- it "calls #file_report on each @formatters" do
27
+ it 'calls #file_report on each @formatters' do
28
28
  label = :some_label
29
29
  formatter.should_receive(:file_report).with(file_problems, label)
30
30
 
@@ -32,9 +32,9 @@ describe Tailor::Reporter do
32
32
  end
33
33
  end
34
34
 
35
- describe "#summary_report" do
36
- let(:all_problems) { double "all problems" }
37
- let(:formatter) { double "Tailor::Formatters::SomeFormatter" }
35
+ describe '#summary_report' do
36
+ let(:all_problems) { double 'all problems' }
37
+ let(:formatter) { double 'Tailor::Formatters::SomeFormatter' }
38
38
 
39
39
  subject do
40
40
  t = Tailor::Reporter.new
@@ -43,8 +43,8 @@ describe Tailor::Reporter do
43
43
  t
44
44
  end
45
45
 
46
- context "without output file" do
47
- it "calls #file_report on each @formatters" do
46
+ context 'without output file' do
47
+ it 'calls #file_report on each @formatters' do
48
48
  label = :some_label
49
49
  formatter.should_receive(:summary_report).with(all_problems)
50
50
  File.should_not_receive(:open)
@@ -53,16 +53,17 @@ describe Tailor::Reporter do
53
53
  end
54
54
  end
55
55
 
56
- context "with output file" do
57
- let(:output_file) { "output.whatever" }
56
+ context 'with output file' do
57
+ let(:output_file) { 'output.whatever' }
58
58
  before do
59
- formatter.should_receive(:respond_to?).with(:accepts_output_file).and_return(true)
59
+ formatter.should_receive(:respond_to?).with(:accepts_output_file).
60
+ and_return(true)
60
61
  formatter.should_receive(:accepts_output_file).and_return(true)
61
62
  end
62
63
 
63
- it "calls #summary_report on each @formatters" do
64
+ it 'calls #summary_report on each @formatters' do
64
65
  formatter.should_receive(:summary_report).with(all_problems)
65
- File.should_receive(:open).with(output_file, "w")
66
+ File.should_receive(:open).with(output_file, 'w')
66
67
 
67
68
  subject.summary_report(all_problems, output_file: output_file)
68
69
  end
@@ -1,26 +1,26 @@
1
- require_relative '../../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'tailor/ruler'
3
3
 
4
4
  describe Tailor::Ruler do
5
5
  before { Tailor::Logger.stub(:log) }
6
6
 
7
- describe "#add_child_ruler" do
8
- it "adds new rulers to @child_rulers" do
9
- ruler = double "Ruler"
7
+ describe '#add_child_ruler' do
8
+ it 'adds new rulers to @child_rulers' do
9
+ ruler = double 'Ruler'
10
10
  subject.add_child_ruler(ruler)
11
11
  subject.instance_variable_get(:@child_rulers).first.should == ruler
12
12
  end
13
13
  end
14
14
 
15
- describe "#problems" do
16
- context "no child_rulers" do
17
- context "@problems is empty" do
15
+ describe '#problems' do
16
+ context 'no child_rulers' do
17
+ context '@problems is empty' do
18
18
  specify { subject.problems.should be_empty }
19
19
  end
20
20
 
21
- context "@problems.size is 1" do
21
+ context '@problems.size is 1' do
22
22
  before do
23
- problem = double "Problem"
23
+ problem = double 'Problem'
24
24
  problem.should_receive(:[]).with :line
25
25
  subject.instance_variable_set(:@problems, [problem])
26
26
  end
@@ -29,22 +29,22 @@ describe Tailor::Ruler do
29
29
  end
30
30
  end
31
31
 
32
- context "child_rulers have problems" do
32
+ context 'child_rulers have problems' do
33
33
  before do
34
- problem = double "Problem"
34
+ problem = double 'Problem'
35
35
  problem.should_receive(:[]).with :line
36
- child_ruler = double "Ruler"
36
+ child_ruler = double 'Ruler'
37
37
  child_ruler.stub(:problems).and_return([problem])
38
38
  subject.instance_variable_set(:@child_rulers, [child_ruler])
39
39
  end
40
40
 
41
- context "@problems is empty" do
41
+ context '@problems is empty' do
42
42
  specify { subject.problems.size.should == 1 }
43
43
  end
44
44
 
45
- context "@problems.size is 1" do
45
+ context '@problems.size is 1' do
46
46
  before do
47
- problem = double "Problem"
47
+ problem = double 'Problem'
48
48
  problem.should_receive(:[]).with :line
49
49
  subject.instance_variable_set(:@problems, [problem])
50
50
  end
@@ -1,11 +1,11 @@
1
1
  require 'ripper'
2
- require_relative '../../../../spec_helper'
2
+ require 'spec_helper'
3
3
  require 'tailor/rulers/indentation_spaces_ruler/indentation_manager'
4
4
 
5
5
 
6
6
  describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
7
7
  let!(:spaces) { 5 }
8
- let!(:lexed_line) { double "LexedLine" }
8
+ let!(:lexed_line) { double 'LexedLine' }
9
9
 
10
10
  before do
11
11
  Tailor::Logger.stub(:log)
@@ -16,21 +16,21 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
16
16
  Tailor::Rulers::IndentationSpacesRuler::IndentationManager.new spaces
17
17
  end
18
18
 
19
- describe "#should_be_at" do
20
- it "returns @proper[:this_line]" do
19
+ describe '#should_be_at' do
20
+ it 'returns @proper[:this_line]' do
21
21
  subject.instance_variable_set(:@proper, { this_line: 321 })
22
22
  subject.should_be_at.should == 321
23
23
  end
24
24
  end
25
25
 
26
- describe "#decrease_this_line" do
26
+ describe '#decrease_this_line' do
27
27
  let!(:spaces) { 27 }
28
28
 
29
- context "#started? is true" do
29
+ context '#started? is true' do
30
30
  before { subject.stub(:started?).and_return true }
31
31
 
32
- context "@proper[:this_line] gets decremented < 0" do
33
- it "sets @proper[:this_line] to 0" do
32
+ context '@proper[:this_line] gets decremented < 0' do
33
+ it 'sets @proper[:this_line] to 0' do
34
34
  subject.instance_variable_set(:@proper, {
35
35
  this_line: 0, next_line: 0
36
36
  })
@@ -41,8 +41,8 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
41
41
  end
42
42
  end
43
43
 
44
- context "@proper[:this_line] NOT decremented < 0" do
45
- it "decrements @proper[:this_line] by @spaces" do
44
+ context '@proper[:this_line] NOT decremented < 0' do
45
+ it 'decrements @proper[:this_line] by @spaces' do
46
46
  subject.instance_variable_set(:@proper, {
47
47
  this_line: 28, next_line: 28
48
48
  })
@@ -54,10 +54,10 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
54
54
  end
55
55
  end
56
56
 
57
- context "#started? is false" do
57
+ context '#started? is false' do
58
58
  before { subject.stub(:started?).and_return false }
59
59
 
60
- it "does not decrement @proper[:this_line]" do
60
+ it 'does not decrement @proper[:this_line]' do
61
61
  subject.instance_variable_set(:@proper, {
62
62
  this_line: 28, next_line: 28
63
63
  })
@@ -69,22 +69,22 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
69
69
  end
70
70
  end
71
71
 
72
- describe "#set_up_line_transition" do
73
- context "@amount_to_change_this < 0" do
72
+ describe '#set_up_line_transition' do
73
+ context '@amount_to_change_this < 0' do
74
74
  before { subject.instance_variable_set(:@amount_to_change_this, -1) }
75
75
 
76
- it "should call #decrease_this_line" do
76
+ it 'should call #decrease_this_line' do
77
77
  subject.should_receive(:decrease_this_line)
78
78
  subject.set_up_line_transition
79
79
  end
80
80
  end
81
81
  end
82
82
 
83
- describe "#transition_lines" do
84
- context "#started? is true" do
83
+ describe '#transition_lines' do
84
+ context '#started? is true' do
85
85
  before { subject.stub(:started?).and_return true }
86
86
 
87
- it "sets @proper[:this_line] to @proper[:next_line]" do
87
+ it 'sets @proper[:this_line] to @proper[:next_line]' do
88
88
  subject.instance_variable_set(:@proper, { next_line: 33 })
89
89
 
90
90
  expect { subject.transition_lines }.to change{subject.should_be_at}.
@@ -92,80 +92,80 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
92
92
  end
93
93
  end
94
94
 
95
- context "#started? is false" do
95
+ context '#started? is false' do
96
96
  before { subject.stub(:started?).and_return false }
97
97
 
98
- it "sets @proper[:this_line] to @proper[:next_line]" do
98
+ it 'sets @proper[:this_line] to @proper[:next_line]' do
99
99
  subject.instance_variable_set(:@proper, { next_line: 33 })
100
100
  expect { subject.transition_lines }.to_not change{subject.should_be_at}
101
101
  end
102
102
  end
103
103
  end
104
104
 
105
- describe "#start" do
106
- it "sets @do_measurement to true" do
105
+ describe '#start' do
106
+ it 'sets @do_measurement to true' do
107
107
  subject.instance_variable_set(:@do_measurement, false)
108
108
  subject.start
109
109
  subject.instance_variable_get(:@do_measurement).should be_true
110
110
  end
111
111
  end
112
112
 
113
- describe "#stop" do
114
- it "sets @do_measurement to false" do
113
+ describe '#stop' do
114
+ it 'sets @do_measurement to false' do
115
115
  subject.instance_variable_set(:@do_measurement, true)
116
116
  subject.stop
117
117
  subject.instance_variable_get(:@do_measurement).should be_false
118
118
  end
119
119
  end
120
120
 
121
- describe "#started?" do
122
- context "@do_measurement is true" do
121
+ describe '#started?' do
122
+ context '@do_measurement is true' do
123
123
  before { subject.instance_variable_set(:@do_measurement, true) }
124
124
  specify { subject.started?.should be_true }
125
125
  end
126
126
 
127
- context "@do_measurement is false" do
127
+ context '@do_measurement is false' do
128
128
  before { subject.instance_variable_set(:@do_measurement, false) }
129
129
  specify { subject.started?.should be_false }
130
130
  end
131
131
  end
132
132
 
133
- describe "#update_actual_indentation" do
134
- context "lexed_line_output.end_of_multi_line_string? is true" do
133
+ describe '#update_actual_indentation' do
134
+ context 'lexed_line_output.end_of_multi_line_string? is true' do
135
135
  before do
136
136
  lexed_line.stub(:end_of_multi_line_string?).and_return true
137
137
  end
138
138
 
139
- it "returns without updating @actual_indentation" do
139
+ it 'returns without updating @actual_indentation' do
140
140
  lexed_line.should_not_receive(:first_non_space_element)
141
141
  subject.update_actual_indentation(lexed_line)
142
142
  end
143
143
  end
144
144
 
145
- context "lexed_line_output.end_of_multi_line_string? is false" do
145
+ context 'lexed_line_output.end_of_multi_line_string? is false' do
146
146
  before do
147
147
  lexed_line.stub(:end_of_multi_line_string?).and_return false
148
148
  lexed_line.stub(:first_non_space_element).
149
149
  and_return first_non_space_element
150
150
  end
151
151
 
152
- context "when indented" do
152
+ context 'when indented' do
153
153
  let(:first_non_space_element) do
154
154
  [[1, 5], :on_comma, ',']
155
155
  end
156
156
 
157
- it "returns the column value of that element" do
157
+ it 'returns the column value of that element' do
158
158
  subject.update_actual_indentation(lexed_line)
159
159
  subject.instance_variable_get(:@actual_indentation).should == 5
160
160
  end
161
161
  end
162
162
 
163
- context "when not indented" do
163
+ context 'when not indented' do
164
164
  let(:first_non_space_element) do
165
165
  [[1, 0], :on_kw, 'class']
166
166
  end
167
167
 
168
- it "returns the column value of that element" do
168
+ it 'returns the column value of that element' do
169
169
  subject.update_actual_indentation(lexed_line)
170
170
  subject.instance_variable_get(:@actual_indentation).should == 0
171
171
  end
@@ -173,8 +173,8 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
173
173
  end
174
174
  end
175
175
 
176
- describe "#line_ends_with_single_token_indenter?" do
177
- context "lexed_line doesn't end with an op, comma, period, label, or kw" do
176
+ describe '#line_ends_with_single_token_indenter?' do
177
+ context 'lexed_line does not end with an op, comma, period, label, or kw' do
178
178
  before do
179
179
  lexed_line.stub(ends_with_op?: false)
180
180
  lexed_line.stub(ends_with_comma?: false)
@@ -189,7 +189,7 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
189
189
  end
190
190
  end
191
191
 
192
- context "lexed_line ends with an op" do
192
+ context 'lexed_line ends with an op' do
193
193
  before do
194
194
  lexed_line.stub(ends_with_op?: true)
195
195
  lexed_line.stub(ends_with_comma?: false)
@@ -203,7 +203,7 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
203
203
  end
204
204
  end
205
205
 
206
- context "lexed_line ends with a comma" do
206
+ context 'lexed_line ends with a comma' do
207
207
  before do
208
208
  lexed_line.stub(ends_with_op?: false)
209
209
  lexed_line.stub(ends_with_comma?: true)
@@ -217,7 +217,7 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
217
217
  end
218
218
  end
219
219
 
220
- context "lexed_line ends with a period" do
220
+ context 'lexed_line ends with a period' do
221
221
  before do
222
222
  lexed_line.stub(ends_with_op?: false)
223
223
  lexed_line.stub(ends_with_comma?: false)
@@ -231,7 +231,7 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
231
231
  end
232
232
  end
233
233
 
234
- context "lexed_line ends with a label" do
234
+ context 'lexed_line ends with a label' do
235
235
  before do
236
236
  lexed_line.stub(ends_with_op?: false)
237
237
  lexed_line.stub(ends_with_comma?: false)
@@ -245,7 +245,7 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
245
245
  end
246
246
  end
247
247
 
248
- context "lexed_line ends with a modified kw" do
248
+ context 'lexed_line ends with a modified kw' do
249
249
  before do
250
250
  lexed_line.stub(ends_with_op?: false)
251
251
  lexed_line.stub(ends_with_comma?: false)
@@ -260,18 +260,18 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
260
260
  end
261
261
  end
262
262
 
263
- describe "#line_ends_with_same_as_last" do
264
- context "@indent_reasons is empty" do
263
+ describe '#line_ends_with_same_as_last' do
264
+ context '@indent_reasons is empty' do
265
265
  before do
266
266
  subject.instance_variable_set(:@indent_reasons, [])
267
267
  end
268
268
 
269
- it "returns false" do
269
+ it 'returns false' do
270
270
  subject.line_ends_with_same_as_last([]).should be_false
271
271
  end
272
272
  end
273
273
 
274
- context "@indent_reasons.last[:token] != token_event.last" do
274
+ context '@indent_reasons.last[:token] != token_event.last' do
275
275
  let(:last_single_token) { [[1, 2], :on_comma, ','] }
276
276
 
277
277
  before do
@@ -279,12 +279,12 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
279
279
  [{ event_type: :on_op }])
280
280
  end
281
281
 
282
- it "returns false" do
282
+ it 'returns false' do
283
283
  subject.line_ends_with_same_as_last(last_single_token).should be_false
284
284
  end
285
285
  end
286
286
 
287
- context "@indent_reasons.last[:token] == token_event.last" do
287
+ context '@indent_reasons.last[:token] == token_event.last' do
288
288
  let(:last_single_token) { [[1, 2], :on_comma, ','] }
289
289
 
290
290
  before do
@@ -292,84 +292,84 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
292
292
  [{ event_type: :on_comma }])
293
293
  end
294
294
 
295
- it "returns true" do
295
+ it 'returns true' do
296
296
  subject.line_ends_with_same_as_last(last_single_token).should be_true
297
297
  end
298
298
  end
299
299
  end
300
300
 
301
- describe "#multi_line_parens?" do
302
- context "an unclosed ( exists on the previous line" do
303
- context "an unclosed ( does not exist on the current line" do
301
+ describe '#multi_line_parens?' do
302
+ context 'an unclosed ( exists on the previous line' do
303
+ context 'an unclosed ( does not exist on the current line' do
304
304
  before do
305
305
  d_tokens = [{ token: '(', lineno: 1 }]
306
306
  subject.instance_variable_set(:@indent_reasons, d_tokens)
307
307
  end
308
308
 
309
- it "returns true" do
309
+ it 'returns true' do
310
310
  subject.multi_line_parens?(2).should be_true
311
311
  end
312
312
  end
313
313
 
314
- context "an unclosed ( exists on the current line" do
314
+ context 'an unclosed ( exists on the current line' do
315
315
  before do
316
316
  d_tokens = [{ token: '(', lineno: 1 }, { token: '(', lineno: 2 }]
317
317
  subject.instance_variable_set(:@indent_reasons, d_tokens)
318
318
  end
319
319
 
320
- it "returns true" do
320
+ it 'returns true' do
321
321
  subject.multi_line_parens?(2).should be_false
322
322
  end
323
323
  end
324
324
  end
325
325
 
326
- context "an unclosed ( does not exist on the previous line" do
326
+ context 'an unclosed ( does not exist on the previous line' do
327
327
  before do
328
328
  d_tokens = [{ token: '(', lineno: 1 }]
329
329
  subject.instance_variable_set(:@indent_reasons, d_tokens)
330
330
  end
331
331
 
332
- it "returns true" do
332
+ it 'returns true' do
333
333
  subject.multi_line_parens?(1).should be_false
334
334
  end
335
335
  end
336
336
  end
337
337
 
338
- describe "#last_opening_event" do
339
- context "@indent_reasons is empty" do
338
+ describe '#last_opening_event' do
339
+ context '@indent_reasons is empty' do
340
340
  before { subject.instance_variable_set(:@indent_reasons, []) }
341
341
  specify { subject.last_opening_event(nil).should be_nil }
342
342
  end
343
343
 
344
- context "@indent_reasons contains the corresponding opening event" do
344
+ context '@indent_reasons contains the corresponding opening event' do
345
345
  let(:indent_reasons) do
346
346
  [{ event_type: :on_lparen }, { event_type: :on_lbrace }]
347
347
  end
348
348
 
349
349
  before { subject.instance_variable_set(:@indent_reasons, indent_reasons) }
350
350
 
351
- context "the corresponding opening event is last" do
352
- it "returns the matching opening event" do
351
+ context 'the corresponding opening event is last' do
352
+ it 'returns the matching opening event' do
353
353
  subject.last_opening_event(:on_rbrace).should == indent_reasons.last
354
354
  end
355
355
  end
356
356
 
357
- context "the corresponding opening event is not last" do
358
- it "returns the matching opening event" do
357
+ context 'the corresponding opening event is not last' do
358
+ it 'returns the matching opening event' do
359
359
  subject.last_opening_event(:on_rparen).should == indent_reasons.first
360
360
  end
361
361
  end
362
362
  end
363
363
  end
364
364
 
365
- describe "#remove_continuation_keywords" do
365
+ describe '#remove_continuation_keywords' do
366
366
  before do
367
367
  subject.instance_variable_set(:@indent_reasons, indent_reasons)
368
368
  end
369
369
 
370
- context "@indent_reasons is empty" do
370
+ context '@indent_reasons is empty' do
371
371
  let(:indent_reasons) do
372
- i = double "@indent_reasons"
372
+ i = double '@indent_reasons'
373
373
  i.stub_chain(:last, :[]).and_return []
374
374
  i.stub(:empty?).and_return true
375
375
 
@@ -379,27 +379,27 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
379
379
  specify { subject.remove_continuation_keywords.should be_nil }
380
380
  end
381
381
 
382
- context "@indent_reasons does not contain CONTINUATION_KEYWORDS" do
382
+ context '@indent_reasons does not contain CONTINUATION_KEYWORDS' do
383
383
  let(:indent_reasons) do
384
- i = double "@indent_reasons"
384
+ i = double '@indent_reasons'
385
385
  i.stub_chain(:last, :[]).and_return [{ token: 'if' }]
386
386
  i.stub(:empty?).and_return false
387
387
 
388
388
  i
389
389
  end
390
390
 
391
- it "should not call #pop on @indent_reasons" do
391
+ it 'should not call #pop on @indent_reasons' do
392
392
  indent_reasons.should_not_receive(:pop)
393
393
  subject.remove_continuation_keywords
394
394
  end
395
395
  end
396
396
 
397
- context "@indent_reasons contains CONTINUATION_KEYWORDS" do
397
+ context '@indent_reasons contains CONTINUATION_KEYWORDS' do
398
398
  let(:indent_reasons) do
399
399
  [{ token: 'if' }, { token: 'elsif' }]
400
400
  end
401
401
 
402
- it "should call #pop on @indent_reasons one time" do
402
+ it 'should call #pop on @indent_reasons one time' do
403
403
  subject.instance_variable_set(:@indent_reasons, indent_reasons)
404
404
  subject.remove_continuation_keywords
405
405
  subject.instance_variable_get(:@indent_reasons).should ==