Sha256: e4443a9080b7dad5759548829a3472a95f2d68b082455329e3f04767c0a79907

Contents?: true

Size: 1.27 KB

Versions: 6

Compression:

Stored size: 1.27 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'pathname'
require 'optparse'

module QonfigSpecRunner
  extend self

  expand_gemfile_path = lambda do |gemfile_name|
    File.expand_path(File.join('..', 'gemfiles', gemfile_name), __dir__)
  end

  GEMFILES = {
    with_external_deps: expand_gemfile_path.call('with_external_deps.gemfile'),
    without_external_deps: expand_gemfile_path.call('without_external_deps.gemfile')
  }.freeze

  def run!
    OptionParser.new do |opts|
      opts.banner = 'Usage: bin/rspec [options]'

      opts.on(
        '-w', '--with-plugins',
        'Run tests with test for plugins'
      ) { run_with_specs_for_plugins! }

      opts.on(
        '-n', '--without-plugins',
        'Run tests without tests for plugins'
      ) { run_without_specs_for_plugins! }
    end.parse!
  end

  private

  def run_with_specs_for_plugins!
    ENV['TEST_PLUGINS'] = 'true'
    ENV['FULL_TEST_COVERAGE_CHECK'] = 'true'
    ENV['BUNDLE_GEMFILE'] = GEMFILES[:with_external_deps]
    run_tests!
  end

  def run_without_specs_for_plugins!
    ENV['BUNDLE_GEMFILE'] = GEMFILES[:without_external_deps]
    run_tests!
  end

  def run_tests!
    require 'rubygems'
    require 'bundler/setup'
    load Gem.bin_path('rspec-core', 'rspec')
  end
end

QonfigSpecRunner.run!

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
qonfig-0.28.0 bin/rspec
qonfig-0.27.0 bin/rspec
qonfig-0.26.0 bin/rspec
qonfig-0.25.0 bin/rspec
qonfig-0.24.1 bin/rspec
qonfig-0.24.0 bin/rspec