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
@@ -3,7 +3,7 @@ require 'tailor/lexer/token'
3
3
 
4
4
  describe Tailor::Lexer::Token do
5
5
  before do
6
- Tailor::Logger.stub(:log)
6
+ allow(Tailor::Logger).to receive(:log)
7
7
  end
8
8
 
9
9
  describe '#modifier_keyword?' do
@@ -14,24 +14,24 @@ describe Tailor::Lexer::Token do
14
14
 
15
15
  context 'the current line has a keyword that is also a modifier' do
16
16
  context 'the keyword is acting as a modifier' do
17
- let!(:full_line_of_text) { %q{puts "hi" if true == true} }
17
+ let!(:full_line_of_text) { %(puts "hi" if true == true) }
18
18
 
19
19
  it 'returns true' do
20
- subject.modifier_keyword?.should be_true
20
+ expect(subject.modifier_keyword?).to eq true
21
21
  end
22
22
  end
23
23
 
24
24
  context 'they keyword is NOT acting as a modifier' do
25
- let!(:full_line_of_text) { %q{if true == true; puts "hi"; end} }
25
+ let!(:full_line_of_text) { %(if true == true; puts "hi"; end) }
26
26
 
27
27
  it 'returns false' do
28
- subject.modifier_keyword?.should be_false
28
+ expect(subject.modifier_keyword?).to eq false
29
29
  end
30
30
  end
31
31
  end
32
32
 
33
33
  context 'the current line does not have a keyword' do
34
- let!(:full_line_of_text) { %q{puts true} }
34
+ let!(:full_line_of_text) { %(puts true) }
35
35
 
36
36
  subject do
37
37
  options = { full_line_of_text: full_line_of_text }
@@ -39,7 +39,7 @@ describe Tailor::Lexer::Token do
39
39
  end
40
40
 
41
41
  it 'returns false' do
42
- subject.modifier_keyword?.should be_false
42
+ expect(subject.modifier_keyword?).to eq false
43
43
  end
44
44
  end
45
45
  end
@@ -9,13 +9,13 @@ describe Tailor::Lexer do
9
9
  subject do
10
10
  r = Tailor::Lexer.new(file_text)
11
11
  r.instance_variable_set(:@buf, [])
12
- r.stub(:log)
12
+ allow(r).to receive(:log)
13
13
 
14
14
  r
15
15
  end
16
16
 
17
17
  before do
18
- Tailor::Lexer.any_instance.stub(:ensure_trailing_newline).
18
+ allow_any_instance_of(Tailor::Lexer).to receive(:ensure_trailing_newline).
19
19
  and_return(file_text)
20
20
  end
21
21
 
@@ -29,8 +29,8 @@ describe Tailor::Lexer do
29
29
 
30
30
  it 'opens and reads the file by the name passed in' do
31
31
  file = double 'File'
32
- file.should_receive(:read).and_return file_text
33
- File.should_receive(:open).with('test', 'r').and_return file
32
+ expect(file).to receive(:read).and_return file_text
33
+ expect(File).to receive(:open).with('test', 'r').and_return file
34
34
  Tailor::Lexer.new(file_name)
35
35
  end
36
36
  end
@@ -39,7 +39,7 @@ describe Tailor::Lexer do
39
39
  let(:text) { 'some text' }
40
40
 
41
41
  it 'does not try to open a file' do
42
- File.should_not_receive(:open)
42
+ expect(File).to_not receive(:open)
43
43
  Tailor::Lexer.new(text)
44
44
  end
45
45
  end
@@ -48,7 +48,7 @@ describe Tailor::Lexer do
48
48
  describe '#on_sp' do
49
49
  context 'token is a backslash then newline' do
50
50
  it 'calls #notify_ignored_nl_observers' do
51
- subject.should_receive(:notify_ignored_nl_observers)
51
+ expect(subject).to receive(:notify_ignored_nl_observers)
52
52
  subject.on_sp("\\\n")
53
53
  end
54
54
  end
@@ -57,43 +57,43 @@ describe Tailor::Lexer do
57
57
  describe '#current_line_of_text' do
58
58
  before do
59
59
  subject.instance_variable_set(:@file_text, file_text)
60
- subject.stub(:lineno).and_return 1
60
+ allow(subject).to receive(:lineno).and_return 1
61
61
  end
62
62
 
63
- context "@file_text is 1 line with 0 \\ns" do
63
+ context '@file_text is 1 line with 0 \ns' do
64
64
  let(:file_text) { "puts 'code'" }
65
65
 
66
66
  it 'returns the line' do
67
- subject.current_line_of_text.should == file_text
67
+ expect(subject.current_line_of_text).to eq file_text
68
68
  end
69
69
  end
70
70
 
71
- context "@file_text is 1 empty line with 0 \\ns" do
71
+ context '@file_text is 1 empty line with 0 \ns' do
72
72
  let(:file_text) { '' }
73
73
 
74
74
  it 'returns the an empty string' do
75
- subject.current_line_of_text.should == file_text
75
+ expect(subject.current_line_of_text).to eq file_text
76
76
  end
77
77
  end
78
78
 
79
- context "@file_text is 1 empty line with 1 \\n" do
79
+ context '@file_text is 1 empty line with 1 \n' do
80
80
  let(:file_text) { "\n" }
81
81
 
82
82
  it 'returns an empty string' do
83
- subject.current_line_of_text.should == ''
83
+ expect(subject.current_line_of_text).to eq ''
84
84
  end
85
85
  end
86
86
  end
87
87
 
88
88
  describe '#count_trailing_newlines' do
89
- context "text contains 0 trailing \\n" do
89
+ context 'text contains 0 trailing \n' do
90
90
  let(:text) { 'text' }
91
- specify { subject.count_trailing_newlines(text).should be_zero }
91
+ specify { expect(subject.count_trailing_newlines(text)).to be_zero }
92
92
  end
93
93
 
94
- context "text contains 1 trailing \\n" do
94
+ context 'text contains 1 trailing \n' do
95
95
  let(:text) { "text\n" }
96
- specify { subject.count_trailing_newlines(text).should == 1 }
96
+ specify { expect(subject.count_trailing_newlines(text)).to eq 1 }
97
97
  end
98
98
  end
99
99
 
@@ -106,11 +106,11 @@ describe Tailor::Lexer do
106
106
  let!(:text) { "text\n" }
107
107
 
108
108
  before do
109
- subject.stub(:count_trailing_newlines).and_return 1
109
+ allow(subject).to receive(:count_trailing_newlines).and_return 1
110
110
  end
111
111
 
112
112
  it 'does not alter the text' do
113
- subject.ensure_trailing_newline(text).should == text
113
+ expect(subject.ensure_trailing_newline(text)).to eq text
114
114
  end
115
115
  end
116
116
 
@@ -118,15 +118,15 @@ describe Tailor::Lexer do
118
118
  let!(:text) { 'text' }
119
119
 
120
120
  it 'adds a newline at the end' do
121
- subject.ensure_trailing_newline(text).should == text + "\n"
121
+ expect(subject.ensure_trailing_newline(text)).to eq(text + "\n")
122
122
  end
123
123
  end
124
124
  end
125
125
 
126
126
  describe '#sub_line_ending_backslashes' do
127
127
  let!(:text) do
128
- %Q{command \\
129
- 'something'}
128
+ %(command \\
129
+ 'something')
130
130
  end
131
131
 
132
132
  before do
@@ -136,8 +136,8 @@ describe Tailor::Lexer do
136
136
  end
137
137
 
138
138
  it 'replaces all line-ending backslashes with a comment' do
139
- subject.sub_publicly(text).should == %Q{command # TAILOR REMOVED BACKSLASH
140
- 'something'}
139
+ expect(subject.sub_publicly(text)).to eq %(command # TAILOR REMOVED BACKSLASH
140
+ 'something')
141
141
  end
142
142
  end
143
143
  end
@@ -3,7 +3,7 @@ require 'tailor/problem'
3
3
 
4
4
  describe Tailor::Problem do
5
5
  before do
6
- Tailor::Problem.any_instance.stub(:log)
6
+ allow_any_instance_of(Tailor::Problem).to receive(:log)
7
7
  end
8
8
 
9
9
  let(:lineno) { 10 }
@@ -11,32 +11,32 @@ describe Tailor::Problem do
11
11
 
12
12
  describe '#set_values' do
13
13
  before do
14
- Tailor::Problem.any_instance.stub(:message)
14
+ allow_any_instance_of(Tailor::Problem).to receive(:message)
15
15
  end
16
16
 
17
17
  it 'sets self[:type] to the type param' do
18
- Tailor::Problem.new(:test, lineno, column, '', :b).
19
- should include(type: :test)
18
+ expect(Tailor::Problem.new(:test, lineno, column, '', :b)).
19
+ to include(type: :test)
20
20
  end
21
21
 
22
22
  it 'sets self[:line] to the lineno param' do
23
- Tailor::Problem.new(:test, lineno, column, '', :c).
24
- should include(line: lineno)
23
+ expect(Tailor::Problem.new(:test, lineno, column, '', :c)).
24
+ to include(line: lineno)
25
25
  end
26
26
 
27
27
  it 'sets self[:column] to the column param' do
28
- Tailor::Problem.new(:test, lineno, column, '', :d).
29
- should include(column: column)
28
+ expect(Tailor::Problem.new(:test, lineno, column, '', :d)).
29
+ to include(column: column)
30
30
  end
31
31
 
32
32
  it 'sets self[:message] to the message param' do
33
- Tailor::Problem.new(:test, lineno, column, 'test', :d).
34
- should include(message: 'test')
33
+ expect(Tailor::Problem.new(:test, lineno, column, 'test', :d)).
34
+ to include(message: 'test')
35
35
  end
36
36
 
37
37
  it 'sets self[:level] to the level param' do
38
- Tailor::Problem.new(:test, lineno, column, 'test', :d).
39
- should include(level: :d)
38
+ expect(Tailor::Problem.new(:test, lineno, column, 'test', :d)).
39
+ to include(level: :d)
40
40
  end
41
41
  end
42
42
  end
@@ -8,7 +8,7 @@ describe Tailor::Reporter do
8
8
 
9
9
  it 'creates a new Formatter object of the type passed in' do
10
10
  reporter = Tailor::Reporter.new(formats)
11
- reporter.formatters.first.should be_a Tailor::Formatters::Text
11
+ expect(reporter.formatters.first).to be_a Tailor::Formatters::Text
12
12
  end
13
13
  end
14
14
  end
@@ -26,7 +26,7 @@ describe Tailor::Reporter do
26
26
 
27
27
  it 'calls #file_report on each @formatters' do
28
28
  label = :some_label
29
- formatter.should_receive(:file_report).with(file_problems, label)
29
+ expect(formatter).to receive(:file_report).with(file_problems, label)
30
30
 
31
31
  subject.file_report(file_problems, label)
32
32
  end
@@ -45,8 +45,8 @@ describe Tailor::Reporter do
45
45
 
46
46
  context 'without output file' do
47
47
  it 'calls #file_report on each @formatters' do
48
- formatter.should_receive(:summary_report).with(all_problems)
49
- File.should_not_receive(:open)
48
+ expect(formatter).to receive(:summary_report).with(all_problems)
49
+ expect(File).to_not receive(:open)
50
50
 
51
51
  subject.summary_report(all_problems)
52
52
  end
@@ -55,18 +55,17 @@ describe Tailor::Reporter do
55
55
  context 'with output file' do
56
56
  let(:output_file) { 'output.whatever' }
57
57
  before do
58
- formatter.should_receive(:respond_to?).with(:accepts_output_file).
58
+ expect(formatter).to receive(:respond_to?).with(:accepts_output_file).
59
59
  and_return(true)
60
- formatter.should_receive(:accepts_output_file).and_return(true)
60
+ expect(formatter).to receive(:accepts_output_file).and_return(true)
61
61
  end
62
62
 
63
63
  it 'calls #summary_report on each @formatters' do
64
- formatter.should_receive(:summary_report).with(all_problems)
65
- File.should_receive(:open).with(output_file, 'w')
64
+ expect(formatter).to receive(:summary_report).with(all_problems)
65
+ expect(File).to receive(:open).with(output_file, 'w')
66
66
 
67
67
  subject.summary_report(all_problems, output_file: output_file)
68
68
  end
69
69
  end
70
-
71
70
  end
72
71
  end
@@ -2,54 +2,54 @@ require 'spec_helper'
2
2
  require 'tailor/ruler'
3
3
 
4
4
  describe Tailor::Ruler do
5
- before { Tailor::Logger.stub(:log) }
5
+ before { allow(Tailor::Logger).to receive(:log) }
6
6
 
7
7
  describe '#add_child_ruler' do
8
8
  it 'adds new rulers to @child_rulers' do
9
9
  ruler = double 'Ruler'
10
10
  subject.add_child_ruler(ruler)
11
- subject.instance_variable_get(:@child_rulers).first.should == ruler
11
+ expect(subject.instance_variable_get(:@child_rulers).first).to eq ruler
12
12
  end
13
13
  end
14
14
 
15
15
  describe '#problems' do
16
16
  context 'no child_rulers' do
17
17
  context '@problems is empty' do
18
- specify { subject.problems.should be_empty }
18
+ specify { expect(subject.problems).to be_empty }
19
19
  end
20
20
 
21
21
  context '@problems.size is 1' do
22
22
  before do
23
23
  problem = double 'Problem'
24
- problem.should_receive(:[]).with :line
24
+ expect(problem).to receive(:[]).with :line
25
25
  subject.instance_variable_set(:@problems, [problem])
26
26
  end
27
27
 
28
- specify { subject.problems.size.should == 1 }
28
+ specify { expect(subject.problems.size).to eq 1 }
29
29
  end
30
30
  end
31
31
 
32
32
  context 'child_rulers have problems' do
33
33
  before do
34
34
  problem = double 'Problem'
35
- problem.should_receive(:[]).with :line
35
+ expect(problem).to receive(:[]).with :line
36
36
  child_ruler = double 'Ruler'
37
- child_ruler.stub(:problems).and_return([problem])
37
+ allow(child_ruler).to receive(:problems).and_return([problem])
38
38
  subject.instance_variable_set(:@child_rulers, [child_ruler])
39
39
  end
40
40
 
41
41
  context '@problems is empty' do
42
- specify { subject.problems.size.should == 1 }
42
+ specify { expect(subject.problems.size).to eq 1 }
43
43
  end
44
44
 
45
45
  context '@problems.size is 1' do
46
46
  before do
47
47
  problem = double 'Problem'
48
- problem.should_receive(:[]).with :line
48
+ expect(problem).to receive(:[]).with :line
49
49
  subject.instance_variable_set(:@problems, [problem])
50
50
  end
51
51
 
52
- specify { subject.problems.size.should == 2 }
52
+ specify { expect(subject.problems.size).to eq 2 }
53
53
  end
54
54
  end
55
55
  end
@@ -2,13 +2,12 @@ require 'ripper'
2
2
  require 'spec_helper'
3
3
  require 'tailor/rulers/indentation_spaces_ruler/indentation_manager'
4
4
 
5
-
6
5
  describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
7
6
  let!(:spaces) { 5 }
8
7
  let!(:lexed_line) { double 'LexedLine' }
9
8
 
10
9
  before do
11
- Tailor::Logger.stub(:log)
10
+ allow(Tailor::Logger).to receive(:log)
12
11
  subject.instance_variable_set(:@spaces, spaces)
13
12
  end
14
13
 
@@ -18,8 +17,8 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
18
17
 
19
18
  describe '#should_be_at' do
20
19
  it 'returns @proper[:this_line]' do
21
- subject.instance_variable_set(:@proper, { this_line: 321 })
22
- subject.should_be_at.should == 321
20
+ subject.instance_variable_set(:@proper, this_line: 321)
21
+ expect(subject.should_be_at).to eq 321
23
22
  end
24
23
  end
25
24
 
@@ -27,66 +26,61 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
27
26
  let!(:spaces) { 27 }
28
27
 
29
28
  context '#started? is true' do
30
- before { subject.stub(:started?).and_return true }
29
+ before { allow(subject).to receive(:started?).and_return true }
31
30
 
32
31
  context '@proper[:this_line] gets decremented < 0' do
33
32
  it 'sets @proper[:this_line] to 0' do
34
- subject.instance_variable_set(:@proper, {
35
- this_line: 0, next_line: 0
36
- })
33
+ subject.instance_variable_set(:@proper, this_line: 0, next_line: 0)
37
34
 
38
35
  subject.decrease_this_line
39
36
  proper_indentation = subject.instance_variable_get(:@proper)
40
- proper_indentation[:this_line].should == 0
37
+ expect(proper_indentation[:this_line]).to be_zero
41
38
  end
42
39
  end
43
40
 
44
41
  context '@proper[:this_line] NOT decremented < 0' do
45
42
  it 'decrements @proper[:this_line] by @spaces' do
46
- subject.instance_variable_set(:@proper, {
47
- this_line: 28, next_line: 28
48
- })
43
+ subject.instance_variable_set(:@proper, this_line: 28, next_line: 28)
49
44
  subject.decrease_this_line
50
45
 
51
46
  proper_indentation = subject.instance_variable_get(:@proper)
52
- proper_indentation[:this_line].should == 1
47
+ expect(proper_indentation[:this_line]).to eq 1
53
48
  end
54
49
  end
55
50
  end
56
51
 
57
52
  context '#started? is false' do
58
- before { subject.stub(:started?).and_return false }
53
+ before { allow(subject).to receive(:started?).and_return false }
59
54
 
60
55
  it 'does not decrement @proper[:this_line]' do
61
- subject.instance_variable_set(:@proper, {
62
- this_line: 28, next_line: 28
63
- })
56
+ subject.instance_variable_set(:@proper, this_line: 28, next_line: 28)
64
57
  subject.decrease_this_line
65
58
 
66
59
  proper_indentation = subject.instance_variable_get(:@proper)
67
- proper_indentation[:this_line].should == 28
60
+ expect(proper_indentation[:this_line]).to eq 28
68
61
  end
69
62
  end
70
63
  end
71
64
 
72
65
  describe '#transition_lines' do
73
66
  context '#started? is true' do
74
- before { subject.stub(:started?).and_return true }
67
+ before { allow(subject).to receive(:started?).and_return true }
75
68
 
76
69
  it 'sets @proper[:this_line] to @proper[:next_line]' do
77
- subject.instance_variable_set(:@proper, { next_line: 33 })
70
+ subject.instance_variable_set(:@proper, next_line: 33)
78
71
 
79
- expect { subject.transition_lines }.to change{subject.should_be_at}.
72
+ expect { subject.transition_lines }.to change { subject.should_be_at }.
80
73
  from(subject.should_be_at).to(33)
81
74
  end
82
75
  end
83
76
 
84
77
  context '#started? is false' do
85
- before { subject.stub(:started?).and_return false }
78
+ before { allow(subject).to receive(:started?).and_return false }
86
79
 
87
80
  it 'sets @proper[:this_line] to @proper[:next_line]' do
88
- subject.instance_variable_set(:@proper, { next_line: 33 })
89
- expect { subject.transition_lines }.to_not change{subject.should_be_at}
81
+ subject.instance_variable_set(:@proper, next_line: 33)
82
+ expect { subject.transition_lines }.
83
+ to_not change { subject.should_be_at }
90
84
  end
91
85
  end
92
86
  end
@@ -95,7 +89,7 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
95
89
  it 'sets @do_measurement to true' do
96
90
  subject.instance_variable_set(:@do_measurement, false)
97
91
  subject.start
98
- subject.instance_variable_get(:@do_measurement).should be_true
92
+ expect(subject.instance_variable_get(:@do_measurement)).to eq true
99
93
  end
100
94
  end
101
95
 
@@ -103,38 +97,39 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
103
97
  it 'sets @do_measurement to false' do
104
98
  subject.instance_variable_set(:@do_measurement, true)
105
99
  subject.stop
106
- subject.instance_variable_get(:@do_measurement).should be_false
100
+ expect(subject.instance_variable_get(:@do_measurement)).to eq false
107
101
  end
108
102
  end
109
103
 
110
104
  describe '#started?' do
111
105
  context '@do_measurement is true' do
112
106
  before { subject.instance_variable_set(:@do_measurement, true) }
113
- specify { subject.started?.should be_true }
107
+ specify { expect(subject).to be_started }
114
108
  end
115
109
 
116
110
  context '@do_measurement is false' do
117
111
  before { subject.instance_variable_set(:@do_measurement, false) }
118
- specify { subject.started?.should be_false }
112
+ specify { expect(subject).to_not be_started }
119
113
  end
120
114
  end
121
115
 
122
116
  describe '#update_actual_indentation' do
123
117
  context 'lexed_line_output.end_of_multi_line_string? is true' do
124
118
  before do
125
- lexed_line.stub(:end_of_multi_line_string?).and_return true
119
+ allow(lexed_line).to receive(:end_of_multi_line_string?).and_return true
126
120
  end
127
121
 
128
122
  it 'returns without updating @actual_indentation' do
129
- lexed_line.should_not_receive(:first_non_space_element)
123
+ expect(lexed_line).to_not receive(:first_non_space_element)
130
124
  subject.update_actual_indentation(lexed_line)
131
125
  end
132
126
  end
133
127
 
134
128
  context 'lexed_line_output.end_of_multi_line_string? is false' do
135
129
  before do
136
- lexed_line.stub(:end_of_multi_line_string?).and_return false
137
- lexed_line.stub(:first_non_space_element).
130
+ allow(lexed_line).to receive(:end_of_multi_line_string?).
131
+ and_return false
132
+ allow(lexed_line).to receive(:first_non_space_element).
138
133
  and_return first_non_space_element
139
134
  end
140
135
 
@@ -145,7 +140,7 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
145
140
 
146
141
  it 'returns the column value of that element' do
147
142
  subject.update_actual_indentation(lexed_line)
148
- subject.instance_variable_get(:@actual_indentation).should == 5
143
+ expect(subject.instance_variable_get(:@actual_indentation)).to eq 5
149
144
  end
150
145
  end
151
146
 
@@ -156,7 +151,7 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
156
151
 
157
152
  it 'returns the column value of that element' do
158
153
  subject.update_actual_indentation(lexed_line)
159
- subject.instance_variable_get(:@actual_indentation).should == 0
154
+ expect(subject.instance_variable_get(:@actual_indentation)).to be_zero
160
155
  end
161
156
  end
162
157
  end
@@ -165,86 +160,91 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
165
160
  describe '#line_ends_with_single_token_indenter?' do
166
161
  context 'lexed_line does not end with an op, comma, period, label, or kw' do
167
162
  before do
168
- lexed_line.stub(ends_with_op?: false)
169
- lexed_line.stub(ends_with_comma?: false)
170
- lexed_line.stub(ends_with_period?: false)
171
- lexed_line.stub(ends_with_label?: false)
172
- lexed_line.stub(ends_with_modifier_kw?: false)
163
+ allow(lexed_line).to receive(:ends_with_op?).and_return false
164
+ allow(lexed_line).to receive(:ends_with_comma?).and_return false
165
+ allow(lexed_line).to receive(:ends_with_period?).and_return false
166
+ allow(lexed_line).to receive(:ends_with_label?).and_return false
167
+ allow(lexed_line).to receive(:ends_with_modifier_kw?).and_return false
173
168
  end
174
169
 
175
170
  specify do
176
- subject.line_ends_with_single_token_indenter?(lexed_line).
177
- should be_false
171
+ expect(subject.line_ends_with_single_token_indenter?(lexed_line)).
172
+ to eq false
178
173
  end
179
174
  end
180
175
 
181
176
  context 'lexed_line ends with an op' do
182
177
  before do
183
- lexed_line.stub(ends_with_op?: true)
184
- lexed_line.stub(ends_with_comma?: false)
185
- lexed_line.stub(ends_with_period?: false)
186
- lexed_line.stub(ends_with_label?: false)
187
- lexed_line.stub(ends_with_modifier_kw?: false)
178
+ allow(lexed_line).to receive(:ends_with_op?).and_return true
179
+ allow(lexed_line).to receive(:ends_with_comma?).and_return false
180
+ allow(lexed_line).to receive(:ends_with_period?).and_return false
181
+ allow(lexed_line).to receive(:ends_with_label?).and_return false
182
+ allow(lexed_line).to receive(:ends_with_modifier_kw?).and_return false
188
183
  end
189
184
 
190
185
  specify do
191
- subject.line_ends_with_single_token_indenter?(lexed_line).should be_true
186
+ expect(subject.line_ends_with_single_token_indenter?(lexed_line)).
187
+ to eq true
192
188
  end
193
189
  end
194
190
 
195
191
  context 'lexed_line ends with a comma' do
196
192
  before do
197
- lexed_line.stub(ends_with_op?: false)
198
- lexed_line.stub(ends_with_comma?: true)
199
- lexed_line.stub(ends_with_period?: false)
200
- lexed_line.stub(ends_with_label?: false)
201
- lexed_line.stub(ends_with_modifier_kw?: false)
193
+ allow(lexed_line).to receive(:ends_with_op?).and_return false
194
+ allow(lexed_line).to receive(:ends_with_comma?).and_return true
195
+ allow(lexed_line).to receive(:ends_with_period?).and_return false
196
+ allow(lexed_line).to receive(:ends_with_label?).and_return false
197
+ allow(lexed_line).to receive(:ends_with_modifier_kw?).and_return false
202
198
  end
203
199
 
204
200
  specify do
205
- subject.line_ends_with_single_token_indenter?(lexed_line).should be_true
201
+ expect(subject.line_ends_with_single_token_indenter?(lexed_line)).
202
+ to eq true
206
203
  end
207
204
  end
208
205
 
209
206
  context 'lexed_line ends with a period' do
210
207
  before do
211
- lexed_line.stub(ends_with_op?: false)
212
- lexed_line.stub(ends_with_comma?: false)
213
- lexed_line.stub(ends_with_period?: true)
214
- lexed_line.stub(ends_with_label?: false)
215
- lexed_line.stub(ends_with_modifier_kw?: false)
208
+ allow(lexed_line).to receive(:ends_with_op?).and_return false
209
+ allow(lexed_line).to receive(:ends_with_comma?).and_return false
210
+ allow(lexed_line).to receive(:ends_with_period?).and_return true
211
+ allow(lexed_line).to receive(:ends_with_label?).and_return false
212
+ allow(lexed_line).to receive(:ends_with_modifier_kw?).and_return false
216
213
  end
217
214
 
218
215
  specify do
219
- subject.line_ends_with_single_token_indenter?(lexed_line).should be_true
216
+ expect(subject.line_ends_with_single_token_indenter?(lexed_line)).
217
+ to eq true
220
218
  end
221
219
  end
222
220
 
223
221
  context 'lexed_line ends with a label' do
224
222
  before do
225
- lexed_line.stub(ends_with_op?: false)
226
- lexed_line.stub(ends_with_comma?: false)
227
- lexed_line.stub(ends_with_period?: false)
228
- lexed_line.stub(ends_with_label?: true)
229
- lexed_line.stub(ends_with_modifier_kw?: false)
223
+ allow(lexed_line).to receive(:ends_with_op?).and_return false
224
+ allow(lexed_line).to receive(:ends_with_comma?).and_return false
225
+ allow(lexed_line).to receive(:ends_with_period?).and_return false
226
+ allow(lexed_line).to receive(:ends_with_label?).and_return true
227
+ allow(lexed_line).to receive(:ends_with_modifier_kw?).and_return false
230
228
  end
231
229
 
232
230
  specify do
233
- subject.line_ends_with_single_token_indenter?(lexed_line).should be_true
231
+ expect(subject.line_ends_with_single_token_indenter?(lexed_line)).
232
+ to eq true
234
233
  end
235
234
  end
236
235
 
237
236
  context 'lexed_line ends with a modified kw' do
238
237
  before do
239
- lexed_line.stub(ends_with_op?: false)
240
- lexed_line.stub(ends_with_comma?: false)
241
- lexed_line.stub(ends_with_period?: false)
242
- lexed_line.stub(ends_with_label?: false)
243
- lexed_line.stub(ends_with_modifier_kw?: true)
238
+ allow(lexed_line).to receive(:ends_with_op?).and_return false
239
+ allow(lexed_line).to receive(:ends_with_comma?).and_return false
240
+ allow(lexed_line).to receive(:ends_with_period?).and_return false
241
+ allow(lexed_line).to receive(:ends_with_label?).and_return false
242
+ allow(lexed_line).to receive(:ends_with_modifier_kw?).and_return true
244
243
  end
245
244
 
246
245
  specify do
247
- subject.line_ends_with_single_token_indenter?(lexed_line).should be_true
246
+ expect(subject.line_ends_with_single_token_indenter?(lexed_line)).
247
+ to eq true
248
248
  end
249
249
  end
250
250
  end
@@ -256,7 +256,7 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
256
256
  end
257
257
 
258
258
  it 'returns false' do
259
- subject.line_ends_with_same_as_last([]).should be_false
259
+ expect(subject.line_ends_with_same_as_last([])).to eq false
260
260
  end
261
261
  end
262
262
 
@@ -269,7 +269,8 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
269
269
  end
270
270
 
271
271
  it 'returns false' do
272
- subject.line_ends_with_same_as_last(last_single_token).should be_false
272
+ expect(subject.line_ends_with_same_as_last(last_single_token)).
273
+ to eq false
273
274
  end
274
275
  end
275
276
 
@@ -282,7 +283,8 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
282
283
  end
283
284
 
284
285
  it 'returns true' do
285
- subject.line_ends_with_same_as_last(last_single_token).should be_true
286
+ expect(subject.line_ends_with_same_as_last(last_single_token)).
287
+ to eq true
286
288
  end
287
289
  end
288
290
  end
@@ -296,7 +298,7 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
296
298
  end
297
299
 
298
300
  it 'returns true' do
299
- subject.multi_line_parens?(2).should be_true
301
+ expect(subject.multi_line_parens?(2)).to eq true
300
302
  end
301
303
  end
302
304
 
@@ -306,8 +308,8 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
306
308
  subject.instance_variable_set(:@indent_reasons, d_tokens)
307
309
  end
308
310
 
309
- it 'returns true' do
310
- subject.multi_line_parens?(2).should be_false
311
+ it 'returns false' do
312
+ expect(subject.multi_line_parens?(2)).to eq false
311
313
  end
312
314
  end
313
315
  end
@@ -318,8 +320,8 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
318
320
  subject.instance_variable_set(:@indent_reasons, d_tokens)
319
321
  end
320
322
 
321
- it 'returns true' do
322
- subject.multi_line_parens?(1).should be_false
323
+ it 'returns false' do
324
+ expect(subject.multi_line_parens?(1)).to eq false
323
325
  end
324
326
  end
325
327
  end
@@ -327,7 +329,7 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
327
329
  describe '#last_opening_event' do
328
330
  context '@indent_reasons is empty' do
329
331
  before { subject.instance_variable_set(:@indent_reasons, []) }
330
- specify { subject.last_opening_event(nil).should be_nil }
332
+ specify { expect(subject.last_opening_event(nil)).to be_nil }
331
333
  end
332
334
 
333
335
  context '@indent_reasons contains the corresponding opening event' do
@@ -339,13 +341,15 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
339
341
 
340
342
  context 'the corresponding opening event is last' do
341
343
  it 'returns the matching opening event' do
342
- subject.last_opening_event(:on_rbrace).should == indent_reasons.last
344
+ expect(subject.last_opening_event(:on_rbrace)).
345
+ to eq indent_reasons.last
343
346
  end
344
347
  end
345
348
 
346
349
  context 'the corresponding opening event is not last' do
347
350
  it 'returns the matching opening event' do
348
- subject.last_opening_event(:on_rparen).should == indent_reasons.first
351
+ expect(subject.last_opening_event(:on_rparen)).
352
+ to eq indent_reasons.first
349
353
  end
350
354
  end
351
355
  end
@@ -365,7 +369,7 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
365
369
  i
366
370
  end
367
371
 
368
- specify { subject.remove_continuation_keywords.should be_nil }
372
+ specify { expect(subject.remove_continuation_keywords).to be_nil }
369
373
  end
370
374
 
371
375
  context '@indent_reasons does not contain CONTINUATION_KEYWORDS' do
@@ -378,7 +382,7 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
378
382
  end
379
383
 
380
384
  it 'should not call #pop on @indent_reasons' do
381
- indent_reasons.should_not_receive(:pop)
385
+ expect(indent_reasons).to_not receive(:pop)
382
386
  subject.remove_continuation_keywords
383
387
  end
384
388
  end
@@ -391,8 +395,8 @@ describe Tailor::Rulers::IndentationSpacesRuler::IndentationManager do
391
395
  it 'should call #pop on @indent_reasons one time' do
392
396
  subject.instance_variable_set(:@indent_reasons, indent_reasons)
393
397
  subject.remove_continuation_keywords
394
- subject.instance_variable_get(:@indent_reasons).should ==
395
- [{ token: 'if' }]
398
+ expect(subject.instance_variable_get(:@indent_reasons)).
399
+ to eq [{ token: 'if' }]
396
400
  end
397
401
  end
398
402
  end