Sha256: 43c2e708f3c799ec31b88a010ecf21446012cda01ed0b5a7a222c77945b7a969

Contents?: true

Size: 1.93 KB

Versions: 22

Compression:

Stored size: 1.93 KB

Contents

unless defined? SPEC_ROOT
  ENV["RAILS_ENV"] = "test"

  SPEC_ROOT = File.expand_path(File.dirname(__FILE__))

  unless defined? RADIANT_ROOT
    if env_file = ENV["RADIANT_ENV_FILE"]
      require env_file
    else
      require File.expand_path(SPEC_ROOT + "/../config/environment")
    end
  end
  require 'spec'
  require 'spec/rails'
  require 'dataset'

  module Kernel
    def rputs(*args)
      puts *["<pre>", args.collect {|a| CGI.escapeHTML(a.inspect)}, "</pre>"]
    end
  end

  class ActiveSupport::TestCase
    include Dataset
    datasets_directory "#{RADIANT_ROOT}/spec/datasets"
    Dataset::ContextClassMethods.datasets_database_dump_path = File.expand_path(RAILS_ROOT + '/tmp/dataset')

    class << self
      # Class method for test helpers
      def test_helper(*names)
        names.each do |name|
          name = name.to_s
          name = $1 if name =~ /^(.*?)_test_helper$/i
          name = name.singularize
          first_time = true
          begin
            constant = (name.camelize + 'TestHelper').constantize
            self.class_eval { include constant }
          rescue NameError
            filename = File.expand_path(SPEC_ROOT + '/../test/helpers/' + name + '_test_helper.rb')
            require filename if first_time
            first_time = false
            retry
          end
        end
      end
      alias :test_helpers :test_helper
    end
  end

  Dir[RADIANT_ROOT + '/spec/matchers/*_matcher.rb'].each do |matcher|
    require matcher
  end

  module Spec
    module Application
      module ExampleExtensions
        def rails_log
          log = IO.read(RAILS_ROOT + '/log/test.log')
          log.should_not be_nil
          log
        end
      end
    end
  end

  Spec::Runner.configure do |config|
    config.include Spec::Application::ExampleExtensions

    config.use_transactional_fixtures = true
    config.use_instantiated_fixtures  = false
    config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
  end
end

Version data entries

22 entries across 22 versions & 3 rubygems

Version Path
radiant-1.0.0.rc2 spec/spec_helper.rb
radiant-1.0.0.rc1 spec/spec_helper.rb
radiantcms-couchrest_model-0.2.4 spec/spec_helper.rb
radiantcms-couchrest_model-0.2.2 spec/spec_helper.rb
radiantcms-couchrest_model-0.2.1 spec/spec_helper.rb
radiantcms-couchrest_model-0.2 spec/spec_helper.rb
radiantcms-couchrest_model-0.1.9 spec/spec_helper.rb
radiantcms-couchrest_model-0.1.8 spec/spec_helper.rb
radiantcms-couchrest_model-0.1.7 spec/spec_helper.rb
radiantcms-couchrest_model-0.1.6 spec/spec_helper.rb
radiantcms-couchrest_model-0.1.5 spec/spec_helper.rb
radiantcms-couchrest_model-0.1.4 spec/spec_helper.rb
radiantcms-couchrest_model-0.1.3 spec/spec_helper.rb
radiantcms-couchrest_model-0.1.2 spec/spec_helper.rb
radiantcms-couchrest_model-0.1.1 spec/spec_helper.rb
radiantcms-couchrest_model-0.1 spec/spec_helper.rb
radiant-0.9.1 spec/spec_helper.rb
radiant-0.8.2 spec/spec_helper.rb
radiant-0.9.0.rc2 spec/spec_helper.rb
radiant-rc-0.9.0 spec/spec_helper.rb