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
@@ -1,32 +0,0 @@
|
|
1
|
-
module PolishGeeks
|
2
|
-
module DevTools
|
3
|
-
module Commands
|
4
|
-
# Checks README.rb exists
|
5
|
-
class Readme < Base
|
6
|
-
self.type = :validator
|
7
|
-
|
8
|
-
# Executes this command
|
9
|
-
# @return [String] command output
|
10
|
-
def execute
|
11
|
-
readme = File.join(::PolishGeeks::DevTools.app_root, 'README.md')
|
12
|
-
@output = File.exist?(readme)
|
13
|
-
end
|
14
|
-
|
15
|
-
# @return [String] label with this validator description
|
16
|
-
def label
|
17
|
-
'README.rb required'
|
18
|
-
end
|
19
|
-
|
20
|
-
# @return [String] error message
|
21
|
-
def error_message
|
22
|
-
"README.rb doesn't exist!"
|
23
|
-
end
|
24
|
-
|
25
|
-
# @return [Boolean] true if README.rb exist
|
26
|
-
def valid?
|
27
|
-
@output
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe PolishGeeks::DevTools::Commands::Base do
|
4
|
-
subject { described_class.new }
|
5
|
-
|
6
|
-
describe '#execute' do
|
7
|
-
let(:error) { PolishGeeks::DevTools::Errors::NotImplementedError }
|
8
|
-
it { expect { subject.execute }. to raise_error(error) }
|
9
|
-
end
|
10
|
-
|
11
|
-
describe '#valid?' do
|
12
|
-
let(:error) { PolishGeeks::DevTools::Errors::NotImplementedError }
|
13
|
-
it { expect { subject.valid? }. to raise_error(error) }
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#error_message' do
|
17
|
-
let(:output) { rand.to_s }
|
18
|
-
|
19
|
-
before do
|
20
|
-
subject.instance_variable_set('@output', output)
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'by default should equal raw output' do
|
24
|
-
expect(subject.error_message).to eq output
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#ensure_executable!' do
|
29
|
-
context 'when there are validators' do
|
30
|
-
let(:validator_class) { PolishGeeks::DevTools::Validators::Base }
|
31
|
-
|
32
|
-
before do
|
33
|
-
expect(described_class)
|
34
|
-
.to receive(:validators)
|
35
|
-
.and_return([validator_class])
|
36
|
-
|
37
|
-
expect_any_instance_of(validator_class)
|
38
|
-
.to receive(:valid?)
|
39
|
-
.and_return(true)
|
40
|
-
end
|
41
|
-
|
42
|
-
it { expect { subject.ensure_executable! }.not_to raise_error }
|
43
|
-
end
|
44
|
-
|
45
|
-
context 'when we dont require any validators' do
|
46
|
-
before do
|
47
|
-
expect(described_class)
|
48
|
-
.to receive(:validators)
|
49
|
-
.and_return([])
|
50
|
-
end
|
51
|
-
|
52
|
-
it { expect { subject.ensure_executable! }.not_to raise_error }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,96 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe PolishGeeks::DevTools::Commands::Brakeman do
|
4
|
-
subject { described_class }
|
5
|
-
|
6
|
-
describe '#validators' do
|
7
|
-
it 'should work only when we have Rails framework' do
|
8
|
-
expect(subject.validators).to eq [PolishGeeks::DevTools::Validators::Rails]
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
RSpec.describe PolishGeeks::DevTools::Commands::Brakeman do
|
14
|
-
subject { described_class.new }
|
15
|
-
|
16
|
-
describe '#execute' do
|
17
|
-
context 'when we run brakeman' do
|
18
|
-
before do
|
19
|
-
expect_any_instance_of(PolishGeeks::DevTools::Shell)
|
20
|
-
.to receive(:execute)
|
21
|
-
.with('bundle exec brakeman -q')
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should execute the command' do
|
25
|
-
subject.execute
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe '#valid?' do
|
31
|
-
context 'when warnings are equal 0' do
|
32
|
-
before do
|
33
|
-
expect(subject)
|
34
|
-
.to receive(:warnings)
|
35
|
-
.and_return(0)
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'and errors are equal 0' do
|
39
|
-
before do
|
40
|
-
expect(subject)
|
41
|
-
.to receive(:errors)
|
42
|
-
.and_return(0)
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'should return true' do
|
46
|
-
expect(subject.valid?).to eq true
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context 'and errors are not equal 0' do
|
51
|
-
before do
|
52
|
-
expect(subject)
|
53
|
-
.to receive(:errors)
|
54
|
-
.and_return(1)
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'should return true' do
|
58
|
-
expect(subject.valid?).to eq false
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe 'label' do
|
65
|
-
let(:models) { rand(1000) }
|
66
|
-
let(:controllers) { rand(1000) }
|
67
|
-
let(:templates) { rand(1000) }
|
68
|
-
|
69
|
-
before do
|
70
|
-
expect(subject).to receive(:models).and_return(models)
|
71
|
-
expect(subject).to receive(:controllers).and_return(controllers)
|
72
|
-
expect(subject).to receive(:templates).and_return(templates)
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'should use details' do
|
76
|
-
label = "Brakeman (#{controllers} con, #{models} mod, #{templates} temp)"
|
77
|
-
expect(subject.label).to eq label
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
describe 'counter' do
|
82
|
-
described_class::REGEXPS.each do |name, _regexp|
|
83
|
-
describe "##{name}" do
|
84
|
-
let(:amount) { rand(1000) }
|
85
|
-
|
86
|
-
before do
|
87
|
-
subject.instance_variable_set(:@output, "#{name.to_s.capitalize} #{amount}")
|
88
|
-
end
|
89
|
-
|
90
|
-
it 'should return a proper value' do
|
91
|
-
expect(subject.send(name)).to eq amount
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe PolishGeeks::DevTools::Commands::Readme do
|
4
|
-
subject { described_class.new }
|
5
|
-
|
6
|
-
let(:config) { double }
|
7
|
-
|
8
|
-
describe '#execute' do
|
9
|
-
it 'should execute the command' do
|
10
|
-
subject.execute
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '#label' do
|
15
|
-
let(:expected) { 'README.rb required' }
|
16
|
-
|
17
|
-
it { expect(subject.label).to eq expected }
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '#error_message' do
|
21
|
-
let(:expected) { "README.rb doesn't exist!" }
|
22
|
-
let(:output) { false }
|
23
|
-
|
24
|
-
it { expect(subject.error_message).to eq expected }
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '#valid?' do
|
28
|
-
context 'when README.md exist' do
|
29
|
-
before do
|
30
|
-
subject.instance_variable_set('@output', true)
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should return true' do
|
34
|
-
expect(subject.valid?).to be true
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe PolishGeeks::DevTools::Commands::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
|
@@ -1,127 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe PolishGeeks::DevTools::Commands::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
|
@@ -1,134 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe PolishGeeks::DevTools::Commands::Simplecov do
|
4
|
-
subject { described_class }
|
5
|
-
|
6
|
-
describe '#validators' do
|
7
|
-
it 'should work only when we have Simplecov' do
|
8
|
-
expect(subject.validators).to eq [PolishGeeks::DevTools::Validators::Simplecov]
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
RSpec.describe PolishGeeks::DevTools::Commands::Simplecov do
|
14
|
-
subject { described_class.new }
|
15
|
-
|
16
|
-
let(:label) { '(95.00%) covered' }
|
17
|
-
let(:config) { double }
|
18
|
-
|
19
|
-
describe '#to_f' do
|
20
|
-
context 'when we run simplecov' do
|
21
|
-
before do
|
22
|
-
subject.instance_variable_set(:@output, label)
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should return number of coverage as a float value' do
|
26
|
-
expect(subject.to_f).to eq 95.00
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '#execute' do
|
32
|
-
context 'when we run simplecov' do
|
33
|
-
let(:output) { OpenStruct.new(rspec: label) }
|
34
|
-
|
35
|
-
before do
|
36
|
-
subject.instance_variable_set(:@stored_output, output)
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should execute the command' do
|
40
|
-
expect(subject.execute).to eq label
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe '#valid?' do
|
46
|
-
context 'when cc level is greater or equal than expected' do
|
47
|
-
before do
|
48
|
-
expect(subject)
|
49
|
-
.to receive(:to_f)
|
50
|
-
.and_return(95.0)
|
51
|
-
expect(PolishGeeks::DevTools::Config)
|
52
|
-
.to receive(:config)
|
53
|
-
.and_return(config)
|
54
|
-
expect(config)
|
55
|
-
.to receive(:simplecov_threshold)
|
56
|
-
.and_return(65.0)
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'should return true' do
|
60
|
-
expect(subject.valid?).to eq true
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
context 'when cc level is less than expected' do
|
65
|
-
before do
|
66
|
-
expect(subject)
|
67
|
-
.to receive(:to_f)
|
68
|
-
.and_return(65.0)
|
69
|
-
expect(PolishGeeks::DevTools::Config)
|
70
|
-
.to receive(:config)
|
71
|
-
.and_return(config)
|
72
|
-
expect(config)
|
73
|
-
.to receive(:simplecov_threshold)
|
74
|
-
.and_return(95.0)
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'should return false' do
|
78
|
-
expect(subject.valid?).to eq false
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe '#label' do
|
84
|
-
context 'when we run simplecov and cc is greater or equal than expected' do
|
85
|
-
before do
|
86
|
-
expect(subject)
|
87
|
-
.to receive(:to_f)
|
88
|
-
.and_return(95.0)
|
89
|
-
expect(PolishGeeks::DevTools::Config)
|
90
|
-
.to receive(:config)
|
91
|
-
.and_return(config)
|
92
|
-
expect(config)
|
93
|
-
.to receive(:simplecov_threshold)
|
94
|
-
.and_return(65.0)
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'should return the label' do
|
98
|
-
expect(subject.label).to eq 'SimpleCov covered 95.0%, required 65.0%'
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
describe '#error_message' do
|
104
|
-
context 'when we run simplecov and cc is less than expected' do
|
105
|
-
before { allow(subject).to receive(:to_f) { 65.0 } }
|
106
|
-
|
107
|
-
context 'and threshold is 95%' do
|
108
|
-
before { allow(subject).to receive(:threshold) { 95.0 } }
|
109
|
-
|
110
|
-
it 'should return the error message' do
|
111
|
-
expect(subject.error_message)
|
112
|
-
.to eq 'SimpleCov coverage level needs to be 95.0% or more, was 65.0%'
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
context 'and threshold is 100%' do
|
117
|
-
before { allow(subject).to receive(:threshold) { 100.0 } }
|
118
|
-
|
119
|
-
it 'should return the error message' do
|
120
|
-
expect(subject.error_message)
|
121
|
-
.to eq 'SimpleCov coverage level needs to be 100.0%, was 65.0%'
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
describe '.generator?' do
|
128
|
-
it { expect(described_class.generator?).to eq false }
|
129
|
-
end
|
130
|
-
|
131
|
-
describe '.validator?' do
|
132
|
-
it { expect(described_class.validator?).to eq true }
|
133
|
-
end
|
134
|
-
end
|