Skip to content

Instantly share code, notes, and snippets.

@denisoster
Created January 21, 2020 10:01
Show Gist options
  • Select an option

  • Save denisoster/633d39f7cc224bdb16ce1db5f141eb69 to your computer and use it in GitHub Desktop.

Select an option

Save denisoster/633d39f7cc224bdb16ce1db5f141eb69 to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
require 'rspec/core'
engine_names = ARGV.map do |val|
result = /\A.+\/apps\/([\w_]+)\/spec.*/.match(val)
result = /\Aapps\/([\w_]+)\/spec.*\z/.match(val) if result.nil?
result ? result[1] : nil
end
engine_names = engine_names.compact.uniq
if engine_names.size == 0
$stderr.puts "can't detect engine names"
exit 1
end
if engine_names.size > 1
$stderr.puts "multiple engines not supported, found: #{engine_names.join(', ')}"
exit 1
end
engine_name = engine_names.first
puts "Detect engine #{engine_name}"
engine_relative_path = "apps/#{engine_names.first}"
root_path = Dir.pwd
engine_full_path = File.join(root_path, engine_relative_path)
unless File.exist?(engine_full_path)
$stderr.puts "Can't find #{engine_full_path}"
exit 1
end
puts "Chdir to #{engine_full_path.inspect}"
Dir.chdir(engine_full_path) do
RSpec::Core::Runner.invoke
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment