aboutsummaryrefslogtreecommitdiffstats
path: root/spec/spec_helper.rb
diff options
context:
space:
mode:
authorJames Thompson <james.b.thompson@gmail.com>2012-03-14 11:40:16 +0200
committerJames Thompson <james.b.thompson@gmail.com>2012-03-14 11:40:16 +0200
commit56d7747f54e86993415b76c92e101608e5ea44e2 (patch)
tree025b7b37f50c4c291e7e676286e7767c40adb1f9 /spec/spec_helper.rb
downloadrefinerycms-pc_banners-56d7747f54e86993415b76c92e101608e5ea44e2.tar.gz
refinerycms-pc_banners-56d7747f54e86993415b76c92e101608e5ea44e2.tar.bz2
refinerycms-pc_banners-56d7747f54e86993415b76c92e101608e5ea44e2.zip
initial commit
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r--spec/spec_helper.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
new file mode 100644
index 0000000..2f4b5d9
--- /dev/null
+++ b/spec/spec_helper.rb
@@ -0,0 +1,50 @@
+def setup_environment
+ # Configure Rails Environment
+ ENV["RAILS_ENV"] ||= 'test'
+
+ require File.expand_path("../dummy/config/environment", __FILE__)
+
+ require 'rspec/rails'
+ require 'capybara/rspec'
+
+ Rails.backtrace_cleaner.remove_silencers!
+
+ RSpec.configure do |config|
+ config.mock_with :rspec
+ config.treat_symbols_as_metadata_keys_with_true_values = true
+ config.filter_run :focus => true
+ config.run_all_when_everything_filtered = true
+ end
+end
+
+def each_run
+ Rails.cache.clear
+ ActiveSupport::Dependencies.clear
+ FactoryGirl.reload
+
+ # Requires supporting files with custom matchers and macros, etc,
+ # in ./support/ and its subdirectories including factories.
+ ([Rails.root.to_s] | ::Refinery::Plugins.registered.pathnames).map{|p|
+ Dir[File.join(p, 'spec', 'support', '**', '*.rb').to_s]
+ }.flatten.sort.each do |support_file|
+ require support_file
+ end
+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
+ # 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.
+ setup_environment
+ end
+
+ Spork.each_run do
+ # This code will be run each time you run your specs.
+ each_run
+ end
+else
+ setup_environment
+ each_run
+end