Sha256: 36c72c14f79deb771bb2a88ebe746ff9e23618405c7adea4dc8e4654ad642654

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

require 'simplecov'
require 'cli-test'
require 'fileutils'

SimpleCov.start

if ENV['CI'] == 'true'
  require 'codecov'
  SimpleCov.formatter = SimpleCov::Formatter::Codecov
else
  SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
end

require 'planter'

RSpec.configure do |c|
  c.expect_with(:rspec) { |e| e.syntax = :expect }
  c.before do
    ENV["RUBYOPT"] = '-W1'
    ENV['PLANTER_DEBUG'] = 'true'
    Planter.base_dir = File.expand_path('spec')
    allow(FileUtils).to receive(:remove_entry_secure).with(anything)
    allow(FileUtils).to receive(:mkdir_p).with(anything)
  end
  c.add_formatter 'd'
end

require 'open3'
require 'time'

module PlanterHelpers
  PLANTER_EXEC = File.join(File.dirname(__FILE__), '..', 'bin', 'plant')

  def planter_with_env(env, *args, stdin: nil)
    pread(env, 'bundle', 'exec', PLANTER_EXEC, "--base-dir=#{File.dirname(__FILE__)}", "--defaults", *args,
          stdin: stdin)
  end

  def pread(env, *cmd, stdin: nil)
    out, err, status = Open3.capture3(env, *cmd, stdin_data: stdin)
    unless status.success?
      raise [
        "Error (#{status}): #{cmd.inspect} failed", "STDOUT:", out.inspect, "STDERR:", err.inspect
      ].join("\n")
    end

    [out, err, status]
  end

  def planter(*args, stdin: nil)
    planter_with_env({}, *args, stdin: stdin)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
planter-cli-3.0.7 spec/spec_helper.rb
planter-cli-3.0.5 spec/spec_helper.rb