2015-08-10 11:05:06 +02:00
|
|
|
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
|
|
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
|
|
|
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
|
|
|
# this file to always be loaded, without a need to explicitly require it in any
|
|
|
|
# files.
|
|
|
|
#
|
|
|
|
# Given that it is always loaded, you are encouraged to keep this file as
|
|
|
|
# light-weight as possible. Requiring heavyweight dependencies from this file
|
|
|
|
# will add to the boot time of your test suite on EVERY test run, even for an
|
|
|
|
# individual file that may not need all of that loaded. Instead, consider making
|
|
|
|
# a separate helper file that requires the additional dependencies and performs
|
|
|
|
# the additional setup, and require it from the spec files that actually need
|
|
|
|
# it.
|
|
|
|
#
|
|
|
|
# The `.rspec` file also contains a few flags that are not defaults but that
|
|
|
|
# users commonly want.
|
|
|
|
#
|
|
|
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
|
|
|
|
2015-08-20 17:30:17 +02:00
|
|
|
ENV['RAILS_ENV'] ||= 'test'
|
2015-08-10 11:05:06 +02:00
|
|
|
|
2018-03-02 16:27:03 +01:00
|
|
|
require File.expand_path('../config/environment', __dir__)
|
2015-08-10 11:05:06 +02:00
|
|
|
require 'rspec/rails'
|
|
|
|
require 'capybara/rspec'
|
|
|
|
require 'database_cleaner'
|
|
|
|
require 'webmock/rspec'
|
|
|
|
require 'shoulda-matchers'
|
|
|
|
require 'devise'
|
2018-01-23 17:15:42 +01:00
|
|
|
require 'factory_bot'
|
2015-08-10 11:05:06 +02:00
|
|
|
|
2018-01-04 10:46:33 +01:00
|
|
|
require 'selenium/webdriver'
|
|
|
|
Capybara.javascript_driver = :headless_chrome
|
2016-12-14 17:13:40 +01:00
|
|
|
Capybara.ignore_hidden_elements = false
|
2018-01-04 10:46:33 +01:00
|
|
|
|
|
|
|
Capybara.register_driver :chrome do |app|
|
|
|
|
Capybara::Selenium::Driver.new(app, browser: :chrome)
|
|
|
|
end
|
|
|
|
|
|
|
|
Capybara.register_driver :headless_chrome do |app|
|
|
|
|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
|
|
|
|
chromeOptions: { args: %w(headless disable-gpu window-size=2560,1600) }
|
|
|
|
)
|
|
|
|
|
|
|
|
Capybara::Selenium::Driver.new app,
|
|
|
|
browser: :chrome,
|
|
|
|
desired_capabilities: capabilities
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
|
|
|
|
2016-12-27 15:50:45 +01:00
|
|
|
ActiveSupport::Deprecation.silenced = true
|
2016-01-27 15:48:27 +01:00
|
|
|
|
2016-11-14 17:50:06 +01:00
|
|
|
Capybara.default_max_wait_time = 1
|
2015-08-10 11:05:06 +02:00
|
|
|
|
|
|
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
|
|
|
# in spec/support/ and its subdirectories.
|
2018-03-06 13:44:29 +01:00
|
|
|
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
|
|
|
|
Dir[Rails.root.join('spec', 'factories', '**', '*.rb')].each { |f| require f }
|
2015-08-10 11:05:06 +02:00
|
|
|
|
|
|
|
# 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)
|
|
|
|
|
2016-05-13 16:08:51 +02:00
|
|
|
VCR.configure do |c|
|
|
|
|
c.ignore_localhost = true
|
|
|
|
c.hook_into :webmock
|
|
|
|
c.cassette_library_dir = 'spec/fixtures/cassettes'
|
|
|
|
c.configure_rspec_metadata!
|
2018-04-26 14:36:27 +02:00
|
|
|
c.ignore_hosts 'test.host'
|
2016-05-13 16:08:51 +02:00
|
|
|
end
|
|
|
|
|
2017-04-04 11:43:49 +02:00
|
|
|
DatabaseCleaner.strategy = :transaction
|
2015-08-10 11:05:06 +02:00
|
|
|
|
2018-01-11 19:04:39 +01:00
|
|
|
SIADETOKEN = :valid_token if !defined? SIADETOKEN
|
2015-08-11 16:18:40 +02:00
|
|
|
|
2015-08-10 11:05:06 +02:00
|
|
|
include Warden::Test::Helpers
|
|
|
|
|
2016-01-11 14:10:41 +01:00
|
|
|
include SmartListing::Helper
|
|
|
|
include SmartListing::Helper::ControllerExtensions
|
|
|
|
|
|
|
|
module SmartListing
|
|
|
|
module Helper
|
|
|
|
def view_context
|
|
|
|
'mock'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-08-24 11:42:06 +02:00
|
|
|
WebMock.disable_net_connect!(allow_localhost: true)
|
|
|
|
|
2015-08-10 11:05:06 +02:00
|
|
|
RSpec.configure do |config|
|
|
|
|
config.filter_run_excluding disable: true
|
|
|
|
config.color = true
|
|
|
|
config.infer_spec_type_from_file_location!
|
|
|
|
config.tty = true
|
|
|
|
|
2016-11-14 18:36:09 +01:00
|
|
|
config.include Shoulda::Matchers::ActiveRecord, type: :model
|
|
|
|
config.include Shoulda::Matchers::ActiveModel, type: :model
|
|
|
|
config.include Shoulda::Matchers::Independent, type: :model
|
2016-02-04 14:08:35 +01:00
|
|
|
|
2015-08-10 11:05:06 +02:00
|
|
|
config.use_transactional_fixtures = false
|
|
|
|
|
|
|
|
config.infer_base_class_for_anonymous_controllers = false
|
|
|
|
|
2017-10-06 10:17:07 +02:00
|
|
|
config.run_all_when_everything_filtered = true
|
2016-02-22 19:42:47 +01:00
|
|
|
config.filter_run :show_in_doc => true if ENV['APIPIE_RECORD']
|
2017-10-05 14:47:15 +02:00
|
|
|
config.filter_run :focus => true
|
2016-02-22 19:42:47 +01:00
|
|
|
|
2015-08-20 17:30:17 +02:00
|
|
|
config.order = 'random'
|
2015-08-10 11:05:06 +02:00
|
|
|
|
2016-11-14 18:36:09 +01:00
|
|
|
config.include Devise::Test::ControllerHelpers, type: :controller
|
|
|
|
config.include Devise::Test::ControllerHelpers, type: :view
|
2015-08-10 11:05:06 +02:00
|
|
|
|
2018-01-23 17:15:42 +01:00
|
|
|
config.include FactoryBot::Syntax::Methods
|
2016-05-13 16:08:51 +02:00
|
|
|
|
|
|
|
config.before(:each) do
|
|
|
|
allow_any_instance_of(PieceJustificativeUploader).to receive(:generate_secure_token).and_return("3dbb3535-5388-4a37-bc2d-778327b9f997")
|
|
|
|
allow_any_instance_of(ProcedureLogoUploader).to receive(:generate_secure_token).and_return("3dbb3535-5388-4a37-bc2d-778327b9f998")
|
|
|
|
allow_any_instance_of(CerfaUploader).to receive(:generate_secure_token).and_return("3dbb3535-5388-4a37-bc2d-778327b9f999")
|
|
|
|
end
|
|
|
|
|
|
|
|
config.before(:all) {
|
|
|
|
Warden.test_mode!
|
|
|
|
|
2018-04-26 14:36:27 +02:00
|
|
|
Typhoeus::Expectation.clear
|
|
|
|
|
2018-04-18 12:24:37 +02:00
|
|
|
if Flipflop.remote_storage?
|
2016-05-24 17:24:47 +02:00
|
|
|
VCR.use_cassette("ovh_storage_init") do
|
|
|
|
CarrierWave.configure do |config|
|
2018-01-16 13:34:24 +01:00
|
|
|
config.fog_credentials = { provider: 'OpenStack' }
|
2016-05-24 17:24:47 +02:00
|
|
|
end
|
2016-05-13 16:08:51 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
}
|
2016-06-15 11:34:05 +02:00
|
|
|
|
|
|
|
RSpec::Matchers.define :have_same_attributes_as do |expected|
|
|
|
|
match do |actual|
|
|
|
|
ignored = [:id, :procedure_id, :updated_at, :created_at]
|
|
|
|
actual.attributes.with_indifferent_access.except(*ignored) == expected.attributes.with_indifferent_access.except(*ignored)
|
|
|
|
end
|
|
|
|
end
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|