polishgeeks-dev-tools 1.3.2 → 1.4.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.
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::YmlParser do
4
- subject { described_class.new }
4
+ subject(:yml_parser) { described_class.new }
5
5
 
6
6
  let(:config) { double }
7
7
  let(:file) { rand.to_s }
@@ -15,48 +15,44 @@ RSpec.describe PolishGeeks::DevTools::Commands::YmlParser do
15
15
  expect(Dir)
16
16
  .to receive(:[])
17
17
  .and_return(results)
18
- expect(subject)
18
+ expect(yml_parser)
19
19
  .to receive(:parse_yaml)
20
20
  .with(file)
21
21
  .and_return(json)
22
- expect(subject)
22
+ expect(yml_parser)
23
23
  .to receive(:check_params)
24
24
  .and_return(json)
25
25
  end
26
26
 
27
- it 'executes the command' do
28
- subject.execute
29
- end
27
+ it { yml_parser.execute }
30
28
  end
31
29
 
32
30
  describe '#label' do
33
- it { expect(subject.label).to eq 'Yaml parser' }
31
+ it { expect(yml_parser.label).to eq 'Yaml parser' }
34
32
  end
35
33
 
36
34
  describe '#error_message' do
37
35
  let(:output) { [file: file, lines: [line]] }
38
36
  let(:expected) { "Following yml files have nil as a value:\n#{file}:\n - Key '#{line}'\n" }
39
37
  before do
40
- subject.instance_variable_set('@output', output)
38
+ yml_parser.instance_variable_set('@output', output)
41
39
  end
42
40
 
43
41
  it 'returns lines with nil value' do
44
- expect(subject.error_message).to eq expected
42
+ expect(yml_parser.error_message).to eq expected
45
43
  end
46
44
  end
47
45
 
48
46
  describe '#valid?' do
49
- before do
50
- subject.instance_variable_set('@output', '')
51
- end
47
+ before { yml_parser.instance_variable_set('@output', '') }
52
48
 
53
- it { expect(subject.valid?).to eq true }
49
+ it { expect(yml_parser.valid?).to eq true }
54
50
  end
55
51
 
56
52
  describe '#file_error' do
57
53
  let(:expected) { "\n#{file}:\n - Key '#{line}'" }
58
54
 
59
- it { expect(subject.send(:file_error, row)).to eq expected }
55
+ it { expect(yml_parser.send(:file_error, row)).to eq expected }
60
56
  end
61
57
 
62
58
  describe '#config_path' do
@@ -66,13 +62,13 @@ RSpec.describe PolishGeeks::DevTools::Commands::YmlParser do
66
62
  .to receive(:expand_path)
67
63
  .and_return('')
68
64
  end
69
- it { expect(subject.send(:config_path)).to eq expected }
65
+ it { expect(yml_parser.send(:config_path)).to eq expected }
70
66
  end
71
67
 
72
68
  describe '#sanitize' do
73
69
  let(:file_path) { PolishGeeks::DevTools.app_root + '/config/' + file }
74
70
 
75
- it { expect(subject.send(:sanitize, file_path)).to eq file }
71
+ it { expect(yml_parser.send(:sanitize, file_path)).to eq file }
76
72
  end
77
73
 
78
74
  describe '#parse_yaml' do
@@ -85,20 +81,20 @@ RSpec.describe PolishGeeks::DevTools::Commands::YmlParser do
85
81
  .to receive(:load)
86
82
  .and_return(file)
87
83
  end
88
- it { expect(subject.send(:parse_yaml, file)).to eq file }
84
+ it { expect(yml_parser.send(:parse_yaml, file)).to eq file }
89
85
  end
90
86
 
91
87
  describe '#check_params' do
92
88
  context 'when file have nil value' do
93
89
  let(:hash) { { key: 'my_key', val: { user: 'test', pass: nil } } }
94
90
 
95
- it { expect(subject.send(:check_params, hash)).to eq [:pass] }
91
+ it { expect(yml_parser.send(:check_params, hash)).to eq [:pass] }
96
92
  end
97
93
 
98
94
  context 'when file have not nil value' do
99
95
  let(:hash) { { key: 'key', val: 'val' } }
100
96
 
101
- it { expect(subject.send(:check_params, hash)).to be_empty }
97
+ it { expect(yml_parser.send(:check_params, hash)).to be_empty }
102
98
  end
103
99
  end
104
100
  end
@@ -1,26 +1,26 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe PolishGeeks::DevTools::ConfigManager do
4
+ subject(:config_manager) { described_class.new(name) }
4
5
  let(:name) { 'rubocop.yml' }
5
6
  let(:path) { '/path/to/config' }
6
- subject { described_class.new(name) }
7
7
 
8
8
  describe '#present?' do
9
9
  context 'when application config exist' do
10
- before { allow(subject).to receive(:application?) { true } }
11
- it { expect(subject.present?).to be true }
10
+ before { allow(config_manager).to receive(:application?) { true } }
11
+ it { expect(config_manager.present?).to be true }
12
12
  end
13
13
 
14
14
  context 'when application config does not exist' do
15
- before { allow(subject).to receive(:application?) { false } }
15
+ before { allow(config_manager).to receive(:application?) { false } }
16
16
  context 'and local config exist' do
17
- before { allow(subject).to receive(:local?) { true } }
18
- it { expect(subject.present?).to be true }
17
+ before { allow(config_manager).to receive(:local?) { true } }
18
+ it { expect(config_manager.present?).to be true }
19
19
  end
20
20
 
21
21
  context 'and local config does not exist' do
22
- before { allow(subject).to receive(:local?) { false } }
23
- it { expect(subject.present?).to be false }
22
+ before { allow(config_manager).to receive(:local?) { false } }
23
+ it { expect(config_manager.present?).to be false }
24
24
  end
25
25
  end
26
26
  end
@@ -28,20 +28,20 @@ RSpec.describe PolishGeeks::DevTools::ConfigManager do
28
28
  describe '#path' do
29
29
  context 'when application config exist' do
30
30
  before do
31
- allow(subject).to receive(:application?) { true }
32
- expect(subject).to receive(:application_path) { path }
31
+ allow(config_manager).to receive(:application?) { true }
32
+ expect(config_manager).to receive(:application_path) { path }
33
33
  end
34
- it { expect(subject.path).to eq path }
34
+ it { expect(config_manager.path).to eq path }
35
35
  end
36
36
 
37
37
  context 'when application config does not exist' do
38
38
  let(:path2) { '/path/to/config2' }
39
39
  before do
40
- allow(subject).to receive(:application?) { false }
41
- expect(subject).to receive(:application_path).never
42
- expect(subject).to receive(:local_path) { path2 }
40
+ allow(config_manager).to receive(:application?) { false }
41
+ expect(config_manager).to receive(:application_path).never
42
+ expect(config_manager).to receive(:local_path) { path2 }
43
43
  end
44
- it { expect(subject.path).to be path2 }
44
+ it { expect(config_manager.path).to be path2 }
45
45
  end
46
46
  end
47
47
 
@@ -52,29 +52,29 @@ RSpec.describe PolishGeeks::DevTools::ConfigManager do
52
52
  end
53
53
 
54
54
  context 'and file exist' do
55
- before { expect(subject).to receive(:local_path) { path } }
56
- it { expect(subject.send(:local?)).to be true }
55
+ before { expect(config_manager).to receive(:local_path) { path } }
56
+ it { expect(config_manager.send(:local?)).to be true }
57
57
  end
58
58
 
59
59
  context 'and file does not exist' do
60
- before { expect(subject).to receive(:local_path) { nil } }
61
- it { expect(subject.send(:local?)).to be false }
60
+ before { expect(config_manager).to receive(:local_path) { nil } }
61
+ it { expect(config_manager.send(:local?)).to be false }
62
62
  end
63
63
  end
64
64
 
65
65
  context 'when config name not present' do
66
- subject { described_class.new(nil) }
67
- it { expect(subject.send(:local?)).to be false }
66
+ subject(:config_manager) { described_class.new(nil) }
67
+ it { expect(config_manager.send(:local?)).to be false }
68
68
  end
69
69
  end
70
70
 
71
71
  describe '#local_path' do
72
72
  before do
73
73
  allow(PolishGeeks::DevTools).to receive(:gem_root) { path }
74
- expect(subject).to receive(:fetch_path).with(path) { path }
74
+ expect(config_manager).to receive(:fetch_path).with(path) { path }
75
75
  end
76
76
 
77
- it { expect(subject.send(:local_path)).to eq(path) }
77
+ it { expect(config_manager.send(:local_path)).to eq(path) }
78
78
  end
79
79
 
80
80
  describe '#application?' do
@@ -84,29 +84,29 @@ RSpec.describe PolishGeeks::DevTools::ConfigManager do
84
84
  end
85
85
 
86
86
  context 'and file exist' do
87
- before { expect(subject).to receive(:application_path) { path } }
88
- it { expect(subject.send(:application?)).to be true }
87
+ before { expect(config_manager).to receive(:application_path) { path } }
88
+ it { expect(config_manager.send(:application?)).to be true }
89
89
  end
90
90
 
91
91
  context 'and file does not exist' do
92
- before { expect(subject).to receive(:application_path) { nil } }
93
- it { expect(subject.send(:application?)).to be false }
92
+ before { expect(config_manager).to receive(:application_path) { nil } }
93
+ it { expect(config_manager.send(:application?)).to be false }
94
94
  end
95
95
  end
96
96
 
97
97
  context 'when config name not present' do
98
- subject { described_class.new(nil) }
99
- it { expect(subject.send(:application?)).to be false }
98
+ subject(:config_manager) { described_class.new(nil) }
99
+ it { expect(config_manager.send(:application?)).to be false }
100
100
  end
101
101
  end
102
102
 
103
103
  describe '#application_path' do
104
104
  before do
105
105
  allow(PolishGeeks::DevTools).to receive(:app_root) { path }
106
- expect(subject).to receive(:fetch_path).with(path) { path }
106
+ expect(config_manager).to receive(:fetch_path).with(path) { path }
107
107
  end
108
108
 
109
- it { expect(subject.send(:application_path)).to eq(path) }
109
+ it { expect(config_manager.send(:application_path)).to eq(path) }
110
110
  end
111
111
 
112
112
  describe '#fetch_path' do
@@ -114,11 +114,11 @@ RSpec.describe PolishGeeks::DevTools::ConfigManager do
114
114
 
115
115
  context 'file exist' do
116
116
  before { expect(File).to receive(:exist?).with(config_file) { true } }
117
- it { expect(subject.send(:fetch_path, path)).to eq(config_file) }
117
+ it { expect(config_manager.send(:fetch_path, path)).to eq(config_file) }
118
118
  end
119
119
 
120
120
  context 'file does not exist' do
121
- it { expect(subject.send(:fetch_path, path)).to be nil }
121
+ it { expect(config_manager.send(:fetch_path, path)).to be nil }
122
122
  end
123
123
  end
124
124
  end
@@ -1,37 +1,37 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe PolishGeeks::DevTools::Config do
4
- subject { described_class.new }
4
+ subject(:config) { described_class.new }
5
5
 
6
6
  described_class::COMMANDS.each do |attribute|
7
7
  describe "#{attribute}=" do
8
8
  let(:value) { rand }
9
- before { subject.public_send(:"#{attribute}=", value) }
9
+ before { config.public_send(:"#{attribute}=", value) }
10
10
 
11
11
  it 'assigns a given value' do
12
- expect(subject.public_send(attribute)).to eq value
12
+ expect(config.public_send(attribute)).to eq value
13
13
  end
14
14
  end
15
15
 
16
16
  describe "#{attribute}?" do
17
17
  let(:value) { rand(2) == 0 }
18
- before { subject.public_send(:"#{attribute}=", value) }
18
+ before { config.public_send(:"#{attribute}=", value) }
19
19
 
20
20
  it 'assigns a given value' do
21
- expect(subject.public_send(:"#{attribute}?")).to eq value
21
+ expect(config.public_send(:"#{attribute}?")).to eq value
22
22
  end
23
23
  end
24
24
  end
25
25
 
26
26
  describe '.setup' do
27
- subject { described_class }
27
+ subject(:config) { described_class }
28
28
  let(:instance) { described_class.new }
29
29
  let(:block) { -> {} }
30
30
 
31
31
  before do
32
32
  instance
33
33
 
34
- expect(subject)
34
+ expect(config)
35
35
  .to receive(:new)
36
36
  .and_return(instance)
37
37
 
@@ -43,18 +43,18 @@ RSpec.describe PolishGeeks::DevTools::Config do
43
43
  .to receive(:freeze)
44
44
  end
45
45
 
46
- it { subject.setup(&block) }
46
+ it { config.setup(&block) }
47
47
  end
48
48
 
49
49
  describe '#initialize' do
50
50
  described_class::COMMANDS.each do |attribute|
51
51
  it "should have #{attribute} command turned on by default" do
52
- expect(subject.public_send(attribute)).to eq true
52
+ expect(config.public_send(attribute)).to eq true
53
53
  end
54
54
  end
55
55
 
56
56
  it 'has simplecov_threshold set to 100 by default' do
57
- expect(subject.simplecov_threshold).to eq 100
57
+ expect(config.simplecov_threshold).to eq 100
58
58
  end
59
59
  end
60
60
  end
@@ -2,14 +2,14 @@ require 'spec_helper'
2
2
 
3
3
  RSpec.describe PolishGeeks::DevTools::Errors do
4
4
  describe 'BaseError' do
5
- subject { described_class::BaseError }
5
+ subject(:errors) { described_class::BaseError }
6
6
 
7
- specify { expect(subject).to be < StandardError }
7
+ specify { expect(errors).to be < StandardError }
8
8
  end
9
9
 
10
10
  describe 'NotImplementedError' do
11
- subject { described_class::NotImplementedError }
11
+ subject(:errors) { described_class::NotImplementedError }
12
12
 
13
- specify { expect(subject).to be < described_class::BaseError }
13
+ specify { expect(errors).to be < described_class::BaseError }
14
14
  end
15
15
  end
@@ -2,13 +2,13 @@ require 'spec_helper'
2
2
 
3
3
  RSpec.describe PolishGeeks::DevTools::Hash do
4
4
  describe 'same_key_structure?' do
5
- subject { h1.same_key_structure?(h2) }
5
+ subject(:hash) { h1.same_key_structure?(h2) }
6
6
 
7
7
  context 'when both are empty' do
8
8
  let(:h1) { described_class.new }
9
9
  let(:h2) { described_class.new }
10
10
 
11
- it { expect(subject).to be true }
11
+ it { expect(hash).to be true }
12
12
  end
13
13
 
14
14
  context 'when first hash is not equal to second' do
@@ -16,14 +16,14 @@ RSpec.describe PolishGeeks::DevTools::Hash do
16
16
  let(:h1) { described_class.new.merge(a: 1) }
17
17
  let(:h2) { described_class.new.merge(b: 1) }
18
18
 
19
- it { expect(subject).to be false }
19
+ it { expect(hash).to be false }
20
20
  end
21
21
 
22
22
  context 'on the second level' do
23
23
  let(:h1) { described_class.new.merge(a: { b: 2 }) }
24
24
  let(:h2) { described_class.new.merge(a: { c: 3 }) }
25
25
 
26
- it { expect(subject).to be false }
26
+ it { expect(hash).to be false }
27
27
  end
28
28
  end
29
29
 
@@ -31,7 +31,7 @@ RSpec.describe PolishGeeks::DevTools::Hash do
31
31
  let(:h1) { described_class.new.merge(a: { b: rand }) }
32
32
  let(:h2) { described_class.new.merge(a: { b: rand }) }
33
33
 
34
- it { expect(subject).to be true }
34
+ it { expect(hash).to be true }
35
35
  end
36
36
  end
37
37
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe PolishGeeks::DevTools::Logger do
4
- subject { described_class.new }
4
+ subject(:logger) { described_class.new }
5
5
 
6
6
  let(:task) { PolishGeeks::DevTools::Commands::Rubocop.new }
7
7
  let(:tmp) { double }
@@ -15,13 +15,13 @@ RSpec.describe PolishGeeks::DevTools::Logger do
15
15
  expect(tmp)
16
16
  .to receive(:generator?)
17
17
  .and_return(true)
18
- expect(subject)
18
+ expect(logger)
19
19
  .to receive(:info)
20
20
  .with(task)
21
21
  end
22
22
 
23
23
  it 'returns some information' do
24
- subject.log(task)
24
+ logger.log(task)
25
25
  end
26
26
  end
27
27
 
@@ -36,13 +36,13 @@ RSpec.describe PolishGeeks::DevTools::Logger do
36
36
  expect(tmp)
37
37
  .to receive(:valid?)
38
38
  .and_return(false)
39
- expect(subject)
39
+ expect(logger)
40
40
  .to receive(:fatal)
41
41
  .with(tmp)
42
42
  end
43
43
 
44
44
  it 'raises RequirementsError' do
45
- expect { subject.log(tmp) }
45
+ expect { logger.log(tmp) }
46
46
  .to raise_error PolishGeeks::DevTools::Errors::RequirementsError
47
47
  end
48
48
  end
@@ -69,10 +69,10 @@ RSpec.describe PolishGeeks::DevTools::Logger do
69
69
  end
70
70
 
71
71
  it 'displays "OK" text' do
72
- expect(subject)
72
+ expect(logger)
73
73
  .to receive(:printf)
74
74
  .with('%-50s %2s', 'Rubocop ', "\e[32mOK\e[0m\n")
75
- subject.send(:info, task)
75
+ logger.send(:info, task)
76
76
  end
77
77
  end
78
78
 
@@ -96,10 +96,10 @@ RSpec.describe PolishGeeks::DevTools::Logger do
96
96
  end
97
97
 
98
98
  it 'displays "OK" text' do
99
- expect(subject)
99
+ expect(logger)
100
100
  .to receive(:printf)
101
101
  .with('%-50s %2s', 'Rubocop ', "\e[32mGENERATED\e[0m\n")
102
- subject.send(:info, task)
102
+ logger.send(:info, task)
103
103
  end
104
104
  end
105
105
 
@@ -120,7 +120,7 @@ RSpec.describe PolishGeeks::DevTools::Logger do
120
120
  end
121
121
 
122
122
  it 'raises UnknownTaskType' do
123
- expect { subject.send(:info, tmp) }
123
+ expect { logger.send(:info, tmp) }
124
124
  .to raise_error PolishGeeks::DevTools::Errors::UnknownTaskType
125
125
  end
126
126
  end
@@ -138,10 +138,10 @@ RSpec.describe PolishGeeks::DevTools::Logger do
138
138
  end
139
139
 
140
140
  it 'returns a message' do
141
- expect(subject)
141
+ expect(logger)
142
142
  .to receive(:printf)
143
143
  .with('%-30s %20s', 'Rubocop ', "\e[31mFAILURE\e[0m\n\n")
144
- subject.send(:fatal, task)
144
+ logger.send(:fatal, task)
145
145
  end
146
146
  end
147
147
  end
@@ -155,7 +155,7 @@ RSpec.describe PolishGeeks::DevTools::Logger do
155
155
  end
156
156
 
157
157
  it 'returns the label' do
158
- expect(subject.send(:label, task)).to eq 'Rubocop'
158
+ expect(logger.send(:label, task)).to eq 'Rubocop'
159
159
  end
160
160
  end
161
161
  end