Sha256: 151d23f17a3bcaba16d5b3c8beb1f5830329ca6b29d84ef8e6466242f880e193

Contents?: true

Size: 1.58 KB

Versions: 2

Compression:

Stored size: 1.58 KB

Contents

ENV["RAILS_ENV"] = 'test'

require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb'))

require 'test/unit'
require 'test_help'

class Test::Unit::TestCase

  self.fixture_path = File.expand_path( File.join(File.dirname(__FILE__), 'fixtures') )

  self.use_transactional_fixtures = true
  self.use_instantiated_fixtures  = false
  
  def setup
    Comatose.configure do |config|
      config.default_filter      = :textile
      config.default_processor   = :liquid
      config.authorization       = Proc.new { true }
      config.admin_authorization = Proc.new { true }
      config.admin_get_author    = Proc.new { request.env['REMOTE_ADDR'] }
      config.admin_get_root_page = Proc.new { ComatosePage.root }
    end
    TextFilters.default_filter = "Textile"
  end

  def create_page(options={})
    ComatosePage.create({ :title => 'Comatose Page', :author=>'test', :parent_id=>1 }.merge(options))
  end
  
  def comatose_page(sym)
    ComatosePage.find_by_slug(sym.to_s.dasherize)
  end
  
  def assert_difference(object, method = nil, difference = 1)
    initial_value = object.send(method)
    yield
    assert_equal initial_value + difference, object.send(method), "#{object}##{method}"
  end

  def assert_no_difference(object, method, &block)
    assert_difference object, method, 0, &block
  end

  class << self
    def should(behave,&block)
      method_name = "test_should_#{behave.gsub(' ', '_')}"
      if block
        define_method method_name, &block
      else
        puts ">>> Untested: #{name.sub(/Test$/,'')} should #{behave}"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
aslakjo-aslakjo-comatose-2.0.5.1 test/test_helper.rb
aslakjo-comatose-2.0.5.2 test/test_helper.rb