Sha256: 693b0efbf9da1b48a4e64a4e30558eb8d5869c375a07838db89dc18ad0980e26

Contents?: true

Size: 906 Bytes

Versions: 4

Compression:

Stored size: 906 Bytes

Contents

module FirestarterTestHelpers
  APP_NAME = 'dummy'

  def remove_project_directory
    FileUtils.rm_rf(project_path)
  end

  def create_tmp_directory
    FileUtils.mkdir_p(tmp_path)
  end

  def run_firestarter(arguments = nil)
    Dir.chdir(tmp_path) do
      Bundler.with_clean_env do
        ENV['TESTING'] = '1'

        %x(#{firestarter_bin} #{APP_NAME} #{arguments})
      end
    end
  end

  def drop_dummy_database
    if File.exists?(project_path)
      Dir.chdir(project_path) do
        Bundler.with_clean_env do
          `rake db:drop`
        end
      end
    end
  end

  def project_path
    @project_path ||= Pathname.new("#{tmp_path}/#{APP_NAME}")
  end

  private

  def tmp_path
    @tmp_path ||= Pathname.new("#{root_path}/tmp")
  end

  def firestarter_bin
    File.join(root_path, 'bin', 'firestarter')
  end

  def root_path
    File.expand_path('../../../', __FILE__)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gb-firestarter-0.3.1 spec/support/firestarter.rb
gb-firestarter-0.3.0 spec/support/firestarter.rb
gb-firestarter-0.2.0 spec/support/firestarter.rb
gb-firestarter-0.1.0 spec/support/firestarter.rb