polishgeeks-dev-tools 1.3.2 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +2 -3
  4. data/CHANGELOG.md +13 -0
  5. data/Gemfile +2 -0
  6. data/Gemfile.lock +53 -55
  7. data/config/rubocop_rspec.yml +6 -0
  8. data/lib/polish_geeks/dev_tools/commands/base.rb +4 -4
  9. data/lib/polish_geeks/dev_tools/commands/brakeman.rb +1 -1
  10. data/lib/polish_geeks/dev_tools/commands/empty_methods/file_parser.rb +1 -1
  11. data/lib/polish_geeks/dev_tools/commands/final_blank_line.rb +3 -1
  12. data/lib/polish_geeks/dev_tools/commands/rubocop.rb +1 -1
  13. data/lib/polish_geeks/dev_tools/version.rb +1 -1
  14. data/lib/polishgeeks-dev-tools.rb +0 -1
  15. data/polishgeeks_dev_tools.gemspec +0 -1
  16. data/spec/lib/polish_geeks/dev_tools/commands/allowed_extensions_spec.rb +10 -10
  17. data/spec/lib/polish_geeks/dev_tools/commands/base_spec.rb +9 -9
  18. data/spec/lib/polish_geeks/dev_tools/commands/brakeman_spec.rb +15 -21
  19. data/spec/lib/polish_geeks/dev_tools/commands/bundler_audit_spec.rb +6 -6
  20. data/spec/lib/polish_geeks/dev_tools/commands/empty_methods/file_parser_spec.rb +18 -18
  21. data/spec/lib/polish_geeks/dev_tools/commands/empty_methods_spec.rb +29 -35
  22. data/spec/lib/polish_geeks/dev_tools/commands/examples_comparator_spec.rb +22 -24
  23. data/spec/lib/polish_geeks/dev_tools/commands/expires_in_spec.rb +9 -11
  24. data/spec/lib/polish_geeks/dev_tools/commands/final_blank_line_spec.rb +31 -35
  25. data/spec/lib/polish_geeks/dev_tools/commands/gemfile_spec.rb +17 -17
  26. data/spec/lib/polish_geeks/dev_tools/commands/haml_lint_spec.rb +7 -15
  27. data/spec/lib/polish_geeks/dev_tools/commands/required_files_spec.rb +8 -8
  28. data/spec/lib/polish_geeks/dev_tools/commands/rspec_files_names_spec.rb +19 -15
  29. data/spec/lib/polish_geeks/dev_tools/commands/rspec_files_structure_spec.rb +40 -44
  30. data/spec/lib/polish_geeks/dev_tools/commands/rspec_spec.rb +22 -22
  31. data/spec/lib/polish_geeks/dev_tools/commands/rubocop_spec.rb +21 -29
  32. data/spec/lib/polish_geeks/dev_tools/commands/rubycritic_spec.rb +2 -4
  33. data/spec/lib/polish_geeks/dev_tools/commands/simplecov_spec.rb +18 -28
  34. data/spec/lib/polish_geeks/dev_tools/commands/tasks_files_names_spec.rb +24 -25
  35. data/spec/lib/polish_geeks/dev_tools/commands/yard_spec.rb +10 -24
  36. data/spec/lib/polish_geeks/dev_tools/commands/yml_parser_spec.rb +15 -19
  37. data/spec/lib/polish_geeks/dev_tools/config_manager_spec.rb +33 -33
  38. data/spec/lib/polish_geeks/dev_tools/config_spec.rb +10 -10
  39. data/spec/lib/polish_geeks/dev_tools/errors_spec.rb +4 -4
  40. data/spec/lib/polish_geeks/dev_tools/hash_spec.rb +5 -5
  41. data/spec/lib/polish_geeks/dev_tools/logger_spec.rb +13 -13
  42. data/spec/lib/polish_geeks/dev_tools/output_storer_spec.rb +2 -2
  43. data/spec/lib/polish_geeks/dev_tools/runner_spec.rb +2 -2
  44. data/spec/lib/polish_geeks/dev_tools/shell_spec.rb +2 -2
  45. data/spec/lib/polish_geeks/dev_tools/validators/base_spec.rb +7 -7
  46. data/spec/lib/polish_geeks/dev_tools/validators/rails_spec.rb +3 -3
  47. data/spec/lib/polish_geeks/dev_tools/validators/rubocop_spec.rb +3 -3
  48. data/spec/lib/polish_geeks/dev_tools/validators/simplecov_spec.rb +12 -11
  49. data/spec/lib/polish_geeks/dev_tools/version_spec.rb +1 -3
  50. data/spec/lib/polish_geeks/dev_tools_spec.rb +7 -13
  51. metadata +3 -18
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe PolishGeeks::DevTools::Commands::Rubocop do
4
- subject { described_class.new }
4
+ subject(:rubocop) { described_class.new }
5
5
  let(:config) { double }
6
6
  before { allow(PolishGeeks::DevTools::Config).to receive(:config) { config } }
7
7
 
@@ -21,105 +21,97 @@ RSpec.describe PolishGeeks::DevTools::Commands::Rubocop do
21
21
  context 'when app config exists' do
22
22
  let(:cmd) do
23
23
  "bundle exec rubocop #{PolishGeeks::DevTools.app_root}" \
24
- " -c #{subject.class.config_manager.path}" \
24
+ " -c #{rubocop.class.config_manager.path}" \
25
25
  ' --require rubocop-rspec' \
26
26
  ' --display-cop-names'
27
27
  end
28
28
 
29
29
  before do
30
30
  expect(config).to receive(:rubocop_rspec?) { true }
31
- allow(subject.class.config_manager).to receive(:application?) { true }
32
- allow(subject.class.config_manager).to receive(:application_path) { path }
31
+ allow(rubocop.class.config_manager).to receive(:application?) { true }
32
+ allow(rubocop.class.config_manager).to receive(:application_path) { path }
33
33
  expect(instance).to receive(:execute).with(cmd)
34
34
  end
35
35
 
36
- it { subject.execute }
36
+ it { rubocop.execute }
37
37
  end
38
38
 
39
39
  context 'when app config does not exist' do
40
40
  let(:path) { Dir.pwd }
41
41
  let(:cmd) do
42
42
  "bundle exec rubocop #{PolishGeeks::DevTools.app_root} " \
43
- "-c #{subject.class.config_manager.path} " \
43
+ "-c #{rubocop.class.config_manager.path} " \
44
44
  '--display-cop-names'
45
45
  end
46
46
 
47
47
  before do
48
48
  allow(PolishGeeks::DevTools).to receive(:gem_root).and_return(path)
49
49
  expect(config).to receive(:rubocop_rspec?) { false }
50
- allow(subject.class.config_manager).to receive(:application?) { false }
51
- allow(subject.class.config_manager).to receive(:local_path) { path }
50
+ allow(rubocop.class.config_manager).to receive(:application?) { false }
51
+ allow(rubocop.class.config_manager).to receive(:local_path) { path }
52
52
  expect(instance).to receive(:execute).with(cmd)
53
53
  end
54
54
 
55
- it { subject.execute }
55
+ it { rubocop.execute }
56
56
  end
57
57
  end
58
58
 
59
59
  describe '#valid?' do
60
60
  context 'when offenses count is equal 0' do
61
61
  before do
62
- expect(subject)
62
+ expect(rubocop)
63
63
  .to receive(:offenses_count)
64
64
  .and_return(0)
65
65
  end
66
66
 
67
- it 'returns true' do
68
- expect(subject.valid?).to eq true
69
- end
67
+ it { expect(rubocop.valid?).to eq true }
70
68
  end
71
69
 
72
70
  context 'when offenses count is different from 0' do
73
71
  before do
74
- expect(subject)
72
+ expect(rubocop)
75
73
  .to receive(:offenses_count)
76
74
  .and_return(100)
77
75
  end
78
76
 
79
- it 'returns false' do
80
- expect(subject.valid?).to eq false
81
- end
77
+ it { expect(rubocop.valid?).to eq false }
82
78
  end
83
79
  end
84
80
 
85
81
  describe '#label' do
86
82
  before do
87
- expect(subject).to receive(:files_count) { 10 }
88
- expect(subject).to receive(:offenses_count) { 5 }
83
+ expect(rubocop).to receive(:files_count) { 10 }
84
+ expect(rubocop).to receive(:offenses_count) { 5 }
89
85
  end
90
86
 
91
87
  context 'when we run rubocop' do
92
88
  before { expect(config).to receive(:rubocop_rspec?) { false } }
93
- it { expect(subject.label).to eq 'Rubocop (10 files, 5 offenses)' }
89
+ it { expect(rubocop.label).to eq 'Rubocop (10 files, 5 offenses)' }
94
90
  end
95
91
 
96
92
  context 'when we run rubocop with rspec' do
97
93
  before { expect(config).to receive(:rubocop_rspec?) { true } }
98
- it { expect(subject.label).to eq 'Rubocop with RSpec (10 files, 5 offenses)' }
94
+ it { expect(rubocop.label).to eq 'Rubocop with RSpec (10 files, 5 offenses)' }
99
95
  end
100
96
  end
101
97
 
102
98
  describe '#files_count' do
103
99
  context 'when we count files' do
104
100
  before do
105
- subject.instance_variable_set(:@output, '10 files inspected')
101
+ rubocop.instance_variable_set(:@output, '10 files inspected')
106
102
  end
107
103
 
108
- it 'returns a proper value' do
109
- expect(subject.send(:files_count)).to eq 10
110
- end
104
+ it { expect(rubocop.send(:files_count)).to eq 10 }
111
105
  end
112
106
  end
113
107
 
114
108
  describe '#offenses_count' do
115
109
  context 'when we count offenses' do
116
110
  before do
117
- subject.instance_variable_set(:@output, '5 offenses detected')
111
+ rubocop.instance_variable_set(:@output, '5 offenses detected')
118
112
  end
119
113
 
120
- it 'returns a proper value' do
121
- expect(subject.send(:offenses_count)).to eq 5
122
- end
114
+ it { expect(rubocop.send(:offenses_count)).to eq 5 }
123
115
  end
124
116
  end
125
117
 
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe PolishGeeks::DevTools::Commands::Rubycritic do
4
- subject { described_class.new }
4
+ subject(:rubycritic) { described_class.new }
5
5
 
6
6
  describe '#execute' do
7
7
  let(:instance) { instance_double(PolishGeeks::DevTools::Shell) }
@@ -13,9 +13,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::Rubycritic do
13
13
  .with('bundle exec rubycritic ./app ./lib/')
14
14
  end
15
15
 
16
- it 'executes the command' do
17
- subject.execute
18
- end
16
+ it { rubycritic.execute }
19
17
  end
20
18
  end
21
19
 
@@ -2,29 +2,27 @@ require 'spec_helper'
2
2
 
3
3
  RSpec.describe PolishGeeks::DevTools::Commands::Simplecov do
4
4
  context 'class' do
5
- subject { described_class }
5
+ subject(:simplecov) { described_class }
6
6
 
7
7
  describe '#validators' do
8
8
  it 'works only when we have Simplecov' do
9
- expect(subject.validators).to eq [PolishGeeks::DevTools::Validators::Simplecov]
9
+ expect(simplecov.validators).to eq [PolishGeeks::DevTools::Validators::Simplecov]
10
10
  end
11
11
  end
12
12
  end
13
13
 
14
14
  context 'instance' do
15
- subject { described_class.new }
15
+ subject(:simplecov) { described_class.new }
16
16
 
17
17
  let(:label) { '(95.00%) covered' }
18
18
  let(:config) { double }
19
19
 
20
20
  describe '#to_f' do
21
21
  context 'when we run simplecov' do
22
- before do
23
- subject.instance_variable_set(:@output, label)
24
- end
22
+ before { simplecov.instance_variable_set(:@output, label) }
25
23
 
26
24
  it 'returns number of coverage as a float value' do
27
- expect(subject.to_f).to eq 95.00
25
+ expect(simplecov.to_f).to eq 95.00
28
26
  end
29
27
  end
30
28
  end
@@ -33,20 +31,16 @@ RSpec.describe PolishGeeks::DevTools::Commands::Simplecov do
33
31
  context 'when we run simplecov' do
34
32
  let(:output) { OpenStruct.new(rspec: label) }
35
33
 
36
- before do
37
- subject.instance_variable_set(:@stored_output, output)
38
- end
34
+ before { simplecov.instance_variable_set(:@stored_output, output) }
39
35
 
40
- it 'executes the command' do
41
- expect(subject.execute).to eq label
42
- end
36
+ it { expect(simplecov.execute).to eq label }
43
37
  end
44
38
  end
45
39
 
46
40
  describe '#valid?' do
47
41
  context 'when cc level is greater or equal than expected' do
48
42
  before do
49
- expect(subject)
43
+ expect(simplecov)
50
44
  .to receive(:to_f)
51
45
  .and_return(95.0)
52
46
  expect(PolishGeeks::DevTools::Config)
@@ -57,14 +51,12 @@ RSpec.describe PolishGeeks::DevTools::Commands::Simplecov do
57
51
  .and_return(65.0)
58
52
  end
59
53
 
60
- it 'returns true' do
61
- expect(subject.valid?).to eq true
62
- end
54
+ it { expect(simplecov.valid?).to eq true }
63
55
  end
64
56
 
65
57
  context 'when cc level is less than expected' do
66
58
  before do
67
- expect(subject)
59
+ expect(simplecov)
68
60
  .to receive(:to_f)
69
61
  .and_return(65.0)
70
62
  expect(PolishGeeks::DevTools::Config)
@@ -75,16 +67,14 @@ RSpec.describe PolishGeeks::DevTools::Commands::Simplecov do
75
67
  .and_return(95.0)
76
68
  end
77
69
 
78
- it 'returns false' do
79
- expect(subject.valid?).to eq false
80
- end
70
+ it { expect(simplecov.valid?).to eq false }
81
71
  end
82
72
  end
83
73
 
84
74
  describe '#label' do
85
75
  context 'when we run simplecov and cc is greater or equal than expected' do
86
76
  before do
87
- expect(subject)
77
+ expect(simplecov)
88
78
  .to receive(:to_f)
89
79
  .and_return(95.0)
90
80
  expect(PolishGeeks::DevTools::Config)
@@ -96,29 +86,29 @@ RSpec.describe PolishGeeks::DevTools::Commands::Simplecov do
96
86
  end
97
87
 
98
88
  it 'returns the label' do
99
- expect(subject.label).to eq 'SimpleCov covered 95.0%, required 65.0%'
89
+ expect(simplecov.label).to eq 'SimpleCov covered 95.0%, required 65.0%'
100
90
  end
101
91
  end
102
92
  end
103
93
 
104
94
  describe '#error_message' do
105
95
  context 'when we run simplecov and cc is less than expected' do
106
- before { allow(subject).to receive(:to_f) { 65.0 } }
96
+ before { allow(simplecov).to receive(:to_f) { 65.0 } }
107
97
 
108
98
  context 'and threshold is 95%' do
109
- before { allow(subject).to receive(:threshold) { 95.0 } }
99
+ before { allow(simplecov).to receive(:threshold) { 95.0 } }
110
100
 
111
101
  it 'returns the error message' do
112
- expect(subject.error_message)
102
+ expect(simplecov.error_message)
113
103
  .to eq 'SimpleCov coverage level needs to be 95.0% or more, was 65.0%'
114
104
  end
115
105
  end
116
106
 
117
107
  context 'and threshold is 100%' do
118
- before { allow(subject).to receive(:threshold) { 100.0 } }
108
+ before { allow(simplecov).to receive(:threshold) { 100.0 } }
119
109
 
120
110
  it 'returns the error message' do
121
- expect(subject.error_message)
111
+ expect(simplecov.error_message)
122
112
  .to eq 'SimpleCov coverage level needs to be 100.0%, was 65.0%'
123
113
  end
124
114
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe PolishGeeks::DevTools::Commands::TasksFilesNames do
4
- subject { described_class.new }
4
+ subject(:tasks_files_names) { described_class.new }
5
5
 
6
6
  let(:config) { double }
7
7
 
@@ -23,19 +23,19 @@ RSpec.describe PolishGeeks::DevTools::Commands::TasksFilesNames do
23
23
 
24
24
  describe '#valid?' do
25
25
  before do
26
- subject.instance_variable_set('@output', output)
26
+ tasks_files_names.instance_variable_set('@output', output)
27
27
  end
28
28
 
29
29
  context 'when output is empty' do
30
30
  let(:output) { [] }
31
31
 
32
- it { expect(subject.valid?).to eq true }
32
+ it { expect(tasks_files_names.valid?).to eq true }
33
33
  end
34
34
 
35
35
  context 'when output is not empty' do
36
36
  let(:output) { ['file_name'] }
37
37
 
38
- it { expect(subject.valid?).to eq false }
38
+ it { expect(tasks_files_names.valid?).to eq false }
39
39
  end
40
40
  end
41
41
 
@@ -44,10 +44,10 @@ RSpec.describe PolishGeeks::DevTools::Commands::TasksFilesNames do
44
44
  let(:expected) { "Tasks files names: #{counter} files checked" }
45
45
 
46
46
  before do
47
- subject.instance_variable_set('@counter', counter)
47
+ tasks_files_names.instance_variable_set('@counter', counter)
48
48
  end
49
49
 
50
- it { expect(subject.label).to eq expected }
50
+ it { expect(tasks_files_names.label).to eq expected }
51
51
  end
52
52
 
53
53
  describe '#error_message' do
@@ -55,54 +55,53 @@ RSpec.describe PolishGeeks::DevTools::Commands::TasksFilesNames do
55
55
  let(:expected) { "Following files have invalid extensions: \n #{output.join("\n")}\n" }
56
56
 
57
57
  before do
58
- subject.instance_variable_set('@output', output)
58
+ tasks_files_names.instance_variable_set('@output', output)
59
59
  end
60
60
 
61
- it { expect(subject.error_message).to eq expected }
61
+ it { expect(tasks_files_names.error_message).to eq expected }
62
62
  end
63
63
 
64
64
  describe '#files' do
65
65
  let(:dummy_type) do
66
66
  OpenStruct.new(
67
- dirs: %w( lib )
67
+ dirs: %w(lib)
68
68
  )
69
69
  end
70
70
 
71
71
  it 'does not be empty' do
72
- expect(subject.send(:files, dummy_type)).not_to be_empty
72
+ expect(tasks_files_names.send(:files, dummy_type)).not_to be_empty
73
73
  end
74
74
 
75
75
  it 'does not contain directories' do
76
- expect(subject.send(:files, dummy_type)).not_to include('command')
76
+ expect(tasks_files_names.send(:files, dummy_type)).not_to include('command')
77
77
  end
78
78
  end
79
79
 
80
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 ) }
81
+ let(:example_cap_files) { %w(a b c test.cap) }
82
+ let(:example_rake_files) { %w(d e f test.rake) }
83
83
 
84
84
  before do
85
- expect(subject)
85
+ expect(tasks_files_names)
86
86
  .to receive(:files)
87
87
  .with(described_class::CAP)
88
- .and_return(example_cap_files)
88
+ .and_return(example_cap_files.dup)
89
89
 
90
- expect(subject)
90
+ expect(tasks_files_names)
91
91
  .to receive(:files)
92
92
  .with(described_class::RAKE)
93
- .and_return(example_rake_files)
93
+ .and_return(example_rake_files.dup)
94
+
95
+ tasks_files_names.execute
94
96
  end
95
97
 
96
98
  it 'sets counter' do
97
- expected = example_cap_files.count + example_rake_files.count
98
- subject.execute
99
- expect(subject.counter).to eq expected
99
+ expect(
100
+ tasks_files_names.counter
101
+ ).to eq example_cap_files.count + example_rake_files.count
100
102
  end
101
103
 
102
- it 'marks all inapropriate files' do
103
- subject.execute
104
- expect(subject.output).not_to include('test.cap')
105
- expect(subject.output).not_to include('test.rake')
106
- end
104
+ it { expect(tasks_files_names.output).not_to include('test.cap') }
105
+ it { expect(tasks_files_names.output).not_to include('test.rake') }
107
106
  end
108
107
  end
@@ -1,54 +1,40 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe PolishGeeks::DevTools::Commands::Yard do
4
- subject { described_class.new }
4
+ subject(:yard) { described_class.new }
5
5
 
6
6
  describe '#execute' do
7
7
  let(:instance) { instance_double(PolishGeeks::DevTools::Shell) }
8
8
 
9
9
  context 'when we run yard' do
10
10
  before do
11
- expect(subject).to receive(:options) { '--list-undoc' }
11
+ expect(yard).to receive(:options) { '--list-undoc' }
12
12
  allow(PolishGeeks::DevTools::Shell).to receive(:new) { instance }
13
13
  expect(instance).to receive(:execute)
14
14
  .with('bundle exec yard stats --list-undoc')
15
15
  end
16
16
 
17
- it 'executes the command' do
18
- subject.execute
19
- end
17
+ it { yard.execute }
20
18
  end
21
19
  end
22
20
 
23
21
  describe '#valid?' do
24
22
  context 'when everything is documented and without warnings' do
25
- before do
26
- subject.instance_variable_set(:@output, 'OK')
27
- end
23
+ before { yard.instance_variable_set(:@output, 'OK') }
28
24
 
29
- it 'returns true' do
30
- expect(subject.valid?).to eq true
31
- end
25
+ it { expect(yard.valid?).to eq true }
32
26
  end
33
27
 
34
28
  context 'when something has some warnings' do
35
- before do
36
- subject.instance_variable_set(:@output, 'warn')
37
- end
29
+ before { yard.instance_variable_set(:@output, 'warn') }
38
30
 
39
- it 'returns false' do
40
- expect(subject.valid?).to eq false
41
- end
31
+ it { expect(yard.valid?).to eq false }
42
32
  end
43
33
 
44
34
  context 'when something is undocumented' do
45
- before do
46
- subject.instance_variable_set(:@output, 'undocumented objects')
47
- end
35
+ before { yard.instance_variable_set(:@output, 'undocumented objects') }
48
36
 
49
- it 'returns false' do
50
- expect(subject.valid?).to eq false
51
- end
37
+ it { expect(yard.valid?).to eq false }
52
38
  end
53
39
  end
54
40
 
@@ -71,7 +57,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::Yard do
71
57
  end
72
58
 
73
59
  it 'returns lines with options' do
74
- expect(subject.send(:options)).to eq '--private --list-undoc'
60
+ expect(yard.send(:options)).to eq '--private --list-undoc'
75
61
  end
76
62
  end
77
63
  end