Sha256: e9cf4d0d39fa4dde293e428b6200c96d1c187ffe5baff318bc342b189bec9791

Contents?: true

Size: 908 Bytes

Versions: 11

Compression:

Stored size: 908 Bytes

Contents

module SuspendersTestHelpers
  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_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

11 entries across 11 versions & 1 rubygems

Version Path
welaika-suspenders-2.7.1 spec/support/suspenders.rb
welaika-suspenders-2.7.0 spec/support/suspenders.rb
welaika-suspenders-2.6.0 spec/support/suspenders.rb
welaika-suspenders-2.5.0 spec/support/suspenders.rb
welaika-suspenders-2.4.0 spec/support/suspenders.rb
welaika-suspenders-2.3.0 spec/support/suspenders.rb
welaika-suspenders-2.2.1 spec/support/suspenders.rb
welaika-suspenders-2.2.0 spec/support/suspenders.rb
welaika-suspenders-2.1.0 spec/support/suspenders.rb
welaika-suspenders-2.0.0 spec/support/suspenders.rb
welaika-suspenders-2.0.0.pre spec/support/suspenders.rb