spec/spec_helper.rb in smalruby-editor-0.0.6 vs spec/spec_helper.rb in smalruby-editor-0.0.7
- old
+ new
@@ -22,13 +22,10 @@
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
- load 'spec/steps/global_variable.rb', true
- Dir.glob('spec/steps/**/*_steps.rb') { |f| load f, true }
-
# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
RSpec.configure do |config|
@@ -46,11 +43,11 @@
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
- config.use_transactional_fixtures = true
+ config.use_transactional_fixtures = false
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
@@ -104,12 +101,43 @@
config.include JsonSpec::Helpers
config.after(javascript: true) do
page.execute_script('window.onbeforeunload = null')
- if selenium?
- FileUtils.rm_rf(downloads_dir)
- end
+ FileUtils.rm_rf(downloads_dir) if selenium?
+ end
+
+ config.before(:all, javascript: true, standalone: true) do
+ expire_assets_cache
+ end
+
+ config.after(:all, javascript: true, standalone: true) do
+ expire_assets_cache
+ end
+
+ config.before(javascript: true, standalone: true) do
+ page.driver.restart
+
+ @_rails_env = Rails.env
+ Rails.env = ENV['RAILS_ENV'] = 'standalone'
+ @_home = ENV['HOME']
+ @_tmpdir = ENV['HOME'] = Dir.mktmpdir('smalruby-')
+ end
+
+ config.after(javascript: true, standalone: true) do
+ FileUtils.remove_entry_secure(@_tmpdir)
+ ENV['HOME'] = @_home
+ Rails.env = ENV['RAILS_ENV'] = @_rails_env
+
+ page.driver.restart
+ end
+
+ config.before :suite do
+ DatabaseRewinder.clean_all
+ end
+
+ config.after :each do
+ DatabaseRewinder.clean
end
end
end
Spork.each_run do