Sha256: 56828e94a2fdf0761ddea03dcc1dde31ebddb5d7bb762819fbb7309e55324482

Contents?: true

Size: 895 Bytes

Versions: 5

Compression:

Stored size: 895 Bytes

Contents

module RobopartsTestHelpers
  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_roboparts(arguments = nil)
    Dir.chdir(tmp_path) do
      Bundler.with_clean_env do
        ENV['TESTING'] = '1'

        %x(#{roboparts_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 roboparts_bin
    File.join(root_path, 'bin', 'roboparts')
  end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
roboparts-0.6.4 spec/support/roboparts.rb
roboparts-0.6.3 spec/support/roboparts.rb
roboparts-0.6.2 spec/support/roboparts.rb
roboparts-0.6.1 spec/support/roboparts.rb
roboparts-0.6.0 spec/support/roboparts.rb