spec/spec_helper.rb in activeadmin-0.2.2 vs spec/spec_helper.rb in activeadmin-0.3.0
- old
+ new
@@ -1,22 +1,19 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH << File.expand_path('../support', __FILE__)
ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__)
-require 'rubygems'
+require 'detect_rails_version'
+ENV['RAILS'] = detect_rails_version
+
require "bundler"
Bundler.setup
require 'shoulda/active_record'
include Shoulda::ActiveRecord::Macros
-# Setup autoloading of ActiveAdmin and the load path
-$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
-autoload :ActiveAdmin, 'active_admin'
-
-
module ActiveAdminIntegrationSpecHelper
extend self
def load_defaults!
ActiveAdmin.unload!
@@ -26,11 +23,11 @@
ActiveAdmin.register(Post){ belongs_to :user, :optional => true }
reload_menus!
end
def reload_menus!
- ActiveAdmin.namespaces.values.each{|n| n.load_menu! }
+ ActiveAdmin.application.namespaces.values.each{|n| n.load_menu! }
end
# Sometimes we need to reload the routes within
# the application to test them out
def reload_routes!
@@ -62,10 +59,20 @@
# metadata[:behaviour][:describes] = ActiveAdmin.namespaces[:admin].resources['Post'].controller
module_eval &block
end
end
+ # Sets up an Arbre::Builder context
+ def setup_arbre_context!
+ include Arbre::Builder
+ let(:assigns){ {} }
+ let(:helpers){ mock_action_view }
+ before do
+ @_helpers = helpers
+ end
+ end
+
# Setup a describe block which uses capybara and rails integration
# test methods.
def describe_with_capybara(*args, &block)
describe *args do
include RSpec::Rails::IntegrationExampleGroup
@@ -83,31 +90,34 @@
end
alias_method :action_view, :mock_action_view
end
-ENV['RAILS'] ||= '3.0.0'
ENV['RAILS_ENV'] = 'test'
-
ENV['RAILS_ROOT'] = File.expand_path("../rails/rails-#{ENV["RAILS"]}", __FILE__)
# Create the test app if it doesn't exists
unless File.exists?(ENV['RAILS_ROOT'])
system 'rake setup'
end
+# Ensure the Active Admin load path is happy
+require 'rails'
+require 'active_admin'
+ActiveAdmin.application.load_paths = [ENV['RAILS_ROOT'] + "/app/admin"]
+
require ENV['RAILS_ROOT'] + '/config/environment'
require 'rspec/rails'
# Setup Some Admin stuff for us to play with
include ActiveAdminIntegrationSpecHelper
load_defaults!
reload_routes!
# Disabling authentication in specs so that we don't have to worry about
# it allover the place
-ActiveAdmin.authentication_method = false
-ActiveAdmin.current_user_method = false
+ActiveAdmin.application.authentication_method = false
+ActiveAdmin.application.current_user_method = false
# Don't add asset cache timestamps. Makes it easy to integration
# test for the presence of an asset file
ENV["RAILS_ASSET_ID"] = ''