Sha256: d7998e8f41f033b8cd37f74e172ef9550c7e2d253b4e9f7835a8ddcfabd47c01

Contents?: true

Size: 940 Bytes

Versions: 9

Compression:

Stored size: 940 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'
        ENV['DISABLE_SPRING'] = '1'

        %x(#{suspenders_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 suspenders_bin
    File.join(root_path, 'bin', 'mj-suspenders')
  end

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mj-suspenders-0.0.9 spec/support/suspenders.rb
mj-suspenders-0.0.8 spec/support/suspenders.rb
mj-suspenders-0.0.7 spec/support/suspenders.rb
mj-suspenders-0.0.6 spec/support/suspenders.rb
mj-suspenders-0.0.5 spec/support/suspenders.rb
mj-suspenders-0.0.4 spec/support/suspenders.rb
mj-suspenders-0.0.3 spec/support/suspenders.rb
mj-suspenders-0.0.2 spec/support/suspenders.rb
mj-suspenders-0.0.1 spec/support/suspenders.rb