aboutsummaryrefslogtreecommitdiffstats
path: root/spec/spec_helper.rb
diff options
context:
space:
mode:
authorPhilip Arndt <parndt@gmail.com>2012-02-01 16:34:06 +1300
committerPhilip Arndt <parndt@gmail.com>2012-02-01 16:34:06 +1300
commit33bfa4dd231e4042456b3a70059c9cf57af858cf (patch)
treed51f175d17423e128cf23b294686fbb361a58189 /spec/spec_helper.rb
parent30ebf2d338cdd1eff3f78fe4f865c98c02b0ad7e (diff)
downloadrefinerycms-blog-33bfa4dd231e4042456b3a70059c9cf57af858cf.tar.gz
refinerycms-blog-33bfa4dd231e4042456b3a70059c9cf57af858cf.tar.bz2
refinerycms-blog-33bfa4dd231e4042456b3a70059c9cf57af858cf.zip
Added support for new code in Refinery CMS since resolve/refinerycms#1234
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r--spec/spec_helper.rb51
1 files changed, 36 insertions, 15 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 9d4bffe..21267d3 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,37 +1,58 @@
require 'rubygems'
-def load_all(*patterns)
- patterns.each { |pattern| Dir[pattern].sort.each { |path| load File.expand_path(path) } }
-end
-
-def setup_environment
+def setup_environment
# Configure Rails Environment
- ENV["RAILS_ENV"] = 'test'
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
-
+ ENV["RAILS_ENV"] ||= 'test'
+
+ require File.expand_path("../dummy/config/environment", __FILE__)
+
require 'rspec/rails'
require 'capybara/rspec'
require 'factory_girl_rails'
-
+
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
+
+ # set javascript driver for capybara
+ Capybara.javascript_driver = :selenium
+
+ # minimize password hashing stretches
+ Devise.stretches = 1
end
-def each_run
- FactoryGirl.reload
+def each_run
ActiveSupport::Dependencies.clear
- load_all 'spec/support/**/*.rb'
- load_all 'spec/factories/**/*.rb' if FactoryGirl.factories.none?
+ 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 { setup_environment }
- Spork.each_run { each_run }
+ 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