<commit_before># This file is part of Mconf-Web, a web application that provides access
# to the Mconf webconferencing system. Copyright (C) 2010-2015 Mconf.
#
# This file is licensed under the Affero General Public License version
# 3 or later. See the LICENSE file.

# This file is copied to spec/ when you run 'rails generate rspec:install'

require 'simplecov'
SimpleCov.start if ENV["COVERAGE"]

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'shoulda-matchers'
require 'cancan/matchers'

# 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}

ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.deliveries = []
ActionMailer::Base.default_url_options = { :host => 'localhost:3001' }

BCrypt::Engine.cost = 4

# To mock event geocode external http requests
Geocoder::Lookup::Test.set_default_stub(
  [
    {
      'latitude'     => 40.7143528,
      'longitude'    => -74.0059731,
      'address'      => 'New York, NY, USA',
      'state'        => 'New York',
      'state_code'   => 'NY',
      'country'      => 'United States',
      'country_code' => 'US'
    }
  ]
)

# Disable all external HTTP requests by default
require 'webmock/rspec'
WebMock.disable_net_connect!(allow_localhost: true)

RSpec.configure do |config|
  # == Mock Framework
  #
  # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
  #
  # config.mock_with :mocha
  # config.mock_with :flexmock
  # config.mock_with :rr
  config.mock_with :rspec

  Zonebie.set_random_timezone

  # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
  # 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.

  # TODO: set to false only to send emails with devise-async and capybara, see http://stackoverflow.com/questions/16732060/devise-async-sidekiq-rspec-integration-spec-fails
  #   use databasecleaner or disable this only in the specific features that need it
  config.use_transactional_fixtures = false

  # Make the rails routes avaiable in all specs
  #config.include Rails.application.routes.url_helpers

  # we don't ever run migration specs, they should be used individually
  config.filter_run_excluding :migration => true
  config.run_all_when_everything_filtered = true

  # To use old default of rspec 2
  config.infer_spec_type_from_file_location!

  config.include Devise::TestHelpers, :type => :controller
  config.include ControllerMacros, :type => :controller
  config.extend Helpers::ClassMethods
  config.include FeatureHelpers, :type => :feature

  config.before(:suite) do
    # setup the current site for the first time and update some things that need configurations
    # from the site table
    Helpers.setup_site
    # this is done in an initializer, so have to do it again to prevent first run errors
    Devise.mailer_sender = Site.current.smtp_sender
  end

  config.before(:each) do |example|
    ResqueSpec.reset!
    ActionMailer::Base.deliveries.clear
    Helpers.setup_site
    Helpers.set_custom_ability_actions([])
    Capybara.current_driver = :webkit if example.metadata[:with_js]
    Geocoder.configure(:lookup => :test)
  end

  # We want features as close to the production environment as possible, so render error
  # pages instead of raising exceptions.
  config.before(:each, type: :feature) do |example|
    Rails.application.config.consider_all_requests_local = false
  end

  config.around(:each) do |example|
    # use :transaction for all, unless explicitly defined that it needs :truncation<commit_msg>Remove http calls in test env<commit_after># This file is part of Mconf-Web, a web application that provides access
# to the Mconf webconferencing system. Copyright (C) 2010-2015 Mconf.
#
# This file is licensed under the Affero General Public License version
# 3 or later. See the LICENSE file.

# This file is copied to spec/ when you run 'rails generate rspec:install'

require 'simplecov'
SimpleCov.start if ENV["COVERAGE"]

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'shoulda-matchers'
require 'cancan/matchers'

# 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}

ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.deliveries = []
ActionMailer::Base.default_url_options = { :host => 'localhost:3001' }

Geocoder.configure(:lookup => :test)

Geocoder::Lookup::Test.set_default_stub(
  [
    {
      'latitude'     => 40.7143528,
      'longitude'    => -74.0059731,
      'address'      => 'New York, NY, USA',
      'state'        => 'New York',
      'state_code'   => 'NY',
      'country'      => 'United States',
      'country_code' => 'US'
    }
  ]
)

BCrypt::Engine.cost = 4

# Disable all external HTTP requests by default
require 'webmock/rspec'
WebMock.disable_net_connect!(allow_localhost: true)

RSpec.configure do |config|
  # == Mock Framework
  #
  # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
  #
  # config.mock_with :mocha
  # config.mock_with :flexmock
  # config.mock_with :rr
  config.mock_with :rspec

  Zonebie.set_random_timezone

  # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
  # 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.

  # TODO: set to false only to send emails with devise-async and capybara, see http://stackoverflow.com/questions/16732060/devise-async-sidekiq-rspec-integration-spec-fails
  #   use databasecleaner or disable this only in the specific features that need it
  config.use_transactional_fixtures = false

  # Make the rails routes avaiable in all specs
  #config.include Rails.application.routes.url_helpers

  # we don't ever run migration specs, they should be used individually
  config.filter_run_excluding :migration => true
  config.run_all_when_everything_filtered = true

  # To use old default of rspec 2
  config.infer_spec_type_from_file_location!

  config.include Devise::TestHelpers, :type => :controller
  config.include ControllerMacros, :type => :controller
  config.extend Helpers::ClassMethods
  config.include FeatureHelpers, :type => :feature

  config.before(:suite) do
    # setup the current site for the first time and update some things that need configurations
    # from the site table
    Helpers.setup_site
    # this is done in an initializer, so have to do it again to prevent first run errors
    Devise.mailer_sender = Site.current.smtp_sender
  end

  config.before(:each) do |example|
    ResqueSpec.reset!
    ActionMailer::Base.deliveries.clear
    Helpers.setup_site
    Helpers.set_custom_ability_actions([])
    Capybara.current_driver = :webkit if example.metadata[:with_js]
  end

  # We want features as close to the production environment as possible, so render error
  # pages instead of raising exceptions.
  config.before(:each, type: :feature) do |example|
    Rails.application.config.consider_all_requests_local = false
  end

  config.around(:each) do |example|
    # use :transaction for all, unless explicitly defined that it needs :truncation
{'fraction_non_alphanumeric': 0.0945945945945946, 'fraction_numerical': 0.010553410553410553, 'mean_word_length': 4.0824068018312625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1314018', 'n_tokens_mistral': 2457, 'n_tokens_neox': 2336, 'n_words': 751}