Method: PDK::Test::Unit.list
- Defined in:
- lib/pdk/tests/unit.rb
.list(options = {}) ⇒ Object
Returns array of { :id, :full_description }.
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/pdk/tests/unit.rb', line 234 def self.list( = {}) require 'pdk/util' require 'pdk/util/bundler' PDK::Util::Bundler.ensure_binstubs!('rake') environment = {} environment['PUPPET_GEM_VERSION'] = [:puppet] if [:puppet] output = rake('spec_list_json', 'Finding unit tests.', environment) rspec_json = PDK::Util.find_first_json_in(output[:stdout]) raise PDK::CLI::FatalError, format('Failed to find valid JSON in output from rspec: %{output}', output: output[:stdout]) unless rspec_json if rspec_json['examples'].empty? = rspec_json['messages'][0] return [] if == 'No examples found.' raise PDK::CLI::FatalError, format('Unable to enumerate examples. rspec reported: %{message}', message: ) else examples = [] rspec_json['examples'].each do |example| examples << { file_path: example['file_path'], id: example['id'], full_description: example['full_description'] } end examples end end |