Sha256: 94849f423e7e369f42e25aa5d10e09a3edb1ef59cedbb6326568b4918ba62b39

Contents?: true

Size: 992 Bytes

Versions: 19

Compression:

Stored size: 992 Bytes

Contents

require 'rubygems'
require 'bundler'
Bundler.setup(:default, :development)

require 'test/unit'
require 'rack/test'

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))

require 'vitrine'

module VitrineTesting
  
  # Wrap the test run in mktimpdir where we will store our temp application
  def run(runner)
    Dir.mktmpdir("vitrine-tests") do | dir_path |
      @tempdir = dir_path
      super
    end
  ensure
    @tempdir = nil
  end
  
  def temporary_app_dir
    raise "Not within a tempdir block" unless @tempdir
    @tempdir
  end
  
  # Write a file out into 'public', creating the subdir tree
  def write_public(name)
    location = FileUtils.mkdir_p(File.dirname(File.join(@tempdir, 'public', name)))
    File.open(File.join(@tempdir, 'public', name), 'w') do | f |
      yield f
    end
  end
  
  # Return the vitrine default Vitrine app
  def app
    Vitrine::App.new.tap { |a| a.settings.set :root, @tempdir }
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
vitrine-0.0.31 test/helper.rb
vitrine-0.0.30 test/helper.rb
vitrine-0.0.29 test/helper.rb
vitrine-0.0.28 test/helper.rb
vitrine-0.0.27 test/helper.rb
vitrine-0.0.26 test/helper.rb
vitrine-0.0.25 test/helper.rb
vitrine-0.0.24 test/helper.rb
vitrine-0.0.23 test/helper.rb
vitrine-0.0.22 test/helper.rb
vitrine-0.0.21 test/helper.rb
vitrine-0.0.19 test/helper.rb
vitrine-0.0.18 test/helper.rb
vitrine-0.0.17 test/helper.rb
vitrine-0.0.16 test/helper.rb
vitrine-0.0.15 test/helper.rb
vitrine-0.0.14 test/helper.rb
vitrine-0.0.13 test/helper.rb
vitrine-0.0.12 test/helper.rb