spec/spec_helper.rb in activeadmin-0.4.4 vs spec/spec_helper.rb in activeadmin-0.5.0.pre
- old
+ new
@@ -11,11 +11,11 @@
ActiveAdmin.register(Post){ belongs_to :user, :optional => true }
reload_menus!
end
def reload_menus!
- ActiveAdmin.application.namespaces.values.each{|n| n.load_menu! }
+ ActiveAdmin.application.namespaces.values.each{|n| n.reset_menu! }
end
# Sometimes we need to reload the routes within
# the application to test them out
def reload_routes!
@@ -47,20 +47,18 @@
# 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
+ def arbre(assigns = {}, helpers = mock_action_view, &block)
+ Arbre::Context.new(assigns, helpers, &block)
end
+ def render_arbre_component(assigns = {}, helpers = mock_action_view, &block)
+ arbre(assigns, helpers, &block).children.first
+ 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,15 +81,12 @@
end
end
ENV['RAILS_ENV'] = 'test'
+ENV['RAILS_ROOT'] = File.expand_path("../rails/rails-#{ENV['RAILS']}", __FILE__)
-require 'detect_rails_version'
-rails_version = detect_rails_version
-ENV['RAILS_ROOT'] = File.expand_path("../rails/rails-#{rails_version}", __FILE__)
-
# Create the test app if it doesn't exists
unless File.exists?(ENV['RAILS_ROOT'])
system 'rake setup'
end
@@ -99,10 +94,11 @@
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!
@@ -158,5 +154,9 @@
rescue MiniTest::Assertion => e
raise Test::Unit::AssertionFailedError, e.message
end
end
end
+
+# improve the performance of the specs suite by not logging anything
+# see http://blog.plataformatec.com.br/2011/12/three-tips-to-improve-the-performance-of-your-test-suite/
+Rails.logger.level = 4