Method: PDK::Test::Unit.list
- Defined in:
- lib/pdk/tests/unit.rb
.list(options = {}) ⇒ Object
Returns array of { :id, :full_description }.
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/pdk/tests/unit.rb', line 224 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, _('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, _('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 |