aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/spec_helper.rb36
-rw-r--r--spec/support/refinery.rb2
2 files changed, 14 insertions, 24 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index b8df592..ea550e2 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,16 +1,17 @@
require 'rubygems'
-def setup_environment
- # Loading more in this block will cause your tests to run faster. However,
- # if you change any configuration or code from libraries loaded here, you'll
- # need to restart spork for it take effect.
-
+def load_all(*patterns)
+ patterns.each { |pattern| Dir[pattern].sort.each { |path| load File.expand_path(path) } }
+end
+
+def setup_environment
# Configure Rails Environment
ENV["RAILS_ENV"] = 'test'
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require 'rspec/rails'
require 'capybara/rspec'
+ require 'factory_girl_rails'
Rails.backtrace_cleaner.remove_silencers!
@@ -20,30 +21,17 @@ def setup_environment
end
def each_run
- require 'factory_girl_rails'
- require 'refinerycms-testing'
+ FactoryGirl.reload
+ ActiveSupport::Dependencies.clear
- Dir[File.expand_path("../../app/models/**/*.rb", __FILE__)].each do |model|
- load model
- end
-
- Dir[
- File.expand_path("../support/**/*.rb", __FILE__),
- File.expand_path("../factories/**/*.rb", __FILE__)
- ].each {|f| require f}
+ load_all 'spec/support/**/*.rb'
+ load_all 'spec/factories/**/*.rb'
end
# If spork is available in the Gemfile it'll be used but we don't force it.
unless (begin; require 'spork'; rescue LoadError; nil end).nil?
- Spork.prefork do
- setup_environment
-
- ActiveSupport::Dependencies.clear
- end
-
- Spork.each_run do
- each_run
- end
+ Spork.prefork { setup_environment }
+ Spork.each_run { each_run }
else
setup_environment
each_run
diff --git a/spec/support/refinery.rb b/spec/support/refinery.rb
index d761787..575ac2b 100644
--- a/spec/support/refinery.rb
+++ b/spec/support/refinery.rb
@@ -1,5 +1,7 @@
require 'refinerycms-testing'
+Refinery::Testing.load_factories
+
RSpec.configure do |config|
config.extend Refinery::Testing::ControllerMacros::Authentication, :type => :controller
config.extend Refinery::Testing::RequestMacros::Authentication, :type => :request