Sha256: d451f023cd0e3695296f6818daa59de48e74fcfa16fddb65638e461fdff00567

Contents?: true

Size: 1.59 KB

Versions: 10

Compression:

Stored size: 1.59 KB

Contents

ENV['TEST'] = '1'
# Ensures aws api never called. Fixture home folder does not contain ~/.aws/credentails
ENV['HOME'] = "spec/fixtures/home"
# We'll always re-generate a new lono project in tmp. It can be:
#
#   1. copied from spec/fixtures/lono_project
#   2. generated from `lono new`
#
# This is done because changing LONO_ROOT for specs was a mess.
ENV['LONO_ROOT'] = "tmp/lono_project" # this gets kept

require "pp"
require "byebug"

# require "bundler"
# Bundler.require(:development)

root = File.expand_path("../", File.dirname(__FILE__))
require "#{root}/lib/lono"

module Helper
  def execute(cmd)
    puts "Running: #{cmd}" if show_command?
    out = `#{cmd}`
    puts out if show_command?
    out
  end

  # Added SHOW_COMMAND because DEBUG is also used by other libraries like
  # bundler and it shows its internal debugging logging also.
  def show_command?
    ENV['DEBUG'] || ENV['SHOW_COMMAND']
  end

  def ensure_tmp_exists
    FileUtils.mkdir_p("tmp")
  end

  # Copies spec/fixtures/lono_project to tmp/lono_project,
  # Main fixture we'll use because it's faster
  def copy_lono_project
    destroy_lono_project # just in case KEEP_TMP_PROJECT is used
    FileUtils.cp_r("spec/fixtures/lono_project", "tmp/lono_project")
  end

  def destroy_lono_project
    # Only use KEEP_TMP_PROJECT if you are testing exactly 1 spec for debugging
    # or it'll affect other tests.
    FileUtils.rm_rf(Lono.root)
  end
end

RSpec.configure do |c|
  c.include Helper
  c.before(:all) do
    ensure_tmp_exists
    copy_lono_project
  end
  c.after(:all) do
    destroy_lono_project unless ENV['KEEP_TMP_PROJECT']
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
lono-4.2.1 spec/spec_helper.rb
lono-4.2.0 spec/spec_helper.rb
lono-4.1.0 spec/spec_helper.rb
lono-4.0.6 spec/spec_helper.rb
lono-4.0.5 spec/spec_helper.rb
lono-4.0.4 spec/spec_helper.rb
lono-4.0.3 spec/spec_helper.rb
lono-4.0.2 spec/spec_helper.rb
lono-4.0.1 spec/spec_helper.rb
lono-4.0.0 spec/spec_helper.rb