TwP / webby

A lightweight and flexible website management system.

This URL has Read+Write access

TwP (author)
Sun Apr 05 21:16:42 -0700 2009
commit  83e6c0d77e9f8e73c8ba725f2df05a7e8a91f7db
tree    8c51f611a195cb1094cca74196de6e7e309565c5
parent  841b4639b281a8e1df42c7a584ad0ca4b72da010
webby / spec / spec_helper.rb
100644 59 lines (47 sloc) 1.4 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Equivalent to a header guard in C/C++
# Used to prevent the spec helper from being loaded more than once
unless defined? WEBBY_SPEC_HELPER
WEBBY_SPEC_HELPER = true
 
require 'fileutils'
require 'stringio'
 
begin
  require 'fake_web'
  $test_externals = true
rescue LoadError
  retry if require 'rubygems'
  $test_externals = false
end
 
require File.expand_path(
    File.join(File.dirname(__FILE__), %w[.. lib webby]))
 
Spec::Runner.configure do |config|
  config.before :all do
    @pwd = Dir.pwd
    Dir.chdir Webby.datapath('site')
    FileUtils.mkdir_p Webby.datapath('site', ::Webby.site.output_dir)
  end
 
  config.after :all do
    FileUtils.rm_rf(Webby.datapath('site', ::Webby.cairn))
    FileUtils.rm_rf(Dir.glob(Webby.datapath(%w[site output *])))
    Dir.chdir @pwd
  end
 
  # == Mock Framework
  #
  # RSpec uses it's own mocking framework by default. If you prefer to
  # use mocha, flexmock or RR, uncomment the appropriate line:
  #
  # config.mock_with :mocha
  # config.mock_with :flexmock
  # config.mock_with :rr
end
 
module Webby
  DATAPATH = ::Webby.path(%w[spec data])
  def self.datapath( *args )
    args.empty? ? DATAPATH : ::File.join(DATAPATH, args.flatten)
  end
end
 
$webby_log_output = StringIO.new
 
logger = Logging::Logger['Webby']
logger.clear_appenders
logger.add_appenders(Logging::Appenders::IO.new('stringio', $webby_log_output))
 
end # unless defined?
 
# EOF