Sha256: 7e17ab69ab268cb9e11459db539c96bb22299c83e848a5683208b183482fd404

Contents?: true

Size: 912 Bytes

Versions: 10

Compression:

Stored size: 912 Bytes

Contents

module SuspendersTestHelpers
  APP_NAME = "dummy_app"

  def remove_project_directory
    FileUtils.rm_rf(project_path)
  end

  def create_tmp_directory
    FileUtils.mkdir_p(tmp_path)
  end

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

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

  def drop_dummy_database
    if File.exist?(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 suspenders_bin
    File.join(root_path, 'bin', 'welaika-suspenders')
  end

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
welaika-suspenders-2.20.0 spec/support/suspenders.rb
welaika-suspenders-2.19.0 spec/support/suspenders.rb
welaika-suspenders-2.17.0 spec/support/suspenders.rb
welaika-suspenders-2.15.0 spec/support/suspenders.rb
welaika-suspenders-2.13.0 spec/support/suspenders.rb
welaika-suspenders-2.12.0 spec/support/suspenders.rb
welaika-suspenders-2.11.0 spec/support/suspenders.rb
welaika-suspenders-2.10.0 spec/support/suspenders.rb
welaika-suspenders-2.9.0 spec/support/suspenders.rb
welaika-suspenders-2.8.0 spec/support/suspenders.rb