tailor 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -3
- data/Gemfile.lock +39 -31
- data/History.md +220 -207
- data/README.md +58 -45
- data/features/step_definitions/indentation_steps.rb +1 -1
- data/lib/tailor/reporter.rb +19 -7
- data/lib/tailor/rulers/spaces_before_lbrace_ruler.rb +0 -1
- data/lib/tailor/rulers/spaces_before_rbrace_ruler.rb +0 -1
- data/lib/tailor/rulers/spaces_in_empty_braces_ruler.rb +0 -1
- data/lib/tailor/version.rb +1 -1
- data/spec/functional/conditional_parentheses_spec.rb +1 -1
- data/spec/functional/conditional_spacing_spec.rb +1 -1
- data/spec/functional/configuration_spec.rb +61 -52
- data/spec/functional/horizontal_spacing/braces_spec.rb +134 -134
- data/spec/functional/horizontal_spacing/brackets_spec.rb +34 -36
- data/spec/functional/horizontal_spacing/comma_spacing_spec.rb +25 -27
- data/spec/functional/horizontal_spacing/hard_tabs_spec.rb +42 -42
- data/spec/functional/horizontal_spacing/long_lines_spec.rb +15 -17
- data/spec/functional/horizontal_spacing/long_methods_spec.rb +4 -4
- data/spec/functional/horizontal_spacing/parens_spec.rb +45 -45
- data/spec/functional/horizontal_spacing/trailing_whitespace_spec.rb +7 -8
- data/spec/functional/horizontal_spacing_spec.rb +10 -11
- data/spec/functional/indentation_spacing/argument_alignment_spec.rb +33 -62
- data/spec/functional/indentation_spacing/bad_indentation_spec.rb +176 -179
- data/spec/functional/indentation_spacing_spec.rb +13 -14
- data/spec/functional/naming/camel_case_methods_spec.rb +4 -6
- data/spec/functional/naming/screaming_snake_case_classes_spec.rb +28 -31
- data/spec/functional/naming_spec.rb +3 -3
- data/spec/functional/rake_task_spec.rb +9 -28
- data/spec/functional/string_interpolation_spec.rb +1 -1
- data/spec/functional/string_quoting_spec.rb +1 -1
- data/spec/functional/vertical_spacing/class_length_spec.rb +4 -6
- data/spec/functional/vertical_spacing/method_length_spec.rb +15 -17
- data/spec/functional/vertical_spacing_spec.rb +3 -3
- data/spec/spec_helper.rb +2 -0
- data/spec/support/argument_alignment_cases.rb +32 -32
- data/spec/support/conditional_parentheses_cases.rb +26 -26
- data/spec/support/good_indentation_cases.rb +205 -205
- data/spec/support/horizontal_spacing_cases.rb +53 -54
- data/spec/support/line_indentation_cases.rb +20 -20
- data/spec/support/naming_cases.rb +12 -12
- data/spec/support/string_interpolation_cases.rb +17 -17
- data/spec/support/string_quoting_cases.rb +12 -12
- data/spec/support/vertical_spacing_cases.rb +8 -8
- data/spec/unit/tailor/cli/options_spec.rb +20 -14
- data/spec/unit/tailor/cli_spec.rb +29 -43
- data/spec/unit/tailor/composite_observable_spec.rb +1 -1
- data/spec/unit/tailor/configuration/file_set_spec.rb +10 -11
- data/spec/unit/tailor/configuration/style_spec.rb +41 -42
- data/spec/unit/tailor/configuration_spec.rb +14 -12
- data/spec/unit/tailor/formatter_spec.rb +3 -3
- data/spec/unit/tailor/formatters/yaml_spec.rb +12 -13
- data/spec/unit/tailor/lexed_line_spec.rb +67 -69
- data/spec/unit/tailor/lexer/token_spec.rb +7 -7
- data/spec/unit/tailor/lexer_spec.rb +24 -24
- data/spec/unit/tailor/problem_spec.rb +12 -12
- data/spec/unit/tailor/reporter_spec.rb +8 -9
- data/spec/unit/tailor/ruler_spec.rb +10 -10
- data/spec/unit/tailor/rulers/indentation_spaces_ruler/indentation_manager_spec.rb +90 -86
- data/spec/unit/tailor/rulers/indentation_spaces_ruler_spec.rb +13 -13
- data/spec/unit/tailor/rulers/spaces_after_comma_ruler_spec.rb +4 -4
- data/spec/unit/tailor/rulers/spaces_after_lbrace_ruler_spec.rb +19 -19
- data/spec/unit/tailor/rulers/spaces_before_lbrace_ruler_spec.rb +6 -6
- data/spec/unit/tailor/rulers/spaces_before_rbrace_ruler_spec.rb +6 -6
- data/spec/unit/tailor/rulers_spec.rb +1 -1
- data/spec/unit/tailor/version_spec.rb +1 -2
- data/spec/unit/tailor_spec.rb +2 -2
- data/tailor.gemspec +3 -3
- metadata +20 -6
data/README.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
|
1
|
+
tailor
|
2
|
+
======
|
2
3
|
|
3
4
|
* http://github.com/turboladen/tailor
|
4
5
|
|
5
6
|
|
6
7
|
[<img src="https://secure.travis-ci.org/turboladen/tailor.png?branch=master"
|
7
|
-
alt="Build Status" />](http://travis-ci.org/turboladen/tailor) [
|
8
|
-
src="https://codeclimate.com/badge.png"
|
9
|
-
/>](https://codeclimate.com/github/turboladen/tailor)
|
8
|
+
alt="Build Status" />](http://travis-ci.org/turboladen/tailor) [![Code Climate](https://codeclimate.com/github/turboladen/tailor.png)](https://codeclimate.com/github/turboladen/tailor)
|
10
9
|
|
11
|
-
|
10
|
+
DESCRIPTION:
|
11
|
+
------------
|
12
12
|
|
13
13
|
tailor parses Ruby files and measures them with some style and static analysis
|
14
14
|
"rulers". Default values for the Rulers are based on a number of style guides
|
@@ -18,7 +18,8 @@ http://wiki.github.com/turboladen/tailor.
|
|
18
18
|
tailor's goal is to help you be consistent with your style, throughout your
|
19
19
|
project, whatever style that may be.
|
20
20
|
|
21
|
-
|
21
|
+
FEATURES/PROBLEMS:
|
22
|
+
------------------
|
22
23
|
|
23
24
|
* Checks for bad style in Ruby files
|
24
25
|
* Recursively in a directory, or...
|
@@ -61,17 +62,17 @@ project, whatever style that may be.
|
|
61
62
|
* (Well, this may be stretching things a bit, but...) Exit 1 on failures
|
62
63
|
|
63
64
|
|
65
|
+
SYNOPSIS:
|
66
|
+
---------
|
64
67
|
|
65
|
-
|
66
|
-
|
67
|
-
### Why style check?
|
68
|
+
### Why style check? ###
|
68
69
|
|
69
70
|
If you're reading this, there's a good chance you already have your own
|
70
71
|
reasons for doing so. If you're not familiar with static analysis, give
|
71
72
|
tailor a go for a few days and see if you think it improves your code's
|
72
73
|
readability.
|
73
74
|
|
74
|
-
### What's it do?
|
75
|
+
### What's it do? ###
|
75
76
|
|
76
77
|
At tailor's inception, there were some other static analysis tools for Ruby,
|
77
78
|
but none which checked style stuff; tailor started off as a means to fill this
|
@@ -80,7 +81,7 @@ various Ruby 1.9 incompatibilities, and left a bigger tool gap for Rubyists.
|
|
80
81
|
Right now it's mostly a style-checker, but might into a tool for analyzing
|
81
82
|
other aspects of your Ruby code.
|
82
83
|
|
83
|
-
### Since 0.x...
|
84
|
+
### Since 0.x... ###
|
84
85
|
|
85
86
|
tailor 1.x is a marked improvement over 0.x. While 0.x provided a few (pretty
|
86
87
|
inconsistent) style checks, its design made the code get all spaghetti-like,
|
@@ -88,7 +89,7 @@ with lots of really gnarly regular expression matching, making it a really bear
|
|
88
89
|
to add new features and fix bugs. tailor 1.x is completely redesigned to make
|
89
90
|
that whole process much easier.
|
90
91
|
|
91
|
-
### Measure Stuff
|
92
|
+
### Measure Stuff ###
|
92
93
|
|
93
94
|
Check *all* files in a directory:
|
94
95
|
|
@@ -131,7 +132,7 @@ require 'tailor/rake_task'
|
|
131
132
|
Tailor::RakeTask.new
|
132
133
|
```
|
133
134
|
|
134
|
-
#### On style...
|
135
|
+
#### On style... ####
|
135
136
|
|
136
137
|
The features list, above, shows some aspects of style that should be fairly
|
137
138
|
straightforward (as to their meaning and reason), however, others make some
|
@@ -199,7 +200,7 @@ uses; it just might not support your style yet. If tailor doesn't support
|
|
199
200
|
your style, please feel free to take a look at the issues list and make a
|
200
201
|
request. ...or fork away!
|
201
202
|
|
202
|
-
### Configurable:
|
203
|
+
### Configurable: ###
|
203
204
|
|
204
205
|
Not everyone prefers the same style of, well, anything really. tailor is
|
205
206
|
configurable to allow you to check your code against the style measurements
|
@@ -208,7 +209,7 @@ that you want.
|
|
208
209
|
It has default values for each of the "rulers" it uses, but if you want to
|
209
210
|
customize these, there are a number of ways you can do so.
|
210
211
|
|
211
|
-
#### CLI
|
212
|
+
#### CLI ####
|
212
213
|
|
213
214
|
At any time, you can tell tailor to show you the configuration that it's going
|
214
215
|
to use by doing:
|
@@ -236,7 +237,7 @@ If you want to simply disable a ruler, just pass `off` to the option:
|
|
236
237
|
$ tailor --max-line-length off lib/
|
237
238
|
```
|
238
239
|
|
239
|
-
#### Configuration File
|
240
|
+
#### Configuration File ####
|
240
241
|
|
241
242
|
While you can drive most tailor options from the command line, configuration
|
242
243
|
files allow for some more flexibility with style rulers, file lists, and
|
@@ -264,7 +265,7 @@ end
|
|
264
265
|
|
265
266
|
This brings us to the concept of "file sets"...
|
266
267
|
|
267
|
-
##### File Sets
|
268
|
+
##### File Sets #####
|
268
269
|
|
269
270
|
File sets allow you to use different style rulers against different groups of
|
270
271
|
files. You may, for example, want your Rails app code to allow for longer
|
@@ -330,7 +331,7 @@ Tailor.config do |config|
|
|
330
331
|
end
|
331
332
|
```
|
332
333
|
|
333
|
-
##### Formatters
|
334
|
+
##### Formatters #####
|
334
335
|
|
335
336
|
By default Tailor uses the text formatter, printing the results on console.
|
336
337
|
Tailor also provides a YAML formatter, that accepts an output file if using
|
@@ -346,36 +347,36 @@ Tailor.config do |config|
|
|
346
347
|
end
|
347
348
|
```
|
348
349
|
|
349
|
-
### Define A Custom Ruler
|
350
|
+
### Define A Custom Ruler ###
|
350
351
|
|
351
352
|
While tailor provides a number of Rulers for checking style, it also provides
|
352
353
|
a way for you to add your own rulers without having to delve into its innards.
|
353
354
|
To do this, you need to do the following.
|
354
355
|
|
355
|
-
#### Create the Ruler
|
356
|
+
#### Create the Ruler ####
|
356
357
|
|
357
358
|
Before jumping in to this, take a look at {Tailor::Ruler} and any of the
|
358
359
|
existing Rulers in `lib/tailor/rulers/`. There are some key things a new
|
359
360
|
Ruler must have:
|
360
361
|
|
361
|
-
*
|
362
|
-
*
|
363
|
-
*
|
364
|
-
*
|
365
|
-
1
|
366
|
-
|
367
|
-
2
|
368
|
-
|
362
|
+
* the class name ends with "Ruler"
|
363
|
+
* it inherits {Tailor::Ruler}
|
364
|
+
* it's defined within the {Tailor::Rulers} module
|
365
|
+
* `#initialize` defines two parameters:
|
366
|
+
1.`config` sets `@config` to the "golden rule" value for what you're
|
367
|
+
measuring
|
368
|
+
2.`options` is a Hash, that should at least be passed the `:level =>` you
|
369
|
+
want the problem to be logged as
|
369
370
|
|
370
|
-
*
|
371
|
-
|
372
|
-
*
|
373
|
-
|
374
|
-
*
|
375
|
-
*
|
371
|
+
* `#add_lexer_observers` gets passed a list of {Tailor::Lexer} event types
|
372
|
+
that the ruler should get notified on
|
373
|
+
* it defines call-back methods for {Tailor::Lexer} to call when it comes
|
374
|
+
across an event of interest
|
375
|
+
* it calls `#measure` to assess if the criteria it's checking has been met
|
376
|
+
* it adds a {Tailor::Problem} to +@problems+ when one is found in `#measure`
|
376
377
|
|
377
378
|
|
378
|
-
#### Add the Ruler to the list of Styles
|
379
|
+
#### Add the Ruler to the list of Styles ####
|
379
380
|
|
380
381
|
Internally, this all happens in `lib/tailor/configuration/style.rb`, but you
|
381
382
|
can add information about your ruler to your config file. If you created a
|
@@ -427,7 +428,7 @@ end
|
|
427
428
|
|
428
429
|
Next time you run tailor, your Ruler will get initialized and used.
|
429
430
|
|
430
|
-
### Using the lib
|
431
|
+
### Using the lib ###
|
431
432
|
|
432
433
|
Sometimes you could use tailor as a lib, getting the results as a hash and
|
433
434
|
manipulate them according your domain.
|
@@ -448,13 +449,12 @@ tailor = Tailor::CLI.new %w(--output-file=results.yaml)
|
|
448
449
|
tailor.execute!
|
449
450
|
```
|
450
451
|
|
451
|
-
|
452
|
+
REQUIREMENTS:
|
453
|
+
-------------
|
452
454
|
|
453
455
|
* Rubies (tested)
|
454
|
-
*
|
455
|
-
* 2.
|
456
|
-
* 2.1.0
|
457
|
-
|
456
|
+
* ruby-2.0.0
|
457
|
+
* ruby-2.1.4
|
458
458
|
* Gems
|
459
459
|
* log_switch
|
460
460
|
* nokogiri
|
@@ -462,16 +462,29 @@ tailor.execute!
|
|
462
462
|
* text-table
|
463
463
|
|
464
464
|
|
465
|
-
|
466
|
-
|
465
|
+
INSTALL:
|
466
|
+
--------
|
467
467
|
|
468
468
|
$ (sudo) gem install tailor
|
469
469
|
|
470
|
-
|
470
|
+
|
471
|
+
RELATED PROJECTS:
|
472
|
+
-----------------
|
473
|
+
|
474
|
+
* [rubocop](https://github.com/bbatsov/rubocop). *A robust Ruby code analyzer, based on the community Ruby style guide.*
|
475
|
+
* [cane](https://github.com/square/cane). *Code quality threshold checking as part of your build*
|
476
|
+
* [roodi](https://github.com/roodi/roodi). *Ruby Object Oriented Design Inferometer*
|
477
|
+
* [reek](https://github.com/troessner/reek/wiki). *Code smell detector for Ruby*
|
478
|
+
* [flog](http://ruby.sadi.st/Ruby_Sadist.html). *Flog shows you the most torturous code you wrote. The more painful the code, the higher the score.*
|
479
|
+
* [foodcritic](http://www.foodcritic.io). *Foodcritic is a helpful lint tool you can use to check your Chef cookbooks for common problems.*
|
480
|
+
* [metric_fu](https://github.com/metricfu/metric_fu). *A fist full of code metrics*
|
481
|
+
|
482
|
+
LICENSE:
|
483
|
+
--------
|
471
484
|
|
472
485
|
(The MIT License)
|
473
486
|
|
474
|
-
Copyright (c) 2010-
|
487
|
+
Copyright (c) 2010-2014 Steve Loveless
|
475
488
|
|
476
489
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
477
490
|
of this software and associated documentation files (the 'Software'), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Given /^(.+) exists with(\w*) a newline at the end$/ do |file_name, no_newline|
|
2
2
|
file_contents = get_file_contents(file_name)
|
3
|
-
file_contents.
|
3
|
+
expect(file_contents).to_not be_nil
|
4
4
|
|
5
5
|
if no_newline.empty?
|
6
6
|
file_contents << "\n" unless file_contents[-1] == "\n"
|
data/lib/tailor/reporter.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
class Tailor
|
2
|
-
|
3
2
|
# Objects of this type are responsible for sending the right data to report
|
4
3
|
# formatters.
|
5
4
|
class Reporter
|
@@ -11,13 +10,26 @@ class Tailor
|
|
11
10
|
#
|
12
11
|
# @param [Array] formats A list of formatters to use for generating reports.
|
13
12
|
def initialize(*formats)
|
14
|
-
|
15
|
-
formats = %w[text] if formats.nil? || formats.empty?
|
13
|
+
formats = %w(text) if formats.nil? || formats.empty?
|
16
14
|
|
17
|
-
formats.flatten.
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
@formatters = formats.flatten.map do |formatter|
|
16
|
+
retried = false
|
17
|
+
|
18
|
+
begin
|
19
|
+
Tailor::Formatters.const_get(formatter.capitalize).new
|
20
|
+
rescue NameError
|
21
|
+
require_relative "formatters/#{formatter}"
|
22
|
+
|
23
|
+
if retried
|
24
|
+
next
|
25
|
+
else
|
26
|
+
retried = true
|
27
|
+
retry
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end.uniq
|
31
|
+
|
32
|
+
@formatters.compact!
|
21
33
|
end
|
22
34
|
|
23
35
|
# Sends the data to each +@formatters+ to generate the report of problems
|
data/lib/tailor/version.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'tailor/configuration'
|
3
3
|
|
4
|
-
|
5
4
|
describe 'Config File' do
|
6
5
|
before do
|
7
|
-
Tailor::Logger.
|
6
|
+
allow(Tailor::Logger).to receive(:log)
|
8
7
|
FakeFS.deactivate!
|
9
8
|
end
|
10
9
|
|
@@ -22,22 +21,24 @@ describe 'Config File' do
|
|
22
21
|
|
23
22
|
context '.tailor does not exist' do
|
24
23
|
before do
|
25
|
-
Tailor::Configuration.
|
24
|
+
allow_any_instance_of(Tailor::Configuration).to receive(:config_file).
|
25
|
+
and_return false
|
26
26
|
end
|
27
27
|
|
28
28
|
it "sets formatters to 'text'" do
|
29
|
-
config.formatters.
|
29
|
+
expect(config.formatters).to eq %w(text)
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'sets file_sets[:default].style to the default style' do
|
33
|
-
config.file_sets[:default].style.
|
34
|
-
config.file_sets[:default].style.
|
33
|
+
expect(config.file_sets[:default].style).to_not be_nil
|
34
|
+
expect(config.file_sets[:default].style).
|
35
|
+
to eq Tailor::Configuration::Style.new.to_hash
|
35
36
|
end
|
36
37
|
|
37
38
|
it 'sets file_sets[:default].file_list to the files in lib/**/*.rb' do
|
38
|
-
config.file_sets[:default].file_list.all? do |path|
|
39
|
+
expect(config.file_sets[:default].file_list.all? do |path|
|
39
40
|
path =~ /tailor\/lib/
|
40
|
-
end.
|
41
|
+
end).to eq true
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
@@ -56,23 +57,25 @@ end
|
|
56
57
|
end
|
57
58
|
|
58
59
|
before do
|
59
|
-
File.
|
60
|
+
expect(File).to receive(:read).and_return config_file
|
60
61
|
end
|
61
62
|
|
62
63
|
it 'creates the default file set' do
|
63
|
-
config.file_sets[:default].style.
|
64
|
-
|
64
|
+
expect(config.file_sets[:default].style).
|
65
|
+
to eq Tailor::Configuration::Style.new.to_hash
|
66
|
+
|
67
|
+
expect(config.file_sets[:default].file_list.all? do |path|
|
65
68
|
path =~ /tailor\/lib/
|
66
|
-
end.
|
69
|
+
end).to eq true
|
67
70
|
end
|
68
71
|
|
69
72
|
it 'creates the :features file set' do
|
70
73
|
style = Tailor::Configuration::Style.new
|
71
74
|
style.max_line_length(90, level: :warn)
|
72
|
-
config.file_sets[:features].style.
|
73
|
-
config.file_sets[:features].file_list.all? do |path|
|
75
|
+
expect(config.file_sets[:features].style).to eq style.to_hash
|
76
|
+
expect(config.file_sets[:features].file_list.all? do |path|
|
74
77
|
path =~ /features/
|
75
|
-
end.
|
78
|
+
end).to eq true
|
76
79
|
end
|
77
80
|
end
|
78
81
|
end
|
@@ -89,15 +92,15 @@ end
|
|
89
92
|
end
|
90
93
|
|
91
94
|
before do
|
92
|
-
File.
|
95
|
+
expect(File).to receive(:read).and_return config_file
|
93
96
|
end
|
94
97
|
|
95
98
|
it 'does not create a :default file set' do
|
96
|
-
config.file_sets.
|
99
|
+
expect(config.file_sets).to_not include :default
|
97
100
|
end
|
98
101
|
|
99
102
|
it 'creates the non-default file set' do
|
100
|
-
config.file_sets.
|
103
|
+
expect(config.file_sets).to include :features
|
101
104
|
end
|
102
105
|
end
|
103
106
|
|
@@ -113,17 +116,17 @@ end
|
|
113
116
|
end
|
114
117
|
|
115
118
|
before do
|
116
|
-
File.
|
119
|
+
expect(File).to receive(:read).and_return config_file
|
117
120
|
end
|
118
121
|
|
119
122
|
it 'creates a :default file set' do
|
120
|
-
config.file_sets.keys.
|
123
|
+
expect(config.file_sets.keys).to eq [:default]
|
121
124
|
end
|
122
125
|
|
123
126
|
it 'has files in the file list levels deep' do
|
124
|
-
config.file_sets[:default].file_list.all? do |file|
|
127
|
+
expect(config.file_sets[:default].file_list.all? do |file|
|
125
128
|
file =~ /spec\.rb$/
|
126
|
-
end.
|
129
|
+
end).to eq true
|
127
130
|
end
|
128
131
|
|
129
132
|
it 'applies the nested configuration within the fileset' do
|
@@ -144,21 +147,24 @@ end
|
|
144
147
|
|
145
148
|
context '.tailor does not exist' do
|
146
149
|
before do
|
147
|
-
Tailor::Configuration
|
150
|
+
allow_any_instance_of(Tailor::Configuration).
|
151
|
+
to receive(:config_file).and_return false
|
148
152
|
end
|
149
153
|
|
150
154
|
it "sets formatters to 'text'" do
|
151
|
-
config.formatters.
|
155
|
+
expect(config.formatters).to eq %w(text)
|
152
156
|
end
|
153
157
|
|
154
158
|
it 'sets file_sets[:default].style to the default style' do
|
155
|
-
config.file_sets[:default].style.
|
156
|
-
config.file_sets[:default].style.
|
159
|
+
expect(config.file_sets[:default].style).to_not be_nil
|
160
|
+
expect(config.file_sets[:default].style).
|
161
|
+
to eq Tailor::Configuration::Style.new.to_hash
|
157
162
|
end
|
158
163
|
|
159
164
|
it 'sets file_sets[:default].file_list to the runtime files' do
|
160
|
-
config.file_sets[:default].file_list.size.
|
161
|
-
config.file_sets[:default].file_list.first.
|
165
|
+
expect(config.file_sets[:default].file_list.size).to eq 1
|
166
|
+
expect(config.file_sets[:default].file_list.first).
|
167
|
+
to match(/lib\/tailor\.rb$/)
|
162
168
|
end
|
163
169
|
end
|
164
170
|
|
@@ -179,19 +185,20 @@ end
|
|
179
185
|
end
|
180
186
|
|
181
187
|
before do
|
182
|
-
File.
|
188
|
+
expect(File).to receive(:read).and_return config_file
|
183
189
|
end
|
184
190
|
|
185
191
|
it 'creates the default file set using the runtime files' do
|
186
192
|
style = Tailor::Configuration::Style.new
|
187
193
|
style.max_line_length 85
|
188
|
-
config.file_sets[:default].style.
|
189
|
-
config.file_sets[:default].file_list.size.
|
190
|
-
config.file_sets[:default].file_list.first.
|
194
|
+
expect(config.file_sets[:default].style).to eq style.to_hash
|
195
|
+
expect(config.file_sets[:default].file_list.size).to eq 1
|
196
|
+
expect(config.file_sets[:default].file_list.first).
|
197
|
+
to match(/lib\/tailor\.rb$/)
|
191
198
|
end
|
192
199
|
|
193
200
|
it 'does not create the :features file set' do
|
194
|
-
config.file_sets.
|
201
|
+
expect(config.file_sets).to_not include :features
|
195
202
|
end
|
196
203
|
end
|
197
204
|
end
|
@@ -208,17 +215,19 @@ end
|
|
208
215
|
end
|
209
216
|
|
210
217
|
before do
|
211
|
-
File.
|
218
|
+
expect(File).to receive(:read).and_return config_file
|
212
219
|
end
|
213
220
|
|
214
|
-
it 'creates a :default file set with the runtime file
|
215
|
-
config.file_sets[:default].style.
|
216
|
-
|
217
|
-
config.file_sets[:default].file_list.
|
221
|
+
it 'creates a :default file set with the runtime file & default style' do
|
222
|
+
expect(config.file_sets[:default].style).
|
223
|
+
to eq Tailor::Configuration::Style.new.to_hash
|
224
|
+
expect(config.file_sets[:default].file_list.size).to eq 1
|
225
|
+
expect(config.file_sets[:default].file_list.first).
|
226
|
+
to match(/lib\/tailor\.rb$/)
|
218
227
|
end
|
219
228
|
|
220
229
|
it 'does not create the non-default file set' do
|
221
|
-
config.file_sets.
|
230
|
+
expect(config.file_sets).to_not include :features
|
222
231
|
end
|
223
232
|
end
|
224
233
|
|
@@ -234,20 +243,21 @@ end
|
|
234
243
|
end
|
235
244
|
|
236
245
|
before do
|
237
|
-
File.
|
246
|
+
expect(File).to receive(:read).and_return config_file
|
238
247
|
end
|
239
248
|
|
240
249
|
it 'creates a :default file set' do
|
241
|
-
config.file_sets.keys.
|
250
|
+
expect(config.file_sets.keys).to eq [:default]
|
242
251
|
end
|
243
252
|
|
244
|
-
it 'creates a :default file set with the runtime file
|
245
|
-
style = Tailor::Configuration::Style.new.tap do |
|
246
|
-
|
253
|
+
it 'creates a :default file set with the runtime file & default style' do
|
254
|
+
style = Tailor::Configuration::Style.new.tap do |s|
|
255
|
+
s.max_line_length 90, level: :warn
|
247
256
|
end.to_hash
|
248
|
-
config.file_sets[:default].style.
|
249
|
-
config.file_sets[:default].file_list.size.
|
250
|
-
config.file_sets[:default].file_list.first.
|
257
|
+
expect(config.file_sets[:default].style).to eq style
|
258
|
+
expect(config.file_sets[:default].file_list.size).to eq 1
|
259
|
+
expect(config.file_sets[:default].file_list.first).
|
260
|
+
to match(/lib\/tailor\.rb$/)
|
251
261
|
end
|
252
262
|
end
|
253
263
|
|
@@ -261,11 +271,11 @@ end
|
|
261
271
|
end
|
262
272
|
|
263
273
|
before do
|
264
|
-
File.
|
274
|
+
expect(File).to receive(:read).and_return config_file
|
265
275
|
end
|
266
276
|
|
267
277
|
it "sets formatters to 'yaml'" do
|
268
|
-
config.formatters.
|
278
|
+
expect(config.formatters).to eq %w(yaml)
|
269
279
|
end
|
270
280
|
end
|
271
281
|
|
@@ -279,13 +289,12 @@ end
|
|
279
289
|
end
|
280
290
|
|
281
291
|
before do
|
282
|
-
File.
|
292
|
+
expect(File).to receive(:read).and_return config_file
|
283
293
|
end
|
284
294
|
|
285
295
|
it 'sets formatters to the defined' do
|
286
|
-
config.formatters.
|
296
|
+
expect(config.formatters).to eq %w(yaml text)
|
287
297
|
end
|
288
|
-
|
289
298
|
end
|
290
299
|
end
|
291
300
|
end
|