Removed superfluous 'tracks' directory at the root of the repository.

Testing commits to github.
This commit is contained in:
bsag 2008-05-20 21:28:26 +01:00
parent 6a42901514
commit 4cbf5a34d3
2269 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,26 @@
# We are always a test environment and should never be anything else
ENV["RAILS_ENV"] ||= "test"
require File.join(File.dirname(__FILE__), 'ptk')
# Set up RAILS_ROOT to #{plugin_path}/test
unless defined?(RAILS_ROOT)
root_path = PTK::LoadPath.expand(__FILE__, '..', '..')
unless RUBY_PLATFORM =~ /mswin32/
require 'pathname'
root_path = Pathname.new(root_path).cleanpath(true).to_s
end
RAILS_ROOT = root_path
end
# add #{plugin_path}/test/lib
PTK::LoadPath.add RAILS_ROOT, 'lib'
# add #{plugin_path}/lib
PTK::LoadPath.add RAILS_ROOT, '..', 'lib'
require 'rubygems'
require 'test/unit'
require 'active_support'

View file

@ -0,0 +1,11 @@
require 'action_pack'
require 'action_controller'
require 'action_controller/test_process'
ActionController::Base.ignore_missing_templates = true
if PTK::Configuration.load :routes
ActionController::Routing::Routes.reload rescue nil
end
class ActionController::Base; def rescue_action(e) raise e end; end

View file

@ -0,0 +1,4 @@
require 'action_mailer'
ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true

View file

@ -0,0 +1,27 @@
require 'active_record'
require 'active_record/fixtures'
ActiveRecord::Base.logger = Logger.new(File.join(RAILS_ROOT, 'test.log'))
# Load the database.yml from #{plugin_path}/test/config if it exists
if file = PTK::Configuration.find_path(:database)
config = YAML::load_file(file)
ActiveRecord::Base.establish_connection(config[ENV['DB'] || 'sqlite3'])
# Load a schema if it exists
if schema = PTK::Configuration.find_path(:schema)
load(schema)
# Setup fixtures if the directory exists
if fixtures = PTK::Configuration.find_path(:fixtures)
PTK::LoadPath.add fixtures
Test::Unit::TestCase.fixture_path = fixtures
Test::Unit::TestCase.use_instantiated_fixtures = false
end
end
end

View file

@ -0,0 +1,31 @@
# We require the initializer to setup the environment properly
unless defined?(Rails::Initializer)
if File.directory?("#{RAILS_ROOT}/../../../rails")
require "#{RAILS_ROOT}/../../../rails/railties/lib/initializer"
else
require 'rubygems'
require_gem 'rails'
require 'initializer'
end
Rails::Initializer.run(:set_load_path)
end
# We overwrite load_environment so we can have only one file
module Rails
class Initializer
def load_environment
end
end
end
# We overwrite the default log to be a directory up
module Rails
class Configuration
def default_log_path
File.join(root_path, "#{environment}.log")
end
end
end
# We then load it manually
PTK::Configuration.load :environment

View file

@ -0,0 +1,148 @@
require 'singleton'
module PTK
class Configuration
class << self
def load(config, fatal = false)
if (file = PTK::PathSet.instance.send(config)) == :ignore then false
elsif File.exists?(file)
require file
true
elsif fatal then raise LoadError, "PTK could not find #{file}"
else
STDERR.puts "PTK::WARNING: could not find #{file}"
false
end
end
def find_path(config, fatal = false)
if (file = PTK::PathSet.instance.send(config)) == :ignore then false
elsif File.exists?(file) then file
elsif fatal then raise LoadError, "PTK could not find #{file}"
else
STDERR.puts "PTK::WARNING: could not find #{file}"
false
end
end
def draw
yield PTK::PathSet.instance
end
end
end
class PathSet
include Singleton
attr_accessor :ptk_prefix
attr_accessor :config
attr_accessor :fixtures
attr_accessor :environment
attr_accessor :schema
attr_accessor :database
attr_accessor :routes
def initialize
self.ptk_prefix = 'ptk'
self.config = File.join(RAILS_ROOT, 'config')
self.fixtures = File.join(RAILS_ROOT, 'fixtures')
self.environment = File.join(self.config, 'environment.rb')
self.database = File.join(self.config, 'database.yml')
self.schema = File.join(self.config, 'schema.rb')
self.routes = File.join(self.config, 'routes.rb')
end
end
class Initializer
# The init.rb in the root directory of the plugin will be loaded by default
attr_accessor :init
# The specific environmental frameworks of a plugin, such as needing the ActionController
# ActionMailer or ActiveRecord gems to be preloaded. A special requirement called
# 'environment' will load tests as though they were in the test environment of a normal
# Rails application.
attr_accessor :frameworks
def frameworks
[@frameworks].flatten
end
# Suites are test extensions including assertions and various tools for easier testing
attr_accessor :suites
def suites
[@suites].flatten
end
# A container for the PathSet instance
attr_reader :paths
def initialize
self.init = true
self.frameworks = :none
self.suites = :all
@paths = PTK::PathSet.instance
end
def self.run(command = :process)
initializer = PTK::Initializer.new
yield initializer if block_given?
initializer.send(command)
end
def process
initialize_frameworks
initialize_suites
initialize_plugin
end
def initialize_frameworks
return if frameworks.include?(:none)
self.frameworks = [:rails] if frameworks.include?(:rails)
frameworks.each { |lib| require_ptk File.join('gem', lib.to_s) }
end
def initialize_suites
return if suites.include?(:none)
self.suites = all_suites if suites.include?(:all)
suites.each { |lib| require_ptk File.join('suite', lib.to_s) }
end
def initialize_plugin
return unless self.init
require File.join(RAILS_ROOT, '..', 'init')
end
protected
def all_suites
Dir.glob(File.join(RAILS_ROOT, 'lib', 'ptk', 'suite', '*.rb')).inject([]) do |a, file|
a << File.basename(file, '.rb').to_sym
a
end
end
def require_ptk(library)
file = paths.ptk_prefix.empty? ? library : File.join(paths.ptk_prefix, library)
require file
end
end
class LoadPath
def self.expand(file, *dirs)
File.join(*([File.expand_path(File.dirname(file))] << dirs))
end
def self.add(*dirs)
path = File.expand_path(File.join(*dirs))
$:.unshift path
$:.uniq!
end
end
end

View file

@ -0,0 +1,23 @@
class Test::Unit::TestCase
# http://project.ioni.st/post/217#post-217
#
# def test_new_publication
# assert_difference(Publication, :count) do
# post :create, :publication => {...}
# # ...
# end
# end
#
# modified by mabs29 to include arguments
def assert_difference(object, method = nil, difference = 1, *args)
initial_value = object.send(method, *args)
yield
assert_equal initial_value + difference, object.send(method, *args), "#{object}##{method}"
end
def assert_no_difference(object, method, *args, &block)
assert_difference object, method, 0, *args, &block
end
end