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/critic'
3
3
  require 'tailor/configuration/style'
4
4
 
@@ -14,7 +14,7 @@ CAMEL_CASE_METHODS['one_caps_camel_case_method_trailing_comment'] =
14
14
  end}
15
15
 
16
16
 
17
- describe "Detection of camel case methods" do
17
+ describe 'Detection of camel case methods' do
18
18
  before do
19
19
  Tailor::Logger.stub(:log)
20
20
  FakeFS.activate!
@@ -36,19 +36,19 @@ describe "Detection of camel case methods" do
36
36
  style
37
37
  end
38
38
 
39
- context "standard camel case method" do
39
+ context 'standard camel case method' do
40
40
  let(:file_name) { 'one_caps_camel_case_method' }
41
41
  specify { critic.problems[file_name].size.should be 1 }
42
- specify { critic.problems[file_name].first[:type].should == "allow_camel_case_methods" }
42
+ specify { critic.problems[file_name].first[:type].should == 'allow_camel_case_methods' }
43
43
  specify { critic.problems[file_name].first[:line].should be 1 }
44
44
  specify { critic.problems[file_name].first[:column].should be 4 }
45
45
  specify { critic.problems[file_name].first[:level].should be :error }
46
46
  end
47
47
 
48
- context "standard camel case method, trailing comment" do
48
+ context 'standard camel case method, trailing comment' do
49
49
  let(:file_name) { 'one_caps_camel_case_method_trailing_comment' }
50
50
  specify { critic.problems[file_name].size.should be 1 }
51
- specify { critic.problems[file_name].first[:type].should == "allow_camel_case_methods" }
51
+ specify { critic.problems[file_name].first[:type].should == 'allow_camel_case_methods' }
52
52
  specify { critic.problems[file_name].first[:line].should be 1 }
53
53
  specify { critic.problems[file_name].first[:column].should be 4 }
54
54
  specify { critic.problems[file_name].first[:level].should be :error }
@@ -1,4 +1,4 @@
1
- require_relative '../../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'tailor/critic'
3
3
  require 'tailor/configuration/style'
4
4
 
@@ -23,7 +23,7 @@ end}
23
23
 
24
24
 
25
25
 
26
- describe "Detection of camel case methods" do
26
+ describe 'Detection of camel case methods' do
27
27
  before do
28
28
  Tailor::Logger.stub(:log)
29
29
  FakeFS.activate!
@@ -45,37 +45,37 @@ describe "Detection of camel case methods" do
45
45
  style
46
46
  end
47
47
 
48
- context "standard screaming snake case class" do
48
+ context 'standard screaming snake case class' do
49
49
  let(:file_name) { 'one_screaming_snake_case_class' }
50
50
  specify { critic.problems[file_name].size.should be 1 }
51
- specify { critic.problems[file_name].first[:type].should == "allow_screaming_snake_case_classes" }
51
+ specify { critic.problems[file_name].first[:type].should == 'allow_screaming_snake_case_classes' }
52
52
  specify { critic.problems[file_name].first[:line].should be 1 }
53
53
  specify { critic.problems[file_name].first[:column].should be 6 }
54
54
  specify { critic.problems[file_name].first[:level].should be :error }
55
55
  end
56
56
 
57
- context "standard screaming snake case module" do
57
+ context 'standard screaming snake case module' do
58
58
  let(:file_name) { 'one_screaming_snake_case_module' }
59
59
  specify { critic.problems[file_name].size.should be 1 }
60
- specify { critic.problems[file_name].first[:type].should == "allow_screaming_snake_case_classes" }
60
+ specify { critic.problems[file_name].first[:type].should == 'allow_screaming_snake_case_classes' }
61
61
  specify { critic.problems[file_name].first[:line].should be 1 }
62
62
  specify { critic.problems[file_name].first[:column].should be 7 }
63
63
  specify { critic.problems[file_name].first[:level].should be :error }
64
64
  end
65
65
 
66
- context "double screaming snake case class" do
66
+ context 'double screaming snake case class' do
67
67
  let(:file_name) { 'double_screaming_snake_case_class' }
68
68
  specify { critic.problems[file_name].size.should be 1 }
69
- specify { critic.problems[file_name].first[:type].should == "allow_screaming_snake_case_classes" }
69
+ specify { critic.problems[file_name].first[:type].should == 'allow_screaming_snake_case_classes' }
70
70
  specify { critic.problems[file_name].first[:line].should be 1 }
71
71
  specify { critic.problems[file_name].first[:column].should be 6 }
72
72
  specify { critic.problems[file_name].first[:level].should be :error }
73
73
  end
74
74
 
75
- context "double screaming snake case module" do
75
+ context 'double screaming snake case module' do
76
76
  let(:file_name) { 'double_screaming_snake_case_module' }
77
77
  specify { critic.problems[file_name].size.should be 1 }
78
- specify { critic.problems[file_name].first[:type].should == "allow_screaming_snake_case_classes" }
78
+ specify { critic.problems[file_name].first[:type].should == 'allow_screaming_snake_case_classes' }
79
79
  specify { critic.problems[file_name].first[:line].should be 1 }
80
80
  specify { critic.problems[file_name].first[:column].should be 7 }
81
81
  specify { critic.problems[file_name].first[:level].should be :error }
@@ -1,10 +1,10 @@
1
- require_relative '../spec_helper'
1
+ require 'spec_helper'
2
2
  require_relative '../support/naming_cases'
3
3
  require 'tailor/critic'
4
4
  require 'tailor/configuration/style'
5
5
 
6
6
 
7
- describe "Naming problem detection" do
7
+ describe 'Naming problem detection' do
8
8
  before do
9
9
  Tailor::Logger.stub(:log)
10
10
  FakeFS.activate!
@@ -28,7 +28,7 @@ describe "Naming problem detection" do
28
28
  File.open(file_name, 'w') { |f| f.write contents }
29
29
  end
30
30
 
31
- it "should be OK" do
31
+ it 'should be OK' do
32
32
  critic.check_file(file_name, style.to_hash)
33
33
  critic.problems.should == { file_name => [] }
34
34
  end
@@ -1,4 +1,4 @@
1
- require_relative '../../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'tailor/critic'
3
3
  require 'tailor/configuration/style'
4
4
 
@@ -24,7 +24,7 @@ CLASS_LENGTH['parent_class_too_long'] =
24
24
  end}
25
25
 
26
26
 
27
- describe "Detection of class length" do
27
+ describe 'Detection of class length' do
28
28
  before do
29
29
  Tailor::Logger.stub(:log)
30
30
  FakeFS.activate!
@@ -47,19 +47,19 @@ describe "Detection of class length" do
47
47
  style
48
48
  end
49
49
 
50
- context "single class" do
50
+ context 'single class' do
51
51
  let(:file_name) { 'class_too_long' }
52
52
  specify { critic.problems[file_name].size.should be 1 }
53
- specify { critic.problems[file_name].first[:type].should == "max_code_lines_in_class" }
53
+ specify { critic.problems[file_name].first[:type].should == 'max_code_lines_in_class' }
54
54
  specify { critic.problems[file_name].first[:line].should be 1 }
55
55
  specify { critic.problems[file_name].first[:column].should be 0 }
56
56
  specify { critic.problems[file_name].first[:level].should be :error }
57
57
  end
58
58
 
59
- context "class in a class" do
59
+ context 'class in a class' do
60
60
  let(:file_name) { 'parent_class_too_long' }
61
61
  specify { critic.problems[file_name].size.should be 1 }
62
- specify { critic.problems[file_name].first[:type].should == "max_code_lines_in_class" }
62
+ specify { critic.problems[file_name].first[:type].should == 'max_code_lines_in_class' }
63
63
  specify { critic.problems[file_name].first[:line].should be 1 }
64
64
  specify { critic.problems[file_name].first[:column].should be 0 }
65
65
  specify { critic.problems[file_name].first[:level].should be :error }
@@ -1,4 +1,4 @@
1
- require_relative '../../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'tailor/critic'
3
3
  require 'tailor/configuration/style'
4
4
 
@@ -18,7 +18,7 @@ METHOD_LENGTH['parent_method_too_long'] =
18
18
  end}
19
19
 
20
20
 
21
- describe "Detection of method length" do
21
+ describe 'Detection of method length' do
22
22
  before do
23
23
  Tailor::Logger.stub(:log)
24
24
  FakeFS.activate!
@@ -41,19 +41,19 @@ describe "Detection of method length" do
41
41
  style
42
42
  end
43
43
 
44
- context "single class too long" do
44
+ context 'single class too long' do
45
45
  let(:file_name) { 'method_too_long' }
46
46
  specify { critic.problems[file_name].size.should be 1 }
47
- specify { critic.problems[file_name].first[:type].should == "max_code_lines_in_method" }
47
+ specify { critic.problems[file_name].first[:type].should == 'max_code_lines_in_method' }
48
48
  specify { critic.problems[file_name].first[:line].should be 1 }
49
49
  specify { critic.problems[file_name].first[:column].should be 0 }
50
50
  specify { critic.problems[file_name].first[:level].should be :error }
51
51
  end
52
52
 
53
- context "method in a method" do
53
+ context 'method in a method' do
54
54
  let(:file_name) { 'method_too_long' }
55
55
  specify { critic.problems[file_name].size.should be 1 }
56
- specify { critic.problems[file_name].first[:type].should == "max_code_lines_in_method" }
56
+ specify { critic.problems[file_name].first[:type].should == 'max_code_lines_in_method' }
57
57
  specify { critic.problems[file_name].first[:line].should be 1 }
58
58
  specify { critic.problems[file_name].first[:column].should be 0 }
59
59
  specify { critic.problems[file_name].first[:level].should be :error }
@@ -1,10 +1,10 @@
1
- require_relative '../spec_helper'
1
+ require 'spec_helper'
2
2
  require_relative '../support/vertical_spacing_cases'
3
3
  require 'tailor/critic'
4
4
  require 'tailor/configuration/style'
5
5
 
6
6
 
7
- describe "Vertical Space problem detection" do
7
+ describe 'Vertical Space problem detection' do
8
8
  before do
9
9
  Tailor::Logger.stub(:log)
10
10
  FakeFS.activate!
@@ -28,7 +28,7 @@ describe "Vertical Space problem detection" do
28
28
  File.open(file_name, 'w') { |f| f.write contents }
29
29
  end
30
30
 
31
- it "should be OK" do
31
+ it 'should be OK' do
32
32
  critic.check_file(file_name, style.to_hash)
33
33
  critic.problems.should == { file_name => [] }
34
34
  end
@@ -0,0 +1,37 @@
1
+ CONDITIONAL_SPACING = {}
2
+
3
+ CONDITIONAL_SPACING['no_space_after_if'] =
4
+ %q{if(foo)
5
+ end}
6
+
7
+ CONDITIONAL_SPACING['space_after_if'] =
8
+ %q{if (foo)
9
+ end}
10
+
11
+ CONDITIONAL_SPACING['no_parens'] =
12
+ %q{if foo
13
+ end}
14
+
15
+ CONDITIONAL_SPACING['nested_parens'] =
16
+ %q{if(foo(bar))
17
+ end}
18
+
19
+ CONDITIONAL_SPACING['no_space_after_unless'] =
20
+ %q{unless(foo)
21
+ end}
22
+
23
+ CONDITIONAL_SPACING['space_after_unless'] =
24
+ %q{unless (foo)
25
+ end}
26
+
27
+ CONDITIONAL_SPACING['no_space_after_case'] =
28
+ %q{puts case(true)
29
+ when true then 'a'
30
+ when false then 'b'
31
+ end}
32
+
33
+ CONDITIONAL_SPACING['space_after_case'] =
34
+ %q{puts case (true)
35
+ when true then 'a'
36
+ when false then 'b'
37
+ end}
@@ -375,7 +375,7 @@ end}
375
375
 
376
376
  INDENT_OK['for_with_retry_loop'] =
377
377
  %Q{for i in 1..5
378
- retry if i > 2
378
+ retry if i > 2
379
379
  puts "Value of local variable is \#{i}"
380
380
  end}
381
381
 
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+ require 'tailor/cli/options'
3
+
4
+ module OptionHelpers
5
+ def cli_option(name)
6
+ "--#{name.to_s.gsub('_', '-')}"
7
+ end
8
+ def option_value(name, value)
9
+ options = Tailor::CLI::Options.parse!([cli_option(name), value])
10
+ options.style[name]
11
+ end
12
+ end
13
+
14
+ describe Tailor::CLI::Options do
15
+ include OptionHelpers
16
+ describe '#parse!' do
17
+ [
18
+ :indentation_spaces,
19
+ :max_code_lines_in_class,
20
+ :max_code_lines_in_method,
21
+ :max_line_length,
22
+ :spaces_after_comma,
23
+ :spaces_after_lbrace,
24
+ :spaces_after_lbracket,
25
+ :spaces_after_lparen,
26
+ :spaces_before_comma,
27
+ :spaces_before_lbrace,
28
+ :spaces_before_rbrace,
29
+ :spaces_before_rbracket,
30
+ :spaces_before_rparen,
31
+ :spaces_in_empty_braces,
32
+ :trailing_newlines
33
+ ].each do |o|
34
+ it 'parses a valid numeric argument correct' do
35
+ expect(option_value(o, '1')).to eq 1
36
+ end
37
+ it 'marks the ruler as off if the option is specified as "off"' do
38
+ expect(option_value(o, 'off')).to eq :off
39
+ end
40
+ it 'marks a ruler as off if the option is specified as "false"' do
41
+ expect(option_value(o, 'false')).to eq :off
42
+ end
43
+ it 'raises if the argument is otherwise not an integer' do
44
+ expect do
45
+ option_value(o, 'not-an-integer')
46
+ end.to raise_error(OptionParser::InvalidArgument)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -1,4 +1,4 @@
1
- require_relative '../../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'tailor/cli'
3
3
 
4
4
 
@@ -25,7 +25,7 @@ describe Tailor::CLI do
25
25
 
26
26
  describe '::run' do
27
27
  it "creates an instance of Tailor::CLI and calls that object's #execute!" do
28
- cli = double "Tailor::CLI"
28
+ cli = double 'Tailor::CLI'
29
29
  cli.should_receive(:execute!)
30
30
  Tailor::CLI.should_receive(:new).and_return cli
31
31
  Tailor::CLI.run([])
@@ -33,7 +33,7 @@ describe Tailor::CLI do
33
33
  end
34
34
 
35
35
  describe '#initialize' do
36
- let(:args) { ['last'] }
36
+ let(:args) { %w[last] }
37
37
 
38
38
  it 'uses Options to parse the args' do
39
39
  Tailor::Configuration.stub(:new).and_return config
@@ -1,4 +1,4 @@
1
- require_relative '../../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'tailor/composite_observable'
3
3
 
4
4
 
@@ -9,31 +9,31 @@ end
9
9
  describe Tailor::CompositeObservable do
10
10
  subject { Tester.new }
11
11
 
12
- describe ".define_observer" do
12
+ describe '.define_observer' do
13
13
  context "observer = 'pants'" do
14
14
  before { Tailor::CompositeObservable.define_observer 'pants' }
15
15
 
16
- context "observer responds to #pants_update" do
16
+ context 'observer responds to #pants_update' do
17
17
  it "defines an instance method 'add_pants_observer' that takes 1 arg" do
18
- observer = double "Observer", respond_to?: true
18
+ observer = double 'Observer', respond_to?: true
19
19
  subject.add_pants_observer(observer)
20
20
  end
21
21
  end
22
22
 
23
- context "observer does not respond to #pants_update" do
23
+ context 'observer does not respond to #pants_update' do
24
24
  it "defines an instance method 'add_pants_observer' that takes 1 arg" do
25
- observer = double "Observer", respond_to?: false
25
+ observer = double 'Observer', respond_to?: false
26
26
  expect { subject.add_pants_observer(observer) }.
27
27
  to raise_error NoMethodError
28
28
  end
29
29
  end
30
30
 
31
- it "defines an instance method #notify_pants_observers" do
31
+ it 'defines an instance method #notify_pants_observers' do
32
32
  expect { subject.notify_pants_observers }.
33
33
  to_not raise_error
34
34
  end
35
35
 
36
- it "defines an instance method #pants_changed" do
36
+ it 'defines an instance method #pants_changed' do
37
37
  expect { subject.pants_changed }.to_not raise_error
38
38
  end
39
39
  end
@@ -1,4 +1,4 @@
1
- require_relative '../../../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'tailor/configuration/file_set'
3
3
 
4
4
 
@@ -18,7 +18,7 @@ describe Tailor::Configuration::FileSet do
18
18
  end
19
19
 
20
20
  context 'the file does not exist' do
21
- it "returns an empty Array" do
21
+ it 'returns an empty Array' do
22
22
  subject.instance_eval { build_file_list('test.rb') }.should == []
23
23
  end
24
24
  end
@@ -1,150 +1,150 @@
1
- require_relative '../../../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'tailor/configuration/style'
3
3
 
4
4
 
5
5
  describe Tailor::Configuration::Style do
6
- describe ".define_property" do
7
- it "defines an instance method that takes 2 params" do
6
+ describe '.define_property' do
7
+ it 'defines an instance method that takes 2 params' do
8
8
  Tailor::Configuration::Style.define_property(:test_method)
9
9
  subject.test_method(1, 2)
10
10
  end
11
11
 
12
- it "allows access to the values via #to_hash" do
12
+ it 'allows access to the values via #to_hash' do
13
13
  Tailor::Configuration::Style.define_property(:test_method)
14
14
  subject.test_method(1, level: :pants)
15
15
  subject.to_hash.should include test_method: [1, { level: :pants }]
16
16
  end
17
17
  end
18
18
 
19
- describe "#initialize" do
20
- describe "sets up default values" do
21
- describe "allow_camel_case_methods" do
19
+ describe '#initialize' do
20
+ describe 'sets up default values' do
21
+ describe 'allow_camel_case_methods' do
22
22
  specify do
23
23
  subject.instance_variable_get(:@allow_camel_case_methods).should == [
24
24
  false, { level: :error }]
25
25
  end
26
26
  end
27
27
 
28
- describe "allow_hard_tabs" do
28
+ describe 'allow_hard_tabs' do
29
29
  specify do
30
30
  subject.instance_variable_get(:@allow_hard_tabs).should == [
31
31
  false, { level: :error }]
32
32
  end
33
33
  end
34
34
 
35
- describe "allow_screaming_snake_case_classes" do
35
+ describe 'allow_screaming_snake_case_classes' do
36
36
  specify do
37
37
  subject.instance_variable_get(:@allow_screaming_snake_case_classes).
38
38
  should == [false, { level: :error }]
39
39
  end
40
40
  end
41
41
 
42
- describe "allow_trailing_line_spaces" do
42
+ describe 'allow_trailing_line_spaces' do
43
43
  specify do
44
44
  subject.instance_variable_get(:@allow_trailing_line_spaces).
45
45
  should == [false, { level: :error }]
46
46
  end
47
47
  end
48
48
 
49
- describe "indentation_spaces" do
49
+ describe 'indentation_spaces' do
50
50
  specify do
51
51
  subject.instance_variable_get(:@indentation_spaces).should == [
52
52
  2, { level: :error }]
53
53
  end
54
54
  end
55
55
 
56
- describe "max_code_lines_in_class" do
56
+ describe 'max_code_lines_in_class' do
57
57
  specify do
58
58
  subject.instance_variable_get(:@max_code_lines_in_class).should == [
59
59
  300, { level: :error }]
60
60
  end
61
61
  end
62
62
 
63
- describe "max_code_lines_in_method" do
63
+ describe 'max_code_lines_in_method' do
64
64
  specify do
65
65
  subject.instance_variable_get(:@max_code_lines_in_method).should == [
66
66
  30, { level: :error }]
67
67
  end
68
68
  end
69
69
 
70
- describe "max_line_length" do
70
+ describe 'max_line_length' do
71
71
  specify do
72
72
  subject.instance_variable_get(:@max_line_length).should == [
73
73
  80, { level: :error }]
74
74
  end
75
75
  end
76
76
 
77
- describe "spaces_after_comma" do
77
+ describe 'spaces_after_comma' do
78
78
  specify do
79
79
  subject.instance_variable_get(:@spaces_after_comma).should == [
80
80
  1, { level: :error }]
81
81
  end
82
82
  end
83
83
 
84
- describe "spaces_after_lbrace" do
84
+ describe 'spaces_after_lbrace' do
85
85
  specify do
86
86
  subject.instance_variable_get(:@spaces_after_lbrace).should == [
87
87
  1, { level: :error }]
88
88
  end
89
89
  end
90
90
 
91
- describe "spaces_after_lbracket" do
91
+ describe 'spaces_after_lbracket' do
92
92
  specify do
93
93
  subject.instance_variable_get(:@spaces_after_lbracket).should == [
94
94
  0, { level: :error }]
95
95
  end
96
96
  end
97
97
 
98
- describe "spaces_after_lparen" do
98
+ describe 'spaces_after_lparen' do
99
99
  specify do
100
100
  subject.instance_variable_get(:@spaces_after_lparen).should == [
101
101
  0, { level: :error }]
102
102
  end
103
103
  end
104
104
 
105
- describe "spaces_before_comma" do
105
+ describe 'spaces_before_comma' do
106
106
  specify do
107
107
  subject.instance_variable_get(:@spaces_before_comma).should == [
108
108
  0, { level: :error }]
109
109
  end
110
110
  end
111
111
 
112
- describe "spaces_before_lbrace" do
112
+ describe 'spaces_before_lbrace' do
113
113
  specify do
114
114
  subject.instance_variable_get(:@spaces_before_lbrace).should == [
115
115
  1, { level: :error }]
116
116
  end
117
117
  end
118
118
 
119
- describe "spaces_before_rbrace" do
119
+ describe 'spaces_before_rbrace' do
120
120
  specify do
121
121
  subject.instance_variable_get(:@spaces_before_rbrace).should == [
122
122
  1, { level: :error }]
123
123
  end
124
124
  end
125
125
 
126
- describe "spaces_before_rbracket" do
126
+ describe 'spaces_before_rbracket' do
127
127
  specify do
128
128
  subject.instance_variable_get(:@spaces_before_rbracket).should == [
129
129
  0, { level: :error }]
130
130
  end
131
131
  end
132
132
 
133
- describe "spaces_before_rparen" do
133
+ describe 'spaces_before_rparen' do
134
134
  specify do
135
135
  subject.instance_variable_get(:@spaces_before_rparen).should == [
136
136
  0, { level: :error }]
137
137
  end
138
138
  end
139
139
 
140
- describe "spaces_in_empty_braces" do
140
+ describe 'spaces_in_empty_braces' do
141
141
  specify do
142
142
  subject.instance_variable_get(:@spaces_in_empty_braces).should == [
143
143
  0, { level: :error }]
144
144
  end
145
145
  end
146
146
 
147
- describe "trailing_newlines" do
147
+ describe 'trailing_newlines' do
148
148
  specify do
149
149
  subject.instance_variable_get(:@trailing_newlines).should == [
150
150
  1, { level: :error }]
@@ -153,7 +153,7 @@ describe Tailor::Configuration::Style do
153
153
  end
154
154
  end
155
155
 
156
- describe "#to_hash" do
156
+ describe '#to_hash' do
157
157
  let(:default_values) do
158
158
  {
159
159
  :allow_camel_case_methods => [false, { :level => :error }],
@@ -166,6 +166,7 @@ describe Tailor::Configuration::Style do
166
166
  :max_code_lines_in_method => [30, { :level => :error }],
167
167
  :max_line_length => [80, { :level => :error }],
168
168
  :spaces_after_comma => [1, { :level => :error }],
169
+ :spaces_after_conditional => [1, { :level=>:error }],
169
170
  :spaces_after_lbrace => [1, { :level => :error }],
170
171
  :spaces_after_lbracket => [0, { :level => :error }],
171
172
  :spaces_after_lparen => [0, { :level => :error }],
@@ -179,17 +180,17 @@ describe Tailor::Configuration::Style do
179
180
  }
180
181
  end
181
182
 
182
- it "returns a Hash of all of the attributes and values" do
183
+ it 'returns a Hash of all of the attributes and values' do
183
184
  subject.to_hash.should == default_values
184
185
  end
185
186
 
186
- context "with a user-added property" do
187
+ context 'with a user-added property' do
187
188
  before do
188
189
  Tailor::Configuration::Style.define_property(:long_pants)
189
190
  subject.long_pants(1, level: :warn)
190
191
  end
191
192
 
192
- it "includes the new property as part of the Hash" do
193
+ it 'includes the new property as part of the Hash' do
193
194
  subject.to_hash.should include long_pants: [1, { level: :warn }]
194
195
  end
195
196
  end