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
@@ -2,17 +2,17 @@ require 'spec_helper'
2
2
 
3
3
  RSpec.describe PolishGeeks::DevTools::Commands::Brakeman do
4
4
  context 'class' do
5
- subject { described_class }
5
+ subject(:brakeman) { described_class }
6
6
 
7
7
  describe '#validators' do
8
8
  it 'works only when we have Rails framework' do
9
- expect(subject.validators).to eq [PolishGeeks::DevTools::Validators::Rails]
9
+ expect(brakeman.validators).to eq [PolishGeeks::DevTools::Validators::Rails]
10
10
  end
11
11
  end
12
12
  end
13
13
 
14
14
  context 'instance' do
15
- subject { described_class.new }
15
+ subject(:brakeman) { described_class.new }
16
16
 
17
17
  describe '#execute' do
18
18
  context 'when we run brakeman' do
@@ -23,42 +23,36 @@ RSpec.describe PolishGeeks::DevTools::Commands::Brakeman do
23
23
  expect(instance).to receive(:execute).with('bundle exec brakeman -q')
24
24
  end
25
25
 
26
- it 'executes the command' do
27
- subject.execute
28
- end
26
+ it { brakeman.execute }
29
27
  end
30
28
  end
31
29
 
32
30
  describe '#valid?' do
33
31
  context 'when warnings are equal 0' do
34
32
  before do
35
- expect(subject)
33
+ expect(brakeman)
36
34
  .to receive(:warnings)
37
35
  .and_return(0)
38
36
  end
39
37
 
40
38
  context 'and errors are equal 0' do
41
39
  before do
42
- expect(subject)
40
+ expect(brakeman)
43
41
  .to receive(:errors)
44
42
  .and_return(0)
45
43
  end
46
44
 
47
- it 'returns true' do
48
- expect(subject.valid?).to eq true
49
- end
45
+ it { expect(brakeman.valid?).to eq true }
50
46
  end
51
47
 
52
48
  context 'and errors are not equal 0' do
53
49
  before do
54
- expect(subject)
50
+ expect(brakeman)
55
51
  .to receive(:errors)
56
52
  .and_return(1)
57
53
  end
58
54
 
59
- it 'returns true' do
60
- expect(subject.valid?).to eq false
61
- end
55
+ it { expect(brakeman.valid?).to eq false }
62
56
  end
63
57
  end
64
58
  end
@@ -69,14 +63,14 @@ RSpec.describe PolishGeeks::DevTools::Commands::Brakeman do
69
63
  let(:templates) { rand(1000) }
70
64
 
71
65
  before do
72
- expect(subject).to receive(:models).and_return(models)
73
- expect(subject).to receive(:controllers).and_return(controllers)
74
- expect(subject).to receive(:templates).and_return(templates)
66
+ expect(brakeman).to receive(:models).and_return(models)
67
+ expect(brakeman).to receive(:controllers).and_return(controllers)
68
+ expect(brakeman).to receive(:templates).and_return(templates)
75
69
  end
76
70
 
77
71
  it 'uses details' do
78
72
  label = "Brakeman (#{controllers} con, #{models} mod, #{templates} temp)"
79
- expect(subject.label).to eq label
73
+ expect(brakeman.label).to eq label
80
74
  end
81
75
  end
82
76
 
@@ -86,11 +80,11 @@ RSpec.describe PolishGeeks::DevTools::Commands::Brakeman do
86
80
  let(:amount) { rand(1000) }
87
81
 
88
82
  before do
89
- subject.instance_variable_set(:@output, "#{name.to_s.capitalize} #{amount}")
83
+ brakeman.instance_variable_set(:@output, "#{name.to_s.capitalize} #{amount}")
90
84
  end
91
85
 
92
86
  it 'returns a proper value' do
93
- expect(subject.send(name)).to eq amount
87
+ expect(brakeman.send(name)).to eq amount
94
88
  end
95
89
  end
96
90
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe PolishGeeks::DevTools::Commands::BundlerAudit do
4
- subject { described_class.new }
4
+ subject(:bundler_audit) { described_class.new }
5
5
 
6
6
  describe '#execute' do
7
7
  let(:instance) { instance_double(PolishGeeks::DevTools::Shell) }
@@ -12,7 +12,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::BundlerAudit do
12
12
  .with('bundle-audit update 2>&1 > /dev/null; bundle-audit check')
13
13
  end
14
14
 
15
- it { subject.execute }
15
+ it { bundler_audit.execute }
16
16
  end
17
17
 
18
18
  describe '#valid?' do
@@ -29,16 +29,16 @@ RSpec.describe PolishGeeks::DevTools::Commands::BundlerAudit do
29
29
 
30
30
  Unpatched versions found!
31
31
  EOS
32
- subject.instance_variable_set('@output', output)
32
+ bundler_audit.instance_variable_set('@output', output)
33
33
  end
34
34
 
35
- it { expect(subject.valid?).to eq false }
35
+ it { expect(bundler_audit.valid?).to eq false }
36
36
  end
37
37
 
38
38
  context 'when there are no vulnerabilities' do
39
- before { subject.instance_variable_set('@output', 'No vulnerabilities found') }
39
+ before { bundler_audit.instance_variable_set('@output', 'No vulnerabilities found') }
40
40
 
41
- it { expect(subject.valid?).to eq true }
41
+ it { expect(bundler_audit.valid?).to eq true }
42
42
  end
43
43
  end
44
44
 
@@ -1,6 +1,6 @@
1
1
  RSpec.describe PolishGeeks::DevTools::Commands::EmptyMethods::FileParser do
2
+ subject(:file_parser) { described_class.new(file) }
2
3
  let(:file) { Tempfile.new('foo') }
3
- subject { described_class.new(file) }
4
4
 
5
5
  describe '#find_empty_methods' do
6
6
  context 'empty define_singleton_methods' do
@@ -20,7 +20,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::EmptyMethods::FileParser do
20
20
  file.read
21
21
  end
22
22
 
23
- it { expect(subject.find_empty_methods).to eq([2, 4, 5, 10]) }
23
+ it { expect(file_parser.find_empty_methods).to eq([2, 4, 5, 10]) }
24
24
  end
25
25
 
26
26
  context 'empty define_methods with comments' do
@@ -36,7 +36,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::EmptyMethods::FileParser do
36
36
  file.read
37
37
  end
38
38
 
39
- it { expect(subject.find_empty_methods).to eq([2, 4, 5]) }
39
+ it { expect(file_parser.find_empty_methods).to eq([2, 4, 5]) }
40
40
  end
41
41
 
42
42
  context 'empty define_methods' do
@@ -52,7 +52,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::EmptyMethods::FileParser do
52
52
  file.read
53
53
  end
54
54
 
55
- it { expect(subject.find_empty_methods).to eq([2, 4, 5]) }
55
+ it { expect(file_parser.find_empty_methods).to eq([2, 4, 5]) }
56
56
  end
57
57
 
58
58
  context 'singleton_methods and methods are defined' do
@@ -75,7 +75,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::EmptyMethods::FileParser do
75
75
  file.read
76
76
  end
77
77
 
78
- it { expect(subject.find_empty_methods).to be_empty }
78
+ it { expect(file_parser.find_empty_methods).to be_empty }
79
79
  end
80
80
 
81
81
  context 'empty one line method' do
@@ -84,7 +84,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::EmptyMethods::FileParser do
84
84
  file.read
85
85
  end
86
86
 
87
- it { expect(subject.find_empty_methods).to eq([1]) }
87
+ it { expect(file_parser.find_empty_methods).to eq([1]) }
88
88
  end
89
89
 
90
90
  context 'empty one line method with comment' do
@@ -93,7 +93,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::EmptyMethods::FileParser do
93
93
  file.read
94
94
  end
95
95
 
96
- it { expect(subject.find_empty_methods).to eq([1]) }
96
+ it { expect(file_parser.find_empty_methods).to eq([1]) }
97
97
  end
98
98
 
99
99
  context 'empty body method' do
@@ -103,7 +103,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::EmptyMethods::FileParser do
103
103
  file.read
104
104
  end
105
105
 
106
- it { expect(subject.find_empty_methods).to eq([1]) }
106
+ it { expect(file_parser.find_empty_methods).to eq([1]) }
107
107
  end
108
108
 
109
109
  context 'empty body method with comment' do
@@ -113,7 +113,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::EmptyMethods::FileParser do
113
113
  file.read
114
114
  end
115
115
 
116
- it { expect(subject.find_empty_methods).to eq([1]) }
116
+ it { expect(file_parser.find_empty_methods).to eq([1]) }
117
117
  end
118
118
 
119
119
  context 'empty method' do
@@ -126,7 +126,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::EmptyMethods::FileParser do
126
126
  file.read
127
127
  end
128
128
 
129
- it { expect(subject.find_empty_methods).to eq([1]) }
129
+ it { expect(file_parser.find_empty_methods).to eq([1]) }
130
130
  end
131
131
 
132
132
  context 'method with comments inside' do
@@ -140,7 +140,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::EmptyMethods::FileParser do
140
140
  file.read
141
141
  end
142
142
 
143
- it { expect(subject.find_empty_methods).to be_empty }
143
+ it { expect(file_parser.find_empty_methods).to be_empty }
144
144
  end
145
145
 
146
146
  context 'method which defines empty define_method inside' do
@@ -151,7 +151,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::EmptyMethods::FileParser do
151
151
  file.read
152
152
  end
153
153
 
154
- it { expect(subject.find_empty_methods).to eq([2]) }
154
+ it { expect(file_parser.find_empty_methods).to eq([2]) }
155
155
  end
156
156
 
157
157
  context 'method which defines empty define_singleton_method inside' do
@@ -164,7 +164,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::EmptyMethods::FileParser do
164
164
  file.read
165
165
  end
166
166
 
167
- it { expect(subject.find_empty_methods).to eq([2]) }
167
+ it { expect(file_parser.find_empty_methods).to eq([2]) }
168
168
  end
169
169
 
170
170
  context 'method which defines define_method inside' do
@@ -175,20 +175,20 @@ RSpec.describe PolishGeeks::DevTools::Commands::EmptyMethods::FileParser do
175
175
  file.read
176
176
  end
177
177
 
178
- it { expect(subject.find_empty_methods).to be_empty }
178
+ it { expect(file_parser.find_empty_methods).to be_empty }
179
179
  end
180
180
  end
181
181
 
182
182
  describe '#method_has_no_lines?' do
183
- it { expect(subject.send(:method_has_no_lines?, 2, 4)).to be_falsey }
184
- it { expect(subject.send(:method_has_no_lines?, 2, 3)).to be_truthy }
183
+ it { expect(file_parser.send(:method_has_no_lines?, 2, 4)).to be_falsey }
184
+ it { expect(file_parser.send(:method_has_no_lines?, 2, 3)).to be_truthy }
185
185
  end
186
186
 
187
187
  describe '#add_empty_method' do
188
- it { expect(subject.send(:add_empty_method, 2)).to eq [3] }
188
+ it { expect(file_parser.send(:add_empty_method, 2)).to eq [3] }
189
189
  end
190
190
 
191
191
  describe '#add_empty_method' do
192
- it { expect(subject.send(:add_empty_method, 2)).to eq [3] }
192
+ it { expect(file_parser.send(:add_empty_method, 2)).to eq [3] }
193
193
  end
194
194
  end
@@ -2,63 +2,57 @@ require 'spec_helper'
2
2
  require 'tempfile'
3
3
 
4
4
  RSpec.describe PolishGeeks::DevTools::Commands::EmptyMethods do
5
- subject { described_class.new }
5
+ subject(:empty_methods) { described_class.new }
6
6
  describe '#execute' do
7
7
  let(:file) { [rand.to_s] }
8
+ let(:empty_methods_output) { [] }
8
9
 
9
10
  before do
10
- expect(subject)
11
+ expect(empty_methods)
11
12
  .to receive(:files_to_analyze)
12
13
  .and_return(file)
13
14
  allow(described_class::FileParser)
14
15
  .to receive_message_chain(:new, :find_empty_methods)
15
- .and_return(empty_methods)
16
+ .and_return(empty_methods_output)
16
17
  end
17
18
 
18
19
  context 'when all files are valid' do
19
- let(:empty_methods) { [] }
20
- before do
21
- subject.execute
22
- end
20
+ before { empty_methods.execute }
23
21
 
24
- it 'sets appropriate variables' do
25
- expect(subject.output).to eq []
26
- expect(subject.counter).to eq(file.count)
27
- end
22
+ it { expect(empty_methods.output).to eq [] }
23
+ it { expect(empty_methods.counter).to eq(file.count) }
28
24
  end
29
25
 
30
26
  context 'when exist not valid file' do
31
- let(:empty_methods) { [rand.to_s, rand.to_s] }
27
+ let(:empty_methods_output) { [rand.to_s, rand.to_s] }
32
28
  before do
33
- expect(subject)
29
+ expect(empty_methods)
34
30
  .to receive(:sanitize)
35
31
  .with(file.first)
36
32
  .and_return(file.first)
37
- subject.execute
33
+ empty_methods.execute
38
34
  end
39
35
 
40
- it 'sets appropriate variables' do
41
- expect(subject.output.first).to eq "#{file.first} lines #{empty_methods}"
42
- expect(subject.counter).to eq(file.count)
43
- end
36
+ it { expect(empty_methods.output.first).to eq "#{file.first} lines #{empty_methods_output}" }
37
+ it { expect(empty_methods.counter).to eq(file.count) }
44
38
  end
45
39
  end
46
40
 
47
41
  describe '#valid?' do
48
42
  before do
49
- subject.instance_variable_set('@output', output)
43
+ empty_methods.instance_variable_set('@output', output)
50
44
  end
51
45
 
52
46
  context 'when output is empty' do
53
47
  let(:output) { [] }
54
48
 
55
- it { expect(subject.valid?).to eq true }
49
+ it { expect(empty_methods.valid?).to eq true }
56
50
  end
57
51
 
58
52
  context 'when output have some files' do
59
53
  let(:output) { ['file_name'] }
60
54
 
61
- it { expect(subject.valid?).to eq false }
55
+ it { expect(empty_methods.valid?).to eq false }
62
56
  end
63
57
  end
64
58
 
@@ -67,10 +61,10 @@ RSpec.describe PolishGeeks::DevTools::Commands::EmptyMethods do
67
61
  let(:expected) { "Empty methods: #{counter} files checked" }
68
62
 
69
63
  before do
70
- subject.instance_variable_set('@counter', counter)
64
+ empty_methods.instance_variable_set('@counter', counter)
71
65
  end
72
66
 
73
- it { expect(subject.label).to eq expected }
67
+ it { expect(empty_methods.label).to eq expected }
74
68
  end
75
69
 
76
70
  describe '#error_message' do
@@ -78,28 +72,28 @@ RSpec.describe PolishGeeks::DevTools::Commands::EmptyMethods do
78
72
  let(:expected) { "Following files contains blank methods: \n#{output.join("\n")}\n" }
79
73
 
80
74
  before do
81
- subject.instance_variable_set('@output', output)
75
+ empty_methods.instance_variable_set('@output', output)
82
76
  end
83
77
 
84
- it { expect(subject.error_message).to eq expected }
78
+ it { expect(empty_methods.error_message).to eq expected }
85
79
  end
86
80
 
87
81
  describe '#files_to_analyze' do
88
82
  let(:files) { [rand.to_s, rand.to_s] }
89
83
 
90
84
  before do
91
- expect(subject)
85
+ expect(empty_methods)
92
86
  .to receive(:files_from_path)
93
87
  .with('**/*.rb')
94
88
  .and_return(files)
95
89
 
96
- expect(subject)
90
+ expect(empty_methods)
97
91
  .to receive(:remove_excludes)
98
92
  .with(files)
99
93
  .and_return(files)
100
94
  end
101
95
 
102
- it { expect(subject.send(:files_to_analyze)).to eq files }
96
+ it { expect(empty_methods.send(:files_to_analyze)).to eq files }
103
97
  end
104
98
 
105
99
  describe '#remove_excludes' do
@@ -107,12 +101,12 @@ RSpec.describe PolishGeeks::DevTools::Commands::EmptyMethods do
107
101
  let(:excludes) { %w(lib exclude.txt) }
108
102
 
109
103
  before do
110
- expect(subject)
104
+ expect(empty_methods)
111
105
  .to receive(:excludes)
112
106
  .and_return(excludes)
113
107
  end
114
108
 
115
- it { expect(subject.send(:remove_excludes, files)).to eq ['file.rb'] }
109
+ it { expect(empty_methods.send(:remove_excludes, files)).to eq ['file.rb'] }
116
110
  end
117
111
 
118
112
  describe '#excludes' do
@@ -120,12 +114,12 @@ RSpec.describe PolishGeeks::DevTools::Commands::EmptyMethods do
120
114
  let(:expected) { configs + described_class::DEFAULT_PATHS_TO_EXCLUDE }
121
115
 
122
116
  before do
123
- expect(subject)
117
+ expect(empty_methods)
124
118
  .to receive(:config_excludes)
125
119
  .and_return(configs)
126
120
  end
127
121
 
128
- it { expect(subject.send(:excludes)).to eq expected }
122
+ it { expect(empty_methods.send(:excludes)).to eq expected }
129
123
  end
130
124
 
131
125
  describe '#config_excludes' do
@@ -142,7 +136,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::EmptyMethods do
142
136
  expect(PolishGeeks::DevTools::Config).to receive(:config) { config }
143
137
  end
144
138
 
145
- it { expect(subject.send(:config_excludes)).to eq(paths) }
139
+ it { expect(empty_methods.send(:config_excludes)).to eq(paths) }
146
140
  end
147
141
 
148
142
  context 'empty_methods_ignored is not set' do
@@ -157,7 +151,7 @@ RSpec.describe PolishGeeks::DevTools::Commands::EmptyMethods do
157
151
  expect(PolishGeeks::DevTools::Config).to receive(:config) { config }
158
152
  end
159
153
 
160
- it { expect(subject.send(:config_excludes)).to eq [] }
154
+ it { expect(empty_methods.send(:config_excludes)).to eq [] }
161
155
  end
162
156
  end
163
157
 
@@ -166,6 +160,6 @@ RSpec.describe PolishGeeks::DevTools::Commands::EmptyMethods do
166
160
  let(:app_root) { PolishGeeks::DevTools.app_root }
167
161
  let(:path) { "#{app_root}/#{file}" }
168
162
 
169
- it { expect(subject.send(:sanitize, "#{app_root}/#{path}")).to eq file }
163
+ it { expect(empty_methods.send(:sanitize, "#{app_root}/#{path}")).to eq file }
170
164
  end
171
165
  end