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.
- checksums.yaml +4 -4
- data/Gemfile.lock +30 -28
- data/History.md +257 -0
- data/README.md +486 -0
- data/Rakefile +1 -9
- data/lib/ext/string_ext.rb +1 -1
- data/lib/tailor/cli.rb +3 -1
- data/lib/tailor/cli/options.rb +59 -39
- data/lib/tailor/configuration.rb +8 -5
- data/lib/tailor/configuration/file_set.rb +1 -3
- data/lib/tailor/configuration/style.rb +2 -0
- data/lib/tailor/critic.rb +2 -2
- data/lib/tailor/formatters/text.rb +17 -16
- data/lib/tailor/lexed_line.rb +2 -4
- data/lib/tailor/lexer.rb +9 -9
- data/lib/tailor/lexer/lexer_constants.rb +32 -32
- data/lib/tailor/lexer/token.rb +8 -10
- data/lib/tailor/logger.rb +1 -1
- data/lib/tailor/problem.rb +4 -1
- data/lib/tailor/rake_task.rb +4 -1
- data/lib/tailor/reporter.rb +3 -3
- data/lib/tailor/ruler.rb +2 -2
- data/lib/tailor/rulers/allow_camel_case_methods_ruler.rb +2 -2
- data/lib/tailor/rulers/allow_hard_tabs_ruler.rb +1 -1
- data/lib/tailor/rulers/allow_invalid_ruby_ruler.rb +1 -1
- data/lib/tailor/rulers/allow_screaming_snake_case_classes_ruler.rb +2 -2
- data/lib/tailor/rulers/indentation_spaces_ruler.rb +24 -22
- data/lib/tailor/rulers/indentation_spaces_ruler/indentation_manager.rb +13 -13
- data/lib/tailor/rulers/max_code_lines_in_class_ruler.rb +2 -2
- data/lib/tailor/rulers/max_code_lines_in_method_ruler.rb +2 -2
- data/lib/tailor/rulers/spaces_after_comma_ruler.rb +6 -6
- data/lib/tailor/rulers/spaces_after_conditional_ruler.rb +48 -0
- data/lib/tailor/rulers/spaces_after_lbrace_ruler.rb +8 -8
- data/lib/tailor/rulers/spaces_after_lbracket_ruler.rb +6 -6
- data/lib/tailor/rulers/spaces_after_lparen_ruler.rb +6 -6
- data/lib/tailor/rulers/spaces_before_comma_ruler.rb +2 -2
- data/lib/tailor/rulers/spaces_before_lbrace_ruler.rb +4 -4
- data/lib/tailor/rulers/spaces_before_rbrace_ruler.rb +9 -9
- data/lib/tailor/rulers/spaces_before_rbracket_ruler.rb +6 -6
- data/lib/tailor/rulers/spaces_before_rparen_ruler.rb +6 -6
- data/lib/tailor/rulers/spaces_in_empty_braces_ruler.rb +1 -1
- data/lib/tailor/rulers/trailing_newlines_ruler.rb +2 -2
- data/lib/tailor/tailorrc.erb +1 -1
- data/lib/tailor/version.rb +1 -1
- data/spec/functional/conditional_spacing_spec.rb +149 -0
- data/spec/functional/configuration_spec.rb +36 -26
- data/spec/functional/horizontal_spacing/braces_spec.rb +1 -1
- data/spec/functional/horizontal_spacing/brackets_spec.rb +14 -14
- data/spec/functional/horizontal_spacing/comma_spacing_spec.rb +8 -8
- data/spec/functional/horizontal_spacing/hard_tabs_spec.rb +13 -13
- data/spec/functional/horizontal_spacing/long_lines_spec.rb +6 -6
- data/spec/functional/horizontal_spacing/long_methods_spec.rb +55 -0
- data/spec/functional/horizontal_spacing/parens_spec.rb +17 -17
- data/spec/functional/horizontal_spacing/trailing_whitespace_spec.rb +8 -8
- data/spec/functional/horizontal_spacing_spec.rb +11 -11
- data/spec/functional/indentation_spacing/bad_indentation_spec.rb +83 -83
- data/spec/functional/indentation_spacing_spec.rb +10 -10
- data/spec/functional/naming/camel_case_methods_spec.rb +6 -6
- data/spec/functional/naming/screaming_snake_case_classes_spec.rb +10 -10
- data/spec/functional/naming_spec.rb +3 -3
- data/spec/functional/vertical_spacing/class_length_spec.rb +6 -6
- data/spec/functional/vertical_spacing/method_length_spec.rb +6 -6
- data/spec/functional/vertical_spacing_spec.rb +3 -3
- data/spec/support/conditional_spacing_cases.rb +37 -0
- data/spec/support/good_indentation_cases.rb +1 -1
- data/spec/unit/tailor/cli/options_spec.rb +50 -0
- data/spec/unit/tailor/cli_spec.rb +3 -3
- data/spec/unit/tailor/composite_observable_spec.rb +8 -8
- data/spec/unit/tailor/configuration/file_set_spec.rb +2 -2
- data/spec/unit/tailor/configuration/style_spec.rb +30 -29
- data/spec/unit/tailor/configuration_spec.rb +39 -24
- data/spec/unit/tailor/critic_spec.rb +18 -17
- data/spec/unit/tailor/formatter_spec.rb +15 -15
- data/spec/unit/tailor/formatters/yaml_spec.rb +1 -1
- data/spec/unit/tailor/lexed_line_spec.rb +258 -258
- data/spec/unit/tailor/lexer/token_spec.rb +11 -11
- data/spec/unit/tailor/lexer_spec.rb +35 -35
- data/spec/unit/tailor/problem_spec.rb +13 -13
- data/spec/unit/tailor/reporter_spec.rb +19 -18
- data/spec/unit/tailor/ruler_spec.rb +15 -15
- data/spec/unit/tailor/rulers/indentation_spaces_ruler/indentation_manager_spec.rb +72 -72
- data/spec/unit/tailor/rulers/indentation_spaces_ruler_spec.rb +32 -32
- data/spec/unit/tailor/rulers/spaces_after_comma_ruler_spec.rb +8 -8
- data/spec/unit/tailor/rulers/spaces_after_lbrace_ruler_spec.rb +36 -36
- data/spec/unit/tailor/rulers/spaces_before_lbrace_ruler_spec.rb +14 -14
- data/spec/unit/tailor/rulers/spaces_before_rbrace_ruler_spec.rb +14 -14
- data/spec/unit/tailor/rulers_spec.rb +2 -2
- data/spec/unit/tailor/version_spec.rb +1 -1
- data/spec/unit/tailor_spec.rb +4 -4
- data/tailor.gemspec +1 -1
- metadata +16 -9
- data/History.rdoc +0 -189
- data/README.rdoc +0 -422
- data/spec/unit/tailor/options_spec.rb +0 -6
@@ -3,11 +3,11 @@ require_relative '../ruler'
|
|
3
3
|
class Tailor
|
4
4
|
module Rulers
|
5
5
|
|
6
|
-
# Checks for spaces before a
|
6
|
+
# Checks for spaces before a +]+ as given by +@config+. It skips checking
|
7
7
|
# when:
|
8
8
|
# * it's the first char in the line.
|
9
|
-
# * it's directly preceded by a
|
10
|
-
# * it's directly preceded by spaces, then a
|
9
|
+
# * it's directly preceded by a +[+.
|
10
|
+
# * it's directly preceded by spaces, then a +[+.
|
11
11
|
class SpacesBeforeRbracketRuler < Tailor::Ruler
|
12
12
|
def initialize(config, options)
|
13
13
|
super(config, options)
|
@@ -53,8 +53,8 @@ class Tailor
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
# This has to keep track of
|
57
|
-
# if the
|
56
|
+
# This has to keep track of +{+s and only follow through with the check
|
57
|
+
# if the +{+ was an lbrace because Ripper doesn't scan the +}+ of an
|
58
58
|
# embedded expression (embexpr_end) as such.
|
59
59
|
#
|
60
60
|
# @param [Tailor::LexedLine] lexed_line
|
@@ -64,7 +64,7 @@ class Tailor
|
|
64
64
|
count = count_spaces(lexed_line, column)
|
65
65
|
|
66
66
|
if count.nil?
|
67
|
-
log
|
67
|
+
log 'rbracket must be at the beginning of the line.'
|
68
68
|
return
|
69
69
|
else
|
70
70
|
log "Found #{count} space(s) before rbracket."
|
@@ -6,8 +6,8 @@ class Tailor
|
|
6
6
|
# Checks for spaces before a +)+ as given by +@config+. It skips checking
|
7
7
|
# when:
|
8
8
|
# * it's the first char in the line.
|
9
|
-
# * it's directly preceded by a
|
10
|
-
# * it's directly preceded by spaces, then a
|
9
|
+
# * it's directly preceded by a +(+.
|
10
|
+
# * it's directly preceded by spaces, then a +(+.
|
11
11
|
class SpacesBeforeRparenRuler < Tailor::Ruler
|
12
12
|
def initialize(config, options)
|
13
13
|
super(config, options)
|
@@ -16,7 +16,7 @@ class Tailor
|
|
16
16
|
|
17
17
|
# @param [LexedLine] lexed_line
|
18
18
|
# @param [Fixnum] column
|
19
|
-
# @return [Fixnum]
|
19
|
+
# @return [Fixnum] the number of spaces before the rparen.
|
20
20
|
def count_spaces(lexed_line, column)
|
21
21
|
current_index = lexed_line.event_index(column)
|
22
22
|
log "Current event index: #{current_index}"
|
@@ -53,8 +53,8 @@ class Tailor
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
# This has to keep track of
|
57
|
-
# if the
|
56
|
+
# This has to keep track of +{+s and only follow through with the check
|
57
|
+
# if the +{+ was an lbrace because Ripper doesn't scan the +}+ of an
|
58
58
|
# embedded expression (embexpr_end) as such.
|
59
59
|
#
|
60
60
|
# @param [Tailor::LexedLine] lexed_line
|
@@ -64,7 +64,7 @@ class Tailor
|
|
64
64
|
count = count_spaces(lexed_line, column)
|
65
65
|
|
66
66
|
if count.nil?
|
67
|
-
log
|
67
|
+
log 'rparen must be at the beginning of the line.'
|
68
68
|
return
|
69
69
|
else
|
70
70
|
log "Found #{count} space(s) before rparen."
|
@@ -68,7 +68,7 @@ class Tailor
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
# This has to keep track of
|
71
|
+
# This has to keep track of +{+s and only follow through with the check
|
72
72
|
# if the +{+ was an lbrace because Ripper doesn't scan the +}+ of an
|
73
73
|
# embedded expression (embexpr_end) as such.
|
74
74
|
#
|
@@ -16,8 +16,8 @@ class Tailor
|
|
16
16
|
# of the file.
|
17
17
|
def measure(trailing_newline_count)
|
18
18
|
if trailing_newline_count != @config
|
19
|
-
lineno =
|
20
|
-
column =
|
19
|
+
lineno = '<EOF>'
|
20
|
+
column = '<EOF>'
|
21
21
|
msg = "File has #{trailing_newline_count} trailing "
|
22
22
|
msg << "newlines, but should have #{@config}."
|
23
23
|
|
data/lib/tailor/tailorrc.erb
CHANGED
@@ -80,7 +80,7 @@
|
|
80
80
|
# Default: 1
|
81
81
|
#
|
82
82
|
Tailor.config do |config|
|
83
|
-
config.formatters "<%= formatters.join(
|
83
|
+
config.formatters "<%= formatters.join(', ') %>"
|
84
84
|
config.file_set '<%= file_list %>' do |style|<% style.each do |rule, value| %>
|
85
85
|
style.<%= rule %> <%= value.first %>, <% value.last.each { |k, v| %><%= k %>: :<%= v %><% } end %>
|
86
86
|
end
|
data/lib/tailor/version.rb
CHANGED
@@ -0,0 +1,149 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../support/conditional_spacing_cases'
|
3
|
+
require 'tailor/critic'
|
4
|
+
require 'tailor/configuration/style'
|
5
|
+
|
6
|
+
describe 'Conditional spacing' do
|
7
|
+
|
8
|
+
def file_name
|
9
|
+
self.class.description
|
10
|
+
end
|
11
|
+
|
12
|
+
def contents
|
13
|
+
CONDITIONAL_SPACING[file_name] || begin
|
14
|
+
raise "Example not found: #{file_name}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
before do
|
19
|
+
Tailor::Logger.stub(:log)
|
20
|
+
FakeFS.activate!
|
21
|
+
FileUtils.touch file_name
|
22
|
+
File.open(file_name, 'w') { |f| f.write contents }
|
23
|
+
end
|
24
|
+
|
25
|
+
let(:critic) { Tailor::Critic.new }
|
26
|
+
|
27
|
+
let(:style) do
|
28
|
+
style = Tailor::Configuration::Style.new
|
29
|
+
style.trailing_newlines 0, level: :off
|
30
|
+
style.allow_invalid_ruby true, level: :off
|
31
|
+
style
|
32
|
+
end
|
33
|
+
|
34
|
+
context :no_space_after_if do
|
35
|
+
it 'warns when there is no space after an if statement' do
|
36
|
+
critic.check_file(file_name, style.to_hash)
|
37
|
+
expect(critic.problems[file_name]).to eql [{
|
38
|
+
:type => 'spaces_after_conditional',
|
39
|
+
:line => 1,
|
40
|
+
:column => 0,
|
41
|
+
:message => '0 spaces after conditional at column 0, expected 1.',
|
42
|
+
:level => :error
|
43
|
+
}]
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'warns with the correct number of expected spaces' do
|
47
|
+
style.spaces_after_conditional 2, level: :error
|
48
|
+
critic.check_file(file_name, style.to_hash)
|
49
|
+
expect(critic.problems[file_name]).to eql [{
|
50
|
+
:type => 'spaces_after_conditional',
|
51
|
+
:line => 1,
|
52
|
+
:column => 0,
|
53
|
+
:message => '0 spaces after conditional at column 0, expected 2.',
|
54
|
+
:level => :error
|
55
|
+
}]
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'does not warn if spaces are set to zero' do
|
59
|
+
style.spaces_after_conditional 0, level: :error
|
60
|
+
critic.check_file(file_name, style.to_hash)
|
61
|
+
expect(critic.problems[file_name]).to be_empty
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'does not warn if spaces are disabled' do
|
65
|
+
style.spaces_after_conditional 2, level: :off
|
66
|
+
critic.check_file(file_name, style.to_hash)
|
67
|
+
expect(critic.problems[file_name]).to be_empty
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context :space_after_if do
|
72
|
+
it 'does not warn when there is a space after the if' do
|
73
|
+
critic.check_file(file_name, style.to_hash)
|
74
|
+
expect(critic.problems[file_name]).to be_empty
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'warns if spaces has been set to zero' do
|
78
|
+
style.spaces_after_conditional 0, level: :error
|
79
|
+
critic.check_file(file_name, style.to_hash)
|
80
|
+
expect(critic.problems[file_name]).to eql [{
|
81
|
+
:type => 'spaces_after_conditional',
|
82
|
+
:line => 1,
|
83
|
+
:column => 0,
|
84
|
+
:message => '1 spaces after conditional at column 0, expected 0.',
|
85
|
+
:level => :error
|
86
|
+
}]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context :no_parens do
|
91
|
+
it 'never warns' do
|
92
|
+
critic.check_file(file_name, style.to_hash)
|
93
|
+
expect(critic.problems[file_name]).to be_empty
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context :nested_parens do
|
98
|
+
it 'warns when there is no space after an if statement' do
|
99
|
+
critic.check_file(file_name, style.to_hash)
|
100
|
+
expect(critic.problems[file_name]).to eql [{
|
101
|
+
:type => 'spaces_after_conditional',
|
102
|
+
:line => 1,
|
103
|
+
:column => 0,
|
104
|
+
:message => '0 spaces after conditional at column 0, expected 1.',
|
105
|
+
:level => :error
|
106
|
+
}]
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context :no_space_after_unless do
|
111
|
+
it 'warns when there is no space after an unless statement' do
|
112
|
+
critic.check_file(file_name, style.to_hash)
|
113
|
+
expect(critic.problems[file_name]).to eql [{
|
114
|
+
:type => 'spaces_after_conditional',
|
115
|
+
:line => 1,
|
116
|
+
:column => 0,
|
117
|
+
:message => '0 spaces after conditional at column 0, expected 1.',
|
118
|
+
:level => :error
|
119
|
+
}]
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context :space_after_unless do
|
124
|
+
it 'does not warn when there is space after an unless statement' do
|
125
|
+
critic.check_file(file_name, style.to_hash)
|
126
|
+
expect(critic.problems[file_name]).to be_empty
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context :no_space_after_case do
|
131
|
+
it 'warns when there is no space after a case statement' do
|
132
|
+
critic.check_file(file_name, style.to_hash)
|
133
|
+
expect(critic.problems[file_name]).to eql [{
|
134
|
+
:type => 'spaces_after_conditional',
|
135
|
+
:line => 1,
|
136
|
+
:column => 5,
|
137
|
+
:message => '0 spaces after conditional at column 5, expected 1.',
|
138
|
+
:level => :error
|
139
|
+
}]
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
context :space_after_case do
|
144
|
+
it 'does not warn when there is space after a case statement' do
|
145
|
+
critic.check_file(file_name, style.to_hash)
|
146
|
+
expect(critic.problems[file_name]).to be_empty
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
@@ -1,7 +1,8 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'tailor/configuration'
|
3
3
|
|
4
|
-
|
4
|
+
|
5
|
+
describe 'Config File' do
|
5
6
|
before do
|
6
7
|
Tailor::Logger.stub(:log)
|
7
8
|
FakeFS.deactivate!
|
@@ -11,7 +12,7 @@ describe "Config File" do
|
|
11
12
|
FakeFS.activate!
|
12
13
|
end
|
13
14
|
|
14
|
-
context
|
15
|
+
context 'files are not given at runtime' do
|
15
16
|
let(:config) do
|
16
17
|
config = Tailor::Configuration.new
|
17
18
|
config.load!
|
@@ -19,7 +20,7 @@ describe "Config File" do
|
|
19
20
|
config
|
20
21
|
end
|
21
22
|
|
22
|
-
context
|
23
|
+
context '.tailor does not exist' do
|
23
24
|
before do
|
24
25
|
Tailor::Configuration.any_instance.stub(:config_file).and_return false
|
25
26
|
end
|
@@ -28,20 +29,20 @@ describe "Config File" do
|
|
28
29
|
config.formatters.should == %w(text)
|
29
30
|
end
|
30
31
|
|
31
|
-
it
|
32
|
+
it 'sets file_sets[:default].style to the default style' do
|
32
33
|
config.file_sets[:default].style.should_not be_nil
|
33
34
|
config.file_sets[:default].style.should == Tailor::Configuration::Style.new.to_hash
|
34
35
|
end
|
35
36
|
|
36
|
-
it
|
37
|
+
it 'sets file_sets[:default].file_list to the files in lib/**/*.rb' do
|
37
38
|
config.file_sets[:default].file_list.all? do |path|
|
38
39
|
path =~ /tailor\/lib/
|
39
40
|
end.should be_true
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
43
|
-
context
|
44
|
-
context
|
44
|
+
context '.tailor defines the default file set' do
|
45
|
+
context 'and another file set' do
|
45
46
|
let(:config_file) do
|
46
47
|
<<-CONFIG
|
47
48
|
Tailor.config do |config|
|
@@ -58,14 +59,14 @@ end
|
|
58
59
|
File.should_receive(:read).and_return config_file
|
59
60
|
end
|
60
61
|
|
61
|
-
it
|
62
|
+
it 'creates the default file set' do
|
62
63
|
config.file_sets[:default].style.should == Tailor::Configuration::Style.new.to_hash
|
63
64
|
config.file_sets[:default].file_list.all? do |path|
|
64
65
|
path =~ /tailor\/lib/
|
65
66
|
end.should be_true
|
66
67
|
end
|
67
68
|
|
68
|
-
it
|
69
|
+
it 'creates the :features file set' do
|
69
70
|
style = Tailor::Configuration::Style.new
|
70
71
|
style.max_line_length(90, level: :warn)
|
71
72
|
config.file_sets[:features].style.should == style.to_hash
|
@@ -76,7 +77,7 @@ end
|
|
76
77
|
end
|
77
78
|
end
|
78
79
|
|
79
|
-
context
|
80
|
+
context '.tailor defines NO default file set' do
|
80
81
|
let(:config_file) do
|
81
82
|
<<-CONFIG
|
82
83
|
Tailor.config do |config|
|
@@ -91,11 +92,11 @@ end
|
|
91
92
|
File.should_receive(:read).and_return config_file
|
92
93
|
end
|
93
94
|
|
94
|
-
it
|
95
|
+
it 'does not create a :default file set' do
|
95
96
|
config.file_sets.should_not include :default
|
96
97
|
end
|
97
98
|
|
98
|
-
it
|
99
|
+
it 'creates the non-default file set' do
|
99
100
|
config.file_sets.should include :features
|
100
101
|
end
|
101
102
|
end
|
@@ -124,6 +125,12 @@ end
|
|
124
125
|
file =~ /spec\.rb$/
|
125
126
|
end.should be_true
|
126
127
|
end
|
128
|
+
|
129
|
+
it 'applies the nested configuration within the fileset' do
|
130
|
+
expect(config.file_sets[:default].style[
|
131
|
+
:max_line_length]).to eql [90, { :level => :warn }]
|
132
|
+
end
|
133
|
+
|
127
134
|
end
|
128
135
|
end
|
129
136
|
|
@@ -135,7 +142,7 @@ end
|
|
135
142
|
config
|
136
143
|
end
|
137
144
|
|
138
|
-
context
|
145
|
+
context '.tailor does not exist' do
|
139
146
|
before do
|
140
147
|
Tailor::Configuration.any_instance.stub(:config_file).and_return false
|
141
148
|
end
|
@@ -144,19 +151,19 @@ end
|
|
144
151
|
config.formatters.should == %w(text)
|
145
152
|
end
|
146
153
|
|
147
|
-
it
|
154
|
+
it 'sets file_sets[:default].style to the default style' do
|
148
155
|
config.file_sets[:default].style.should_not be_nil
|
149
156
|
config.file_sets[:default].style.should == Tailor::Configuration::Style.new.to_hash
|
150
157
|
end
|
151
158
|
|
152
|
-
it
|
159
|
+
it 'sets file_sets[:default].file_list to the runtime files' do
|
153
160
|
config.file_sets[:default].file_list.size.should be 1
|
154
161
|
config.file_sets[:default].file_list.first.match /lib\/tailor\.rb$/
|
155
162
|
end
|
156
163
|
end
|
157
164
|
|
158
|
-
context
|
159
|
-
context
|
165
|
+
context '.tailor defines the default file set' do
|
166
|
+
context 'and another file set' do
|
160
167
|
let(:config_file) do
|
161
168
|
<<-CONFIG
|
162
169
|
Tailor.config do |config|
|
@@ -175,7 +182,7 @@ end
|
|
175
182
|
File.should_receive(:read).and_return config_file
|
176
183
|
end
|
177
184
|
|
178
|
-
it
|
185
|
+
it 'creates the default file set using the runtime files' do
|
179
186
|
style = Tailor::Configuration::Style.new
|
180
187
|
style.max_line_length 85
|
181
188
|
config.file_sets[:default].style.should == style.to_hash
|
@@ -183,13 +190,13 @@ end
|
|
183
190
|
config.file_sets[:default].file_list.first.match /lib\/tailor\.rb$/
|
184
191
|
end
|
185
192
|
|
186
|
-
it
|
193
|
+
it 'does not create the :features file set' do
|
187
194
|
config.file_sets.should_not include :features
|
188
195
|
end
|
189
196
|
end
|
190
197
|
end
|
191
198
|
|
192
|
-
context
|
199
|
+
context '.tailor defines NO default file set' do
|
193
200
|
let(:config_file) do
|
194
201
|
<<-CONFIG
|
195
202
|
Tailor.config do |config|
|
@@ -204,13 +211,13 @@ end
|
|
204
211
|
File.should_receive(:read).and_return config_file
|
205
212
|
end
|
206
213
|
|
207
|
-
it
|
214
|
+
it 'creates a :default file set with the runtime file and default style' do
|
208
215
|
config.file_sets[:default].style.should == Tailor::Configuration::Style.new.to_hash
|
209
216
|
config.file_sets[:default].file_list.size.should be 1
|
210
217
|
config.file_sets[:default].file_list.first.match /lib\/tailor\.rb$/
|
211
218
|
end
|
212
219
|
|
213
|
-
it
|
220
|
+
it 'does not create the non-default file set' do
|
214
221
|
config.file_sets.should_not include :features
|
215
222
|
end
|
216
223
|
end
|
@@ -234,8 +241,11 @@ end
|
|
234
241
|
config.file_sets.keys.should == [:default]
|
235
242
|
end
|
236
243
|
|
237
|
-
it
|
238
|
-
|
244
|
+
it 'creates a :default file set with the runtime file and default style' do
|
245
|
+
style = Tailor::Configuration::Style.new.tap do |style|
|
246
|
+
style.max_line_length 90, level: :warn
|
247
|
+
end.to_hash
|
248
|
+
config.file_sets[:default].style.should == style
|
239
249
|
config.file_sets[:default].file_list.size.should be 1
|
240
250
|
config.file_sets[:default].file_list.first.match /lib\/tailor\.rb$/
|
241
251
|
end
|
@@ -272,7 +282,7 @@ end
|
|
272
282
|
File.should_receive(:read).and_return config_file
|
273
283
|
end
|
274
284
|
|
275
|
-
it
|
285
|
+
it 'sets formatters to the defined' do
|
276
286
|
config.formatters.should == %w(yaml text)
|
277
287
|
end
|
278
288
|
|