norad_cli 0.1.19 → 0.1.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e59ae272be4575213e6e4a1ae0006a84e5eb069
4
- data.tar.gz: fcd29e17a780f3550a3c62d4b16c505db7268b9e
3
+ metadata.gz: 8ca0e03325e221db2ca3a367bb023d4d5838c0d9
4
+ data.tar.gz: b99ad1c5723bdd3de37cb02272ca72a7c0097461
5
5
  SHA512:
6
- metadata.gz: 292d9d37e8061927977261226c463d5fd02f0020ad92147d99d6e100e5ed60bddd05bfce0e191c42ff0a1d966f06b4332923216cf26266a15e2ef6864eb1a458
7
- data.tar.gz: 784a9255cf124973739cb992b776c6b1ef3d2183eb91d71c1707ebc6ed43de371c5759c85370a74a54ccf3728f15d79d4e84f0c9765e71abf35cd48bab9b1b9f
6
+ metadata.gz: 36264ce742ac208290b2d0073011b2a58e0749b7b3e410eeba86042aab209e033592a8efb00c81934e190e91b9d1ffdd28acebae6003250d839ddd1440df9152
7
+ data.tar.gz: 4752f3fe64b20ebdadcc3a7eec8decb92f3f911471765653b74e942d8d49f12ac955401f85302d5dcdbf7bd3d082bc7745807b0929cc814abc61c42f2bde07e9
@@ -251,28 +251,7 @@ class Sectest < Thor
251
251
  option :verbose, aliases: '-v', type: :boolean, desc: 'Turn on verbose logging'
252
252
  option :debug, aliases: '-d', type: :boolean, desc: 'Turn on debugging'
253
253
  define_method 'spec:image' do |name|
254
- # Set environment variables
255
- if options[:verbose]
256
- ENV['ENABLE_LOGS'] = 'true'
257
- end
258
-
259
- if options[:debug]
260
- ENV['ENABLE_NORAD_DEBUG'] = 'true'
261
- end
262
-
263
- ENV['SCAN_ASSESSMENT'] = 'true'
264
- ENV['TEST_RESULTS_SERVER_IMAGE'] = 'docker-images-test-results-server'
265
- ENV['UBUNTU_SSH_SERVER_IMAGE'] = 'docker-images-test-ubuntu-ssh-server'
266
-
267
- # Run the tests
268
- if File.exist?("spec/#{name}/#{name}_spec.rb")
269
- RSpec.clear_examples
270
- say("Testing spec/#{name}/#{name}_spec.rb")
271
- RSpec::Core::Runner.run(["spec/#{name}/#{name}_spec.rb"], $stderr, $stdout)
272
- else
273
- say("Warning: spec/#{name}/#{name}_spec.rb does not exist!\n", :yellow)
274
- say("Warning: No tests will be run for #{name}\n", :yellow)
275
- end
254
+ run_specs(name, options)
276
255
  end
277
256
 
278
257
  desc 'spec', 'Run all rspec tests for the entire repo (all sectests)'
@@ -280,12 +259,12 @@ class Sectest < Thor
280
259
  option :debug, aliases: '-d', type: :boolean, desc: 'Turn on debugging'
281
260
  def spec
282
261
  # Error check to ensure this is a plugin directory
283
- Dir.glob('sectests/*').select do |f|
262
+ specs = Dir.glob('sectests/*').map do |f|
284
263
  if File.directory? f
285
- # Build all for the sectest
286
- send('spec:image', f.split('/')[-1])
264
+ f.split('/')[-1]
287
265
  end
288
- end
266
+ end.compact
267
+ run_specs(specs, options)
289
268
  end
290
269
 
291
270
  desc 'seed', 'Create the containers.rb seed to import into the api'
@@ -349,4 +328,35 @@ class Sectest < Thor
349
328
  end
350
329
  end
351
330
  end
331
+
332
+ no_commands do
333
+ def run_specs(*specs, **opts)
334
+ # Set environment variables
335
+ if opts[:verbose]
336
+ ENV['ENABLE_LOGS'] = 'true'
337
+ end
338
+
339
+ if opts[:debug]
340
+ ENV['ENABLE_NORAD_DEBUG'] = 'true'
341
+ end
342
+
343
+ ENV['SCAN_ASSESSMENT'] = 'true'
344
+ ENV['TEST_RESULTS_SERVER_IMAGE'] = 'docker-images-test-results-server'
345
+ ENV['UBUNTU_SSH_SERVER_IMAGE'] = 'docker-images-test-ubuntu-ssh-server'
346
+
347
+ codes = specs.map do |spec|
348
+ # Run the tests
349
+ if File.exist?("spec/#{spec}/#{spec}_spec.rb")
350
+ RSpec.clear_examples
351
+ say("Testing spec/#{spec}/#{spec}_spec.rb")
352
+ RSpec::Core::Runner.run(["spec/#{spec}/#{spec}_spec.rb"], $stderr, $stdout)
353
+ else
354
+ say("Warning: spec/#{spec}/#{spec}_spec.rb does not exist!\n", :yellow)
355
+ say("Warning: No tests will be run for #{spec}\n", :yellow)
356
+ 0 # always return 0 if the spec doesn't exist
357
+ end
358
+ end
359
+ exit(codes.detect(-> { 0 }, &:nonzero?))
360
+ end
361
+ end
352
362
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module NoradCli
3
- VERSION = '0.1.19'
3
+ VERSION = '0.1.20'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: norad_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.19
4
+ version: 0.1.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Hitchcock
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-03-21 00:00:00.000000000 Z
13
+ date: 2017-03-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: git