polishgeeks-dev-tools 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +3 -2
- data/CHANGELOG.md +69 -0
- data/Gemfile.lock +76 -81
- data/README.md +28 -22
- data/Rakefile +4 -3
- data/config/rubocop.yml +16 -16
- data/config/rubocop_todo.yml +14 -0
- data/lib/polish_geeks/dev_tools.rb +26 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/allowed_extensions.rb +4 -4
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/base.rb +18 -3
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/brakeman.rb +5 -2
- data/lib/polish_geeks/dev_tools/commands/bundler_audit.rb +23 -0
- data/lib/{polishgeeks/dev-tools/commands/empty_method.rb → polish_geeks/dev_tools/commands/empty_methods.rb} +3 -13
- data/lib/{polishgeeks/dev-tools/commands/empty_method → polish_geeks/dev_tools/commands/empty_methods}/file_parser.rb +1 -1
- data/lib/{polishgeeks/dev-tools/commands/empty_method → polish_geeks/dev_tools/commands/empty_methods}/string_refinements.rb +2 -2
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/examples_comparator.rb +13 -7
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/expires_in.rb +6 -6
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/final_blank_line.rb +1 -11
- data/lib/polish_geeks/dev_tools/commands/gemfile.rb +39 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/haml_lint.rb +0 -0
- data/lib/polish_geeks/dev_tools/commands/required_files.rb +38 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/rspec.rb +24 -5
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/rspec_files_names.rb +1 -1
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/rspec_files_structure.rb +22 -9
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/rubocop.rb +10 -8
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/rubycritic.rb +0 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/simplecov.rb +0 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/tasks_files_names.rb +0 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/yard.rb +0 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/yml_parser.rb +0 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/config.rb +24 -16
- data/lib/polish_geeks/dev_tools/config_manager.rb +68 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/errors.rb +0 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/hash.rb +0 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/logger.rb +3 -3
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/output_storer.rb +0 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/runner.rb +0 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/shell.rb +0 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/tasks/dev-tools.rake +0 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/validators/base.rb +2 -2
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/validators/rails.rb +0 -0
- data/lib/polish_geeks/dev_tools/validators/rubocop.rb +12 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/validators/simplecov.rb +1 -1
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/version.rb +1 -1
- data/lib/polishgeeks-dev-tools.rb +6 -31
- data/polishgeeks_dev_tools.gemspec +6 -5
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/allowed_extensions_spec.rb +5 -17
- data/spec/lib/polish_geeks/dev_tools/commands/base_spec.rb +90 -0
- data/spec/lib/polish_geeks/dev_tools/commands/brakeman_spec.rb +99 -0
- data/spec/lib/polish_geeks/dev_tools/commands/bundler_audit_spec.rb +52 -0
- data/spec/lib/{polishgeeks/dev-tools/commands/empty_method → polish_geeks/dev_tools/commands/empty_methods}/file_parser_spec.rb +1 -1
- data/spec/lib/{polishgeeks/dev-tools/commands/empty_method → polish_geeks/dev_tools/commands/empty_methods}/string_refinements_spec.rb +1 -1
- data/spec/lib/{polishgeeks/dev-tools/commands/empty_method_spec.rb → polish_geeks/dev_tools/commands/empty_methods_spec.rb} +7 -54
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/examples_comparator_spec.rb +8 -8
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/expires_in_spec.rb +1 -1
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/final_blank_line_spec.rb +2 -45
- data/spec/lib/polish_geeks/dev_tools/commands/gemfile_spec.rb +91 -0
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/haml_lint_spec.rb +13 -21
- data/spec/lib/polish_geeks/dev_tools/commands/required_files_spec.rb +51 -0
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/rspec_files_names_spec.rb +2 -2
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/rspec_files_structure_spec.rb +19 -32
- data/spec/lib/polish_geeks/dev_tools/commands/rspec_spec.rb +106 -0
- data/spec/lib/polish_geeks/dev_tools/commands/rubocop_spec.rb +131 -0
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/rubycritic_spec.rb +5 -3
- data/spec/lib/polish_geeks/dev_tools/commands/simplecov_spec.rb +136 -0
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/tasks_files_names_spec.rb +8 -8
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/yard_spec.rb +10 -10
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/yml_parser_spec.rb +2 -2
- data/spec/lib/polish_geeks/dev_tools/config_manager_spec.rb +124 -0
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/config_spec.rb +3 -3
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/errors_spec.rb +0 -0
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/hash_spec.rb +8 -8
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/logger_spec.rb +9 -9
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/output_storer_spec.rb +1 -1
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/runner_spec.rb +0 -0
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/shell_spec.rb +1 -1
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/validators/base_spec.rb +0 -0
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/validators/rails_spec.rb +0 -0
- data/spec/lib/polish_geeks/dev_tools/validators/rubocop_spec.rb +29 -0
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/validators/simplecov_spec.rb +1 -1
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/version_spec.rb +0 -0
- data/spec/lib/{polishgeeks-dev-tools_spec.rb → polish_geeks/dev_tools_spec.rb} +2 -2
- data/spec/spec_helper.rb +1 -1
- metadata +141 -99
- data/lib/polishgeeks/dev-tools/commands/readme.rb +0 -32
- data/spec/lib/polishgeeks/dev-tools/commands/base_spec.rb +0 -55
- data/spec/lib/polishgeeks/dev-tools/commands/brakeman_spec.rb +0 -96
- data/spec/lib/polishgeeks/dev-tools/commands/readme_spec.rb +0 -38
- data/spec/lib/polishgeeks/dev-tools/commands/rspec_spec.rb +0 -63
- data/spec/lib/polishgeeks/dev-tools/commands/rubocop_spec.rb +0 -127
- data/spec/lib/polishgeeks/dev-tools/commands/simplecov_spec.rb +0 -134
data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/examples_comparator_spec.rb
RENAMED
@@ -27,7 +27,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::ExamplesComparator do
|
|
27
27
|
context 'when compared files structure is the same' do
|
28
28
|
let(:compare_result) { true }
|
29
29
|
|
30
|
-
it '
|
30
|
+
it 'puts a successful message into output' do
|
31
31
|
subject.execute
|
32
32
|
|
33
33
|
expect(subject.output).to include 'success'
|
@@ -37,7 +37,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::ExamplesComparator do
|
|
37
37
|
context 'when compared files structure is not the same' do
|
38
38
|
let(:compare_result) { false }
|
39
39
|
|
40
|
-
it '
|
40
|
+
it 'puts a failed message into output' do
|
41
41
|
subject.execute
|
42
42
|
expect(subject.output).to include 'failed'
|
43
43
|
end
|
@@ -49,7 +49,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::ExamplesComparator do
|
|
49
49
|
"#{File.expand_path(PolishGeeks::DevTools.app_root + '/config')}/**/*.yml.example"
|
50
50
|
end
|
51
51
|
|
52
|
-
it '
|
52
|
+
it 'is equal to expected message' do
|
53
53
|
expect(subject.send(:config_path)).to eq expected
|
54
54
|
end
|
55
55
|
end
|
@@ -58,7 +58,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::ExamplesComparator do
|
|
58
58
|
let(:compare_header) { rand.to_s }
|
59
59
|
let(:expected) { "\e[32m success\e[0m - #{compare_header}\n" }
|
60
60
|
|
61
|
-
it '
|
61
|
+
it 'is equal to expected message' do
|
62
62
|
expect(subject.send(:successful_compare, compare_header)).to eq expected
|
63
63
|
end
|
64
64
|
end
|
@@ -67,7 +67,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::ExamplesComparator do
|
|
67
67
|
let(:compare_header) { rand.to_s }
|
68
68
|
let(:expected) { "\e[31m failed\e[0m - #{compare_header} - structure not equal\n" }
|
69
69
|
|
70
|
-
it '
|
70
|
+
it 'is equal to expected message' do
|
71
71
|
expect(subject.send(:failed_compare, compare_header)).to eq expected
|
72
72
|
end
|
73
73
|
end
|
@@ -75,7 +75,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::ExamplesComparator do
|
|
75
75
|
describe '#compare_header' do
|
76
76
|
let(:expected) { "#{File.basename(example_file)} and #{File.basename(dedicated_file)}" }
|
77
77
|
|
78
|
-
it '
|
78
|
+
it 'is equal to expected message' do
|
79
79
|
expect(subject.send(:compare_header, example_file, dedicated_file)).to eq expected
|
80
80
|
end
|
81
81
|
end
|
@@ -145,7 +145,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::ExamplesComparator do
|
|
145
145
|
subject.instance_variable_set(:@output, 'OK')
|
146
146
|
end
|
147
147
|
|
148
|
-
it '
|
148
|
+
it 'returns true' do
|
149
149
|
expect(subject.valid?).to eq true
|
150
150
|
end
|
151
151
|
end
|
@@ -155,7 +155,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::ExamplesComparator do
|
|
155
155
|
subject.instance_variable_set(:@output, 'failed')
|
156
156
|
end
|
157
157
|
|
158
|
-
it '
|
158
|
+
it 'returns false' do
|
159
159
|
expect(subject.valid?).to eq false
|
160
160
|
end
|
161
161
|
end
|
data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/final_blank_line_spec.rb
RENAMED
@@ -21,7 +21,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::FinalBlankLine do
|
|
21
21
|
subject.execute
|
22
22
|
end
|
23
23
|
|
24
|
-
it '
|
24
|
+
it 'sets appropriate variables' do
|
25
25
|
expect(subject.output).to eq []
|
26
26
|
expect(subject.counter).to eq(files.count)
|
27
27
|
end
|
@@ -43,7 +43,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::FinalBlankLine do
|
|
43
43
|
subject.execute
|
44
44
|
end
|
45
45
|
|
46
|
-
it '
|
46
|
+
it 'sets appropriate variables' do
|
47
47
|
expect(subject.output).to eq files
|
48
48
|
expect(subject.counter).to eq(files.count)
|
49
49
|
end
|
@@ -157,49 +157,6 @@ RSpec.describe PolishGeeks::DevTools::Commands::FinalBlankLine do
|
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
160
|
-
describe '#files_from_path' do
|
161
|
-
let(:app_root) { PolishGeeks::DevTools.app_root }
|
162
|
-
|
163
|
-
context 'path is a directory' do
|
164
|
-
let(:path) { rand.to_s }
|
165
|
-
let(:file_in_path) { "#{app_root}/#{rand}" }
|
166
|
-
let(:dir_in_path) { "#{app_root}/#{rand}" }
|
167
|
-
before do
|
168
|
-
expect(File)
|
169
|
-
.to receive(:file?)
|
170
|
-
.with("#{app_root}/#{path}")
|
171
|
-
.and_return(false)
|
172
|
-
|
173
|
-
expect(Dir)
|
174
|
-
.to receive(:glob)
|
175
|
-
.with("#{app_root}/#{path}")
|
176
|
-
.and_return([file_in_path, dir_in_path])
|
177
|
-
|
178
|
-
expect(File)
|
179
|
-
.to receive(:file?)
|
180
|
-
.with(file_in_path)
|
181
|
-
.and_return(true)
|
182
|
-
|
183
|
-
expect(File)
|
184
|
-
.to receive(:file?)
|
185
|
-
.with(dir_in_path)
|
186
|
-
.and_return(false)
|
187
|
-
end
|
188
|
-
it { expect(subject.send(:files_from_path, path)).to eq [file_in_path] }
|
189
|
-
end
|
190
|
-
|
191
|
-
context 'path is a file' do
|
192
|
-
let(:path) { rand.to_s }
|
193
|
-
before do
|
194
|
-
expect(File)
|
195
|
-
.to receive(:file?)
|
196
|
-
.with("#{app_root}/#{path}")
|
197
|
-
.and_return(true)
|
198
|
-
end
|
199
|
-
it { expect(subject.send(:files_from_path, path)).to eq ["#{app_root}/#{path}"] }
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
160
|
describe '#sanitize' do
|
204
161
|
let(:file) { rand.to_s }
|
205
162
|
let(:app_root) { PolishGeeks::DevTools.app_root }
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe PolishGeeks::DevTools::Commands::Gemfile do
|
4
|
+
subject { described_class.new }
|
5
|
+
|
6
|
+
describe '#execute' do
|
7
|
+
let(:wrong_gem) { rand.to_s }
|
8
|
+
let(:gemfile) { double }
|
9
|
+
let(:output) { [rand.to_s] }
|
10
|
+
|
11
|
+
before do
|
12
|
+
expect(File)
|
13
|
+
.to receive(:join)
|
14
|
+
.with(::PolishGeeks::DevTools.app_root, 'Gemfile')
|
15
|
+
.and_return(gemfile)
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'gemfile file exists' do
|
19
|
+
before do
|
20
|
+
expect(File)
|
21
|
+
.to receive(:exist?)
|
22
|
+
.with(gemfile)
|
23
|
+
.and_return(true)
|
24
|
+
|
25
|
+
expect(IO)
|
26
|
+
.to receive(:readlines)
|
27
|
+
.with(gemfile)
|
28
|
+
.and_return([wrong_gem])
|
29
|
+
|
30
|
+
expect(wrong_gem)
|
31
|
+
.to receive(:match)
|
32
|
+
.with(described_class::CHECKED_REGEXP)
|
33
|
+
.and_return(true)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'set wrong gems to output' do
|
37
|
+
subject.execute
|
38
|
+
expect(subject.output).to eq [wrong_gem]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'gemfile file does not exist' do
|
43
|
+
before do
|
44
|
+
expect(File)
|
45
|
+
.to receive(:exist?)
|
46
|
+
.with(gemfile)
|
47
|
+
.and_return(false)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'set empty array to output' do
|
51
|
+
subject.execute
|
52
|
+
expect(subject.output).to eq []
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#label' do
|
58
|
+
it { expect(subject.label).to eq 'Gemfile checking' }
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#error_message' do
|
62
|
+
let(:output) { [rand.to_s, rand.to_s] }
|
63
|
+
|
64
|
+
before do
|
65
|
+
subject.instance_variable_set('@output', output)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'contains output with wrong gems' do
|
69
|
+
expect(subject.error_message)
|
70
|
+
.to eq "Gemfile contains gems from local path: \n#{output.join('')}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '#valid?' do
|
75
|
+
context 'when output is empty' do
|
76
|
+
before do
|
77
|
+
subject.instance_variable_set('@output', [])
|
78
|
+
end
|
79
|
+
|
80
|
+
it { expect(subject.valid?).to be true }
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'when output is not empty' do
|
84
|
+
before do
|
85
|
+
subject.instance_variable_set('@output', [rand.to_s])
|
86
|
+
end
|
87
|
+
|
88
|
+
it { expect(subject.valid?).to be false }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -4,25 +4,22 @@ RSpec.describe PolishGeeks::DevTools::Commands::HamlLint do
|
|
4
4
|
subject { described_class.new }
|
5
5
|
|
6
6
|
describe '#execute' do
|
7
|
+
let(:instance) { instance_double(PolishGeeks::DevTools::Shell) }
|
7
8
|
let(:path) { '/' }
|
9
|
+
|
8
10
|
before do
|
9
|
-
expect(ENV)
|
10
|
-
|
11
|
-
.with('BUNDLE_GEMFILE')
|
12
|
-
.and_return(path)
|
11
|
+
expect(ENV).to receive(:[]).with('BUNDLE_GEMFILE') { path }
|
12
|
+
allow(PolishGeeks::DevTools::Shell).to receive(:new) { instance }
|
13
13
|
end
|
14
14
|
|
15
15
|
context 'when app config exists' do
|
16
16
|
before do
|
17
|
-
expect(File)
|
18
|
-
|
19
|
-
.and_return(true)
|
20
|
-
expect_any_instance_of(PolishGeeks::DevTools::Shell)
|
21
|
-
.to receive(:execute)
|
17
|
+
expect(File).to receive(:exist?) { true }
|
18
|
+
expect(instance).to receive(:execute)
|
22
19
|
.with("bundle exec haml-lint -c #{path}.haml-lint.yml app/views")
|
23
20
|
end
|
24
21
|
|
25
|
-
it '
|
22
|
+
it 'executes the command' do
|
26
23
|
subject.execute
|
27
24
|
end
|
28
25
|
end
|
@@ -30,18 +27,13 @@ RSpec.describe PolishGeeks::DevTools::Commands::HamlLint do
|
|
30
27
|
context 'when app config does not exist' do
|
31
28
|
let(:path) { Dir.pwd }
|
32
29
|
before do
|
33
|
-
expect(PolishGeeks::DevTools)
|
34
|
-
|
35
|
-
|
36
|
-
expect(File)
|
37
|
-
.to receive(:exist?)
|
38
|
-
.and_return(false)
|
39
|
-
expect_any_instance_of(PolishGeeks::DevTools::Shell)
|
40
|
-
.to receive(:execute)
|
30
|
+
expect(PolishGeeks::DevTools).to receive(:gem_root) { path }
|
31
|
+
expect(File).to receive(:exist?) { false }
|
32
|
+
expect(instance).to receive(:execute)
|
41
33
|
.with("bundle exec haml-lint -c #{path}/config/haml-lint.yml app/views")
|
42
34
|
end
|
43
35
|
|
44
|
-
it '
|
36
|
+
it 'executes the command' do
|
45
37
|
subject.execute
|
46
38
|
end
|
47
39
|
end
|
@@ -53,7 +45,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::HamlLint do
|
|
53
45
|
subject.instance_variable_set('@output', '[W] SpaceInsideHashAttributes')
|
54
46
|
end
|
55
47
|
|
56
|
-
it '
|
48
|
+
it 'is false' do
|
57
49
|
expect(subject.valid?).to eq false
|
58
50
|
end
|
59
51
|
end
|
@@ -63,7 +55,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::HamlLint do
|
|
63
55
|
subject.instance_variable_set('@output', '')
|
64
56
|
end
|
65
57
|
|
66
|
-
it '
|
58
|
+
it 'is true' do
|
67
59
|
expect(subject.valid?).to eq true
|
68
60
|
end
|
69
61
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe PolishGeeks::DevTools::Commands::RequiredFiles do
|
4
|
+
subject { described_class.new }
|
5
|
+
|
6
|
+
let(:config) { double }
|
7
|
+
|
8
|
+
describe '#execute' do
|
9
|
+
context 'when required_files_include is set' do
|
10
|
+
let(:required_files_include) { 'REVIEW.md' }
|
11
|
+
let(:config) do
|
12
|
+
double(
|
13
|
+
required_files_include: [required_files_include]
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
before do
|
18
|
+
expect(PolishGeeks::DevTools)
|
19
|
+
.to receive(:config)
|
20
|
+
.and_return(config)
|
21
|
+
subject.execute
|
22
|
+
end
|
23
|
+
|
24
|
+
it { expect(subject.error_message.match(/REVIEW.md not exist/)).not_to be_nil }
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when required_files_include is empty' do
|
28
|
+
it { expect(subject.error_message).to be_nil }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#valid?' do
|
33
|
+
context 'when file exist' do
|
34
|
+
before { subject.instance_variable_set('@output', []) }
|
35
|
+
|
36
|
+
it { expect(subject.valid?).to be true }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#error_message' do
|
41
|
+
context 'when output is not empty' do
|
42
|
+
let(:file_name) { rand.to_s }
|
43
|
+
let(:output) { [file_name] }
|
44
|
+
let(:expected) { "Following files does not exist or are empty:\n#{file_name}\n" }
|
45
|
+
before do
|
46
|
+
subject.instance_variable_set('@output', output)
|
47
|
+
end
|
48
|
+
it { expect(subject.error_message).to eq expected }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/rspec_files_names_spec.rb
RENAMED
@@ -33,7 +33,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::RspecFilesNames do
|
|
33
33
|
context 'when we dont have invalid files' do
|
34
34
|
let(:files) { ['test_spec.rb'] }
|
35
35
|
|
36
|
-
it '
|
36
|
+
it 'sets appropriate variables' do
|
37
37
|
expect(subject.output).to eq []
|
38
38
|
expect(subject.counter).to eq(described_class::CHECKED_DIRS.count * files.count)
|
39
39
|
end
|
@@ -42,7 +42,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::RspecFilesNames do
|
|
42
42
|
context 'when we have invalid files' do
|
43
43
|
let(:files) { ['test_spe.rb'] }
|
44
44
|
|
45
|
-
it '
|
45
|
+
it 'sets appropriate variables' do
|
46
46
|
expect(subject.output).to eq(files * described_class::CHECKED_DIRS.count)
|
47
47
|
expect(subject.counter).to eq(described_class::CHECKED_DIRS.count * files.count)
|
48
48
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'tempfile'
|
2
3
|
|
3
4
|
RSpec.describe PolishGeeks::DevTools::Commands::RspecFilesStructure do
|
4
5
|
subject { described_class.new }
|
@@ -17,7 +18,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::RspecFilesStructure do
|
|
17
18
|
.and_return(analyzed_files_result)
|
18
19
|
|
19
20
|
expect(subject)
|
20
|
-
.to receive(:
|
21
|
+
.to receive(:analyzed_rspec_files)
|
21
22
|
.exactly(2).times
|
22
23
|
.and_return(rspec_files_result)
|
23
24
|
|
@@ -30,7 +31,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::RspecFilesStructure do
|
|
30
31
|
.and_return(substract_rspec_result)
|
31
32
|
end
|
32
33
|
|
33
|
-
it '
|
34
|
+
it 'is subtraction' do
|
34
35
|
subject.execute
|
35
36
|
|
36
37
|
expect(subject.instance_variable_get(:@output)).to eq expected
|
@@ -47,35 +48,25 @@ RSpec.describe PolishGeeks::DevTools::Commands::RspecFilesStructure do
|
|
47
48
|
.at_least(:once)
|
48
49
|
end
|
49
50
|
|
50
|
-
it { expect(subject.send(:analyzed_files)).
|
51
|
+
it { expect(subject.send(:analyzed_files)).not_to be_empty }
|
51
52
|
|
52
53
|
context 'when we gather files for analyze' do
|
53
|
-
let(:file) {
|
54
|
+
let(:file) { Tempfile.new }
|
54
55
|
let(:files_collection) { [file] }
|
55
56
|
|
56
|
-
before
|
57
|
-
expect(described_class::FILES_CHECKED)
|
58
|
-
.to receive(:map)
|
59
|
-
.and_return(files_collection)
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'should flatten, uniq and sanitize' do
|
63
|
-
expect(files_collection)
|
64
|
-
.to receive(:flatten!)
|
65
|
-
|
66
|
-
expect(files_collection)
|
67
|
-
.to receive(:uniq!)
|
57
|
+
before { expect(subject).to receive(:checked_files) { files_collection } }
|
68
58
|
|
69
|
-
|
70
|
-
|
71
|
-
|
59
|
+
it 'flatten,s uniq and sanitize' do
|
60
|
+
expect(files_collection).to receive(:flatten!)
|
61
|
+
expect(files_collection).to receive(:uniq!)
|
62
|
+
expect(subject).to receive(:sanitize).with(file)
|
72
63
|
|
73
64
|
subject.send(:analyzed_files)
|
74
65
|
end
|
75
66
|
end
|
76
67
|
end
|
77
68
|
|
78
|
-
describe '#
|
69
|
+
describe '#analyzed_rspec_files' do
|
79
70
|
let(:config) { double(rspec_files_structure_ignored: nil) }
|
80
71
|
|
81
72
|
before do
|
@@ -85,19 +76,15 @@ RSpec.describe PolishGeeks::DevTools::Commands::RspecFilesStructure do
|
|
85
76
|
.at_least(:once)
|
86
77
|
end
|
87
78
|
|
88
|
-
it { expect(subject.send(:
|
79
|
+
it { expect(subject.send(:analyzed_rspec_files)).not_to be_empty }
|
89
80
|
|
90
81
|
context 'when we gather rspec files' do
|
91
82
|
let(:file) { double }
|
92
83
|
let(:files_collection) { [file] }
|
93
84
|
|
94
|
-
before
|
95
|
-
expect(described_class::RSPEC_FILES)
|
96
|
-
.to receive(:map)
|
97
|
-
.and_return(files_collection)
|
98
|
-
end
|
85
|
+
before { expect(subject).to receive(:rspec_files) { files_collection } }
|
99
86
|
|
100
|
-
it '
|
87
|
+
it 'flatten,s uniq and sanitize' do
|
101
88
|
expect(files_collection)
|
102
89
|
.to receive(:flatten!)
|
103
90
|
|
@@ -108,7 +95,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::RspecFilesStructure do
|
|
108
95
|
.to receive(:sanitize)
|
109
96
|
.with(file)
|
110
97
|
|
111
|
-
subject.send(:
|
98
|
+
subject.send(:analyzed_rspec_files)
|
112
99
|
end
|
113
100
|
end
|
114
101
|
end
|
@@ -141,7 +128,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::RspecFilesStructure do
|
|
141
128
|
.and_return(analyzed_files_result)
|
142
129
|
end
|
143
130
|
|
144
|
-
it '
|
131
|
+
it 'returns the label' do
|
145
132
|
expected = "Rspec files structure (#{analyzed_files_result.count} checked)"
|
146
133
|
expect(subject.label).to eq expected
|
147
134
|
end
|
@@ -161,7 +148,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::RspecFilesStructure do
|
|
161
148
|
.and_return(message)
|
162
149
|
end
|
163
150
|
|
164
|
-
it '
|
151
|
+
it 'returns the error message' do
|
165
152
|
expect(subject.error_message).to eq expected
|
166
153
|
end
|
167
154
|
end
|
@@ -241,7 +228,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::RspecFilesStructure do
|
|
241
228
|
subject.instance_variable_set(:@output, output)
|
242
229
|
end
|
243
230
|
|
244
|
-
it '
|
231
|
+
it 'returns the error message' do
|
245
232
|
expect(subject.send(:files_error_message))
|
246
233
|
.to eq "Following files don't have corresponding Rspec files:\n\ntest.rb\n"
|
247
234
|
end
|
@@ -254,7 +241,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::RspecFilesStructure do
|
|
254
241
|
subject.instance_variable_set(:@output, output)
|
255
242
|
end
|
256
243
|
|
257
|
-
it '
|
244
|
+
it 'returns the error message' do
|
258
245
|
expect(subject.send(:rspec_error_message))
|
259
246
|
.to eq "\n\nFollowing Rspec don't have corresponding files:\n\ntest_rspec_spec.rb\n"
|
260
247
|
end
|