polishgeeks-dev-tools 1.0.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 +7 -0
- data/.gitignore +22 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +6 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +193 -0
- data/README.md +112 -0
- data/Rakefile +20 -0
- data/config/haml-lint.yml +74 -0
- data/config/rubocop.yml +35 -0
- data/config/yardopts +7 -0
- data/lib/polishgeeks-dev-tools.rb +43 -0
- data/lib/polishgeeks/dev-tools/command/allowed_extensions.rb +62 -0
- data/lib/polishgeeks/dev-tools/command/base.rb +73 -0
- data/lib/polishgeeks/dev-tools/command/brakeman.rb +46 -0
- data/lib/polishgeeks/dev-tools/command/coverage.rb +43 -0
- data/lib/polishgeeks/dev-tools/command/examples_comparator.rb +75 -0
- data/lib/polishgeeks/dev-tools/command/expires_in.rb +74 -0
- data/lib/polishgeeks/dev-tools/command/haml_lint.rb +28 -0
- data/lib/polishgeeks/dev-tools/command/readme.rb +32 -0
- data/lib/polishgeeks/dev-tools/command/rspec.rb +38 -0
- data/lib/polishgeeks/dev-tools/command/rspec_files_names.rb +58 -0
- data/lib/polishgeeks/dev-tools/command/rspec_files_structure.rb +134 -0
- data/lib/polishgeeks/dev-tools/command/rubocop.rb +50 -0
- data/lib/polishgeeks/dev-tools/command/rubycritic.rb +17 -0
- data/lib/polishgeeks/dev-tools/command/simplecov.rb +32 -0
- data/lib/polishgeeks/dev-tools/command/tasks_files_names.rb +76 -0
- data/lib/polishgeeks/dev-tools/command/yard.rb +35 -0
- data/lib/polishgeeks/dev-tools/command/yml_parser.rb +85 -0
- data/lib/polishgeeks/dev-tools/config.rb +91 -0
- data/lib/polishgeeks/dev-tools/hash.rb +24 -0
- data/lib/polishgeeks/dev-tools/logger.rb +63 -0
- data/lib/polishgeeks/dev-tools/output_storer.rb +17 -0
- data/lib/polishgeeks/dev-tools/runner.rb +27 -0
- data/lib/polishgeeks/dev-tools/shell.rb +16 -0
- data/lib/polishgeeks/dev-tools/tasks/dev-tools.rake +15 -0
- data/lib/polishgeeks/dev-tools/version.rb +8 -0
- data/polishgeeks_dev_tools.gemspec +36 -0
- data/spec/lib/polishgeeks-dev-tools_spec.rb +35 -0
- data/spec/lib/polishgeeks/dev-tools/command/allowed_extensions_spec.rb +66 -0
- data/spec/lib/polishgeeks/dev-tools/command/base_spec.rb +127 -0
- data/spec/lib/polishgeeks/dev-tools/command/brakeman_spec.rb +95 -0
- data/spec/lib/polishgeeks/dev-tools/command/coverage_spec.rb +121 -0
- data/spec/lib/polishgeeks/dev-tools/command/examples_comparator_spec.rb +171 -0
- data/spec/lib/polishgeeks/dev-tools/command/expires_in_spec.rb +69 -0
- data/spec/lib/polishgeeks/dev-tools/command/haml_lint_spec.rb +79 -0
- data/spec/lib/polishgeeks/dev-tools/command/readme_spec.rb +38 -0
- data/spec/lib/polishgeeks/dev-tools/command/rspec_files_names_spec.rb +91 -0
- data/spec/lib/polishgeeks/dev-tools/command/rspec_files_structure_spec.rb +262 -0
- data/spec/lib/polishgeeks/dev-tools/command/rspec_spec.rb +63 -0
- data/spec/lib/polishgeeks/dev-tools/command/rubocop_spec.rb +127 -0
- data/spec/lib/polishgeeks/dev-tools/command/rubycritic_spec.rb +27 -0
- data/spec/lib/polishgeeks/dev-tools/command/simplecov_spec.rb +53 -0
- data/spec/lib/polishgeeks/dev-tools/command/tasks_files_names_spec.rb +108 -0
- data/spec/lib/polishgeeks/dev-tools/command/yard_spec.rb +86 -0
- data/spec/lib/polishgeeks/dev-tools/command/yml_parser_spec.rb +104 -0
- data/spec/lib/polishgeeks/dev-tools/config_spec.rb +78 -0
- data/spec/lib/polishgeeks/dev-tools/hash_spec.rb +37 -0
- data/spec/lib/polishgeeks/dev-tools/logger_spec.rb +162 -0
- data/spec/lib/polishgeeks/dev-tools/output_storer_spec.rb +20 -0
- data/spec/lib/polishgeeks/dev-tools/runner_spec.rb +57 -0
- data/spec/lib/polishgeeks/dev-tools/shell_spec.rb +13 -0
- data/spec/lib/polishgeeks/dev-tools/version_spec.rb +7 -0
- data/spec/spec_helper.rb +28 -0
- metadata +330 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe PolishGeeks::DevTools::Command::Rspec do
|
4
|
+
subject { described_class.new }
|
5
|
+
|
6
|
+
describe '#execute' do
|
7
|
+
context 'when we run rspec' do
|
8
|
+
before do
|
9
|
+
expect_any_instance_of(PolishGeeks::DevTools::Shell)
|
10
|
+
.to receive(:execute)
|
11
|
+
.with('bundle exec rspec spec')
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should execute the command' do
|
15
|
+
subject.execute
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#valid?' do
|
21
|
+
context 'when there are some failures' do
|
22
|
+
before do
|
23
|
+
subject.instance_variable_set(:@output, '2 failures')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should return false' do
|
27
|
+
expect(subject.valid?).to eq false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when there are not any failures' do
|
32
|
+
before do
|
33
|
+
subject.instance_variable_set(:@output, '0 failures')
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should return true' do
|
37
|
+
expect(subject.valid?).to eq true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#label' do
|
43
|
+
context 'when we run rspec' do
|
44
|
+
let(:label) { '10 examples, 5 failures, 2 pending' }
|
45
|
+
|
46
|
+
before do
|
47
|
+
subject.instance_variable_set(:@output, label)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should return the label' do
|
51
|
+
expect(subject.label).to eq 'Rspec (10 ex, 5 fa, 2 pe)'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '.generator?' do
|
57
|
+
it { expect(described_class.generator?).to eq false }
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '.validator?' do
|
61
|
+
it { expect(described_class.validator?).to eq true }
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe PolishGeeks::DevTools::Command::Rubocop do
|
4
|
+
subject { described_class.new }
|
5
|
+
|
6
|
+
describe '#execute' do
|
7
|
+
let(:path) { '/' }
|
8
|
+
before do
|
9
|
+
expect(ENV)
|
10
|
+
.to receive(:[])
|
11
|
+
.with('BUNDLE_GEMFILE')
|
12
|
+
.and_return(path)
|
13
|
+
.at_least(:once)
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when app config exists' do
|
17
|
+
before do
|
18
|
+
expect(File)
|
19
|
+
.to receive(:exist?)
|
20
|
+
.and_return(true)
|
21
|
+
expect_any_instance_of(PolishGeeks::DevTools::Shell)
|
22
|
+
.to receive(:execute)
|
23
|
+
.with("bundle exec rubocop -c #{path}.rubocop.yml #{PolishGeeks::DevTools.app_root}")
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should execute the command' do
|
27
|
+
subject.execute
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when app config does not exist' do
|
32
|
+
let(:path) { Dir.pwd }
|
33
|
+
let(:app_root) { PolishGeeks::DevTools.app_root }
|
34
|
+
let(:cmd_expected) { "bundle exec rubocop -c #{path}/config/rubocop.yml #{app_root}" }
|
35
|
+
|
36
|
+
before do
|
37
|
+
expect(PolishGeeks::DevTools)
|
38
|
+
.to receive(:gem_root)
|
39
|
+
.and_return(path)
|
40
|
+
expect(File)
|
41
|
+
.to receive(:exist?)
|
42
|
+
.and_return(false)
|
43
|
+
expect_any_instance_of(PolishGeeks::DevTools::Shell)
|
44
|
+
.to receive(:execute)
|
45
|
+
.with(cmd_expected)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should execute the command' do
|
49
|
+
subject.execute
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#valid?' do
|
55
|
+
context 'when offenses count is equal 0' do
|
56
|
+
before do
|
57
|
+
expect(subject)
|
58
|
+
.to receive(:offenses_count)
|
59
|
+
.and_return(0)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should return true' do
|
63
|
+
expect(subject.valid?).to eq true
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'when offenses count is different from 0' do
|
68
|
+
before do
|
69
|
+
expect(subject)
|
70
|
+
.to receive(:offenses_count)
|
71
|
+
.and_return(100)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should return false' do
|
75
|
+
expect(subject.valid?).to eq false
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '#label' do
|
81
|
+
context 'when we run rubocop' do
|
82
|
+
before do
|
83
|
+
expect(subject)
|
84
|
+
.to receive(:files_count)
|
85
|
+
.and_return(10)
|
86
|
+
expect(subject)
|
87
|
+
.to receive(:offenses_count)
|
88
|
+
.and_return(5)
|
89
|
+
end
|
90
|
+
it 'should return the label' do
|
91
|
+
expect(subject.label).to eq 'Rubocop (10 files, 5 offenses)'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe '#files_count' do
|
97
|
+
context 'when we count files' do
|
98
|
+
before do
|
99
|
+
subject.instance_variable_set(:@output, '10 files inspected')
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should return a proper value' do
|
103
|
+
expect(subject.send(:files_count)).to eq 10
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe '#offenses_count' do
|
109
|
+
context 'when we count offenses' do
|
110
|
+
before do
|
111
|
+
subject.instance_variable_set(:@output, '5 offenses detected')
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should return a proper value' do
|
115
|
+
expect(subject.send(:offenses_count)).to eq 5
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe '.generator?' do
|
121
|
+
it { expect(described_class.generator?).to eq false }
|
122
|
+
end
|
123
|
+
|
124
|
+
describe '.validator?' do
|
125
|
+
it { expect(described_class.validator?).to eq true }
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe PolishGeeks::DevTools::Command::Rubycritic do
|
4
|
+
subject { described_class.new }
|
5
|
+
|
6
|
+
describe '#execute' do
|
7
|
+
context 'when we run rubycritic' do
|
8
|
+
before do
|
9
|
+
expect_any_instance_of(PolishGeeks::DevTools::Shell)
|
10
|
+
.to receive(:execute)
|
11
|
+
.with('bundle exec rubycritic ./app ./lib/')
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should execute the command' do
|
15
|
+
subject.execute
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '.generator?' do
|
21
|
+
it { expect(described_class.generator?).to eq true }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.validator?' do
|
25
|
+
it { expect(described_class.validator?).to eq false }
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe PolishGeeks::DevTools::Command::Simplecov do
|
4
|
+
subject { described_class.new }
|
5
|
+
|
6
|
+
let(:label) { '(95.00%) covered' }
|
7
|
+
|
8
|
+
describe '#execute' do
|
9
|
+
context 'when we run simplecov' do
|
10
|
+
let(:output) { OpenStruct.new(rspec: label) }
|
11
|
+
|
12
|
+
before do
|
13
|
+
subject.instance_variable_set(:@stored_output, output)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should execute the command' do
|
17
|
+
expect(subject.execute).to eq label
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#valid?' do
|
23
|
+
context 'when a report was generated' do
|
24
|
+
before do
|
25
|
+
subject.instance_variable_set(:@output, label)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should return true' do
|
29
|
+
expect(subject.valid?).to eq true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#label' do
|
35
|
+
context 'when we run simplecov' do
|
36
|
+
before do
|
37
|
+
subject.instance_variable_set(:@output, label)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should return the label' do
|
41
|
+
expect(subject.label).to eq 'Simplecov (95.00%) covered'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '.generator?' do
|
47
|
+
it { expect(described_class.generator?).to eq false }
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '.validator?' do
|
51
|
+
it { expect(described_class.validator?).to eq true }
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe PolishGeeks::DevTools::Command::TasksFilesNames do
|
4
|
+
subject { described_class.new }
|
5
|
+
|
6
|
+
let(:config) { double }
|
7
|
+
|
8
|
+
describe 'CAP' do
|
9
|
+
let(:dirs) { ['lib/capistrano'] }
|
10
|
+
let(:regexp) { /.*\.cap$/ }
|
11
|
+
|
12
|
+
it { expect(described_class::CAP.dirs).to eq dirs }
|
13
|
+
it { expect(described_class::CAP.regexp).to eq regexp }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'RAKE' do
|
17
|
+
let(:dirs) { ['lib/tasks'] }
|
18
|
+
let(:regexp) { /.*\.rake$/ }
|
19
|
+
|
20
|
+
it { expect(described_class::RAKE.dirs).to eq dirs }
|
21
|
+
it { expect(described_class::RAKE.regexp).to eq regexp }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#valid?' do
|
25
|
+
before do
|
26
|
+
subject.instance_variable_set('@output', output)
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when output is empty' do
|
30
|
+
let(:output) { [] }
|
31
|
+
|
32
|
+
it { expect(subject.valid?).to eq true }
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when output is not empty' do
|
36
|
+
let(:output) { ['file_name'] }
|
37
|
+
|
38
|
+
it { expect(subject.valid?).to eq false }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#label' do
|
43
|
+
let(:counter) { rand(1000) }
|
44
|
+
let(:expected) { "Tasks files names: #{counter} files checked" }
|
45
|
+
|
46
|
+
before do
|
47
|
+
subject.instance_variable_set('@counter', counter)
|
48
|
+
end
|
49
|
+
|
50
|
+
it { expect(subject.label).to eq expected }
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#error_message' do
|
54
|
+
let(:output) { [rand.to_s, rand.to_s] }
|
55
|
+
let(:expected) { "Following files have invalid extensions: \n #{output.join("\n")}\n" }
|
56
|
+
|
57
|
+
before do
|
58
|
+
subject.instance_variable_set('@output', output)
|
59
|
+
end
|
60
|
+
|
61
|
+
it { expect(subject.error_message).to eq expected }
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#files' do
|
65
|
+
let(:dummy_type) do
|
66
|
+
OpenStruct.new(
|
67
|
+
dirs: %w( lib )
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should not be empty' do
|
72
|
+
expect(subject.send(:files, dummy_type)).to_not be_empty
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should not contain directories' do
|
76
|
+
expect(subject.send(:files, dummy_type)).to_not include('command')
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '#execute' do
|
81
|
+
let(:example_cap_files) { %w( a b c test.cap ) }
|
82
|
+
let(:example_rake_files) { %w( d e f test.rake ) }
|
83
|
+
|
84
|
+
before do
|
85
|
+
expect(subject)
|
86
|
+
.to receive(:files)
|
87
|
+
.with(described_class::CAP)
|
88
|
+
.and_return(example_cap_files)
|
89
|
+
|
90
|
+
expect(subject)
|
91
|
+
.to receive(:files)
|
92
|
+
.with(described_class::RAKE)
|
93
|
+
.and_return(example_rake_files)
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should set counter' do
|
97
|
+
expected = example_cap_files.count + example_rake_files.count
|
98
|
+
subject.execute
|
99
|
+
expect(subject.counter).to eq expected
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should mark all inapropriate files' do
|
103
|
+
subject.execute
|
104
|
+
expect(subject.output).to_not include('test.cap')
|
105
|
+
expect(subject.output).to_not include('test.rake')
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe PolishGeeks::DevTools::Command::Yard do
|
4
|
+
subject { described_class.new }
|
5
|
+
|
6
|
+
describe '#execute' do
|
7
|
+
context 'when we run yard' do
|
8
|
+
before do
|
9
|
+
expect(subject)
|
10
|
+
.to receive(:options)
|
11
|
+
.and_return('--list-undoc')
|
12
|
+
expect_any_instance_of(PolishGeeks::DevTools::Shell)
|
13
|
+
.to receive(:execute)
|
14
|
+
.with('bundle exec yard stats --list-undoc')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should execute the command' do
|
18
|
+
subject.execute
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#valid?' do
|
24
|
+
context 'when everything is documented and without warnings' do
|
25
|
+
before do
|
26
|
+
subject.instance_variable_set(:@output, 'OK')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should return true' do
|
30
|
+
expect(subject.valid?).to eq true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when something has some warnings' do
|
35
|
+
before do
|
36
|
+
subject.instance_variable_set(:@output, 'warn')
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should return false' do
|
40
|
+
expect(subject.valid?).to eq false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when something is undocumented' do
|
45
|
+
before do
|
46
|
+
subject.instance_variable_set(:@output, 'undocumented objects')
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should return false' do
|
50
|
+
expect(subject.valid?).to eq false
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#options' do
|
56
|
+
context 'when we load yard settings' do
|
57
|
+
let(:path) { Dir.pwd }
|
58
|
+
let(:config) { double }
|
59
|
+
|
60
|
+
before do
|
61
|
+
expect(PolishGeeks::DevTools)
|
62
|
+
.to receive(:gem_root)
|
63
|
+
.and_return(path)
|
64
|
+
expect(File)
|
65
|
+
.to receive(:readlines)
|
66
|
+
.and_return(config)
|
67
|
+
expect(config)
|
68
|
+
.to receive(:join)
|
69
|
+
.with(' ')
|
70
|
+
.and_return('--private')
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should return lines with options' do
|
74
|
+
expect(subject.send(:options)).to eq '--private --list-undoc'
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '.generator?' do
|
80
|
+
it { expect(described_class.generator?).to eq false }
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '.validator?' do
|
84
|
+
it { expect(described_class.validator?).to eq true }
|
85
|
+
end
|
86
|
+
end
|