spec/spec_helper.rb in active_metadata-0.5.2 vs spec/spec_helper.rb in active_metadata-0.6.0
- old
+ new
@@ -1,39 +1,21 @@
# encoding: utf-8
require 'rubygems'
-require "rails/all"
-require "logger"
-require 'rspec/core'
-require "sqlite3"
-require "rack/test/uploaded_file"
-require 'active_support/cache'
-$: << File.expand_path(File.dirname(__FILE__) + "/../app")
-gemfile = File.expand_path('../Gemfile', __FILE__)
+ENV["RAILS_ENV"] ||= 'test'
-begin
- ENV['BUNDLE_GEMFILE'] = gemfile
- require 'bundler'
- Bundler.setup
-rescue Bundler::GemNotFound => e
- STDERR.puts e.message
- STDERR.puts "Try running `bundle install`."
- exit!
-end if File.exist?(gemfile)
+require 'rails/all'
+require 'active_metadata'
+require 'rack/test/uploaded_file'
+require File.expand_path("../dummy/config/environment.rb", __FILE__)
-ENV["RAILS_ENV"] ||= 'test'
-ENV["ACTIVE_METADATA_ENV"] ||= 'test'
+ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
+Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
-ActiveRecord::Base.establish_connection YAML.load_file("config/database.yml")[ENV["RAILS_ENV"]]
-ActiveRecord::Base.logger = Logger.new "log/test.log"
-Rails.logger = ActiveRecord::Base.logger
-RAILS_CACHE = ActiveSupport::Cache::MemoryStore.new
-
-# loading ruby files
-require "#{File.dirname(__FILE__)}/../lib/engine.rb"
-Dir["spec/support/*.rb"].each {|f| require "support/#{(File.basename(f, File.extname(f)) )}"}
+require 'rspec/rails'
+
RSpec.configure do |config|
# == Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
@@ -51,16 +33,21 @@
# config.use_transactional_fixtures = true
config.before(:each) do
Document.delete_all
- Note.delete_all
- Watcher.delete_all
- Attachment.delete_all
- History.delete_all
+ ActiveMetadata::Note.delete_all
+ ActiveMetadata::Watcher.delete_all
+ ActiveMetadata::Attachment.delete_all
+ ActiveMetadata::History.delete_all
FileUtils.remove_dir File.expand_path('public/system/') if Dir.exist?(File.expand_path('public/system/'))
end
config.after(:suite) do
# seems that closing the established connection isn't really necessary
end
+end
+
+def test_pdf name='pdf_test'
+ doc = File.expand_path("../support/#{name}.pdf", __FILE__)
+ Rack::Test::UploadedFile.new(doc, "application/pdf")
end
\ No newline at end of file