spec/rails_helper.rb in releaf-1.1.22 vs spec/rails_helper.rb in releaf-2.0.0
- old
+ new
@@ -1,10 +1,9 @@
require 'simplecov'
require 'simplecov-rcov'
require 'coveralls'
require 'pry'
-require 'pry-nav'
SimpleCov.command_name 'rspec'
Coveralls.wear!('rails')
if ENV["COVERAGE"]
@@ -21,59 +20,63 @@
ENV["RAILS_ENV"] ||= 'test'
require 'spec_helper'
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require 'rspec/rails'
-require 'factory_girl'
+require 'rails-controller-testing'
+require 'factory_bot'
require "shoulda-matchers"
require 'db-query-matchers'
-require 'capybara/poltergeist'
+require 'selenium/webdriver'
require 'with_model'
require 'timecop'
require 'with_model'
require 'database_cleaner'
require 'releaf/rspec'
-require 'sass' # To stop these warnings: WARN: tilt autoloading 'sass' in a non thread-safe way; explicit require 'sass' suggested.
Rails.backtrace_cleaner.remove_silencers!
# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
# for devise testing
include Warden::Test::Helpers
+Capybara.register_driver(:chrome) do |app|
+ options = ::Selenium::WebDriver::Chrome::Options.new
+ options.add_argument('--headless')
+ options.add_argument('--window-size=1400,900')
-Capybara.register_driver :poltergeist do |app|
- Capybara::Poltergeist::Driver.new(app, js_errors: true, inspector: true, phantomjs_logger: WarningSuppressor)
+ if ENV['CI']
+ options.add_argument('--no-sandbox')
+ options.add_argument('--disable-dev-shm-usage')
+ end
+
+ Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
end
-class WarningSuppressor
- IGNOREABLE = /CoreText performance|userSpaceScaleFactor/
+Capybara.javascript_driver = :chrome
- def write(message)
- if message =~ IGNOREABLE
- 0
- else
- puts(message)
- 1
- end
- end
-end
+Capybara.default_set_options = { clear: :backspace } # needed for 'fill_in "Foo", with: ""' to work
RSpec.configure do |config|
config.use_transactional_fixtures = false
config.infer_base_class_for_anonymous_controllers = false
config.order = "random"
config.infer_spec_type_from_file_location!
+ config.include Shoulda::Matchers::ActiveModel, type: :model
+ config.include Shoulda::Matchers::ActiveRecord, type: :model
+ config.include Shoulda::Matchers::Independent
+
config.color = true
if ENV['COVERAGE']
config.add_formatter(:progress)
end
config.include Releaf::Test::Helpers
+ config.include CapybaraActions, type: :feature
config.include WaitSteps
config.include ExcelHelpers
config.extend WithModel
config.include Rails.application.routes.url_helpers
@@ -83,14 +86,19 @@
config.extend ControllerMacros, type: :controller
config.include Devise::Test::ControllerHelpers, type: :helper
config.extend ControllerMacros, type: :helper
- # FactoryGirl
- config.include FactoryGirl::Syntax::Methods
+ [:controller, :view, :request].each do |type|
+ config.include ::Rails::Controller::Testing::TestProcess, type: type
+ config.include ::Rails::Controller::Testing::TemplateAssertions, type: type
+ config.include ::Rails::Controller::Testing::Integration, type: type
+ end
- Capybara.javascript_driver = :poltergeist
- Capybara.server = :webrick
+
+ config.include FactoryBot::Syntax::Methods
+
+ Capybara.default_normalize_ws = true
# disable empty translation creation
config.before(:each) do |example|
Rails.cache.clear