<commit_before>ENV['RAILS_ENV'] ||= 'test'
require 'spec_helper'
require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails'
require 'capybara/rspec'

ActiveRecord::Migration.maintain_test_schema!

module ControllerMatchers
  extend RSpec::Matchers::DSL

  matcher :have_assigned do |sym, expected|
    include RSpec::Matchers::Composable
    match do |actual|
      actual.call if actual.is_a?(Proc)
      values_match?(expected, assigns[sym])
    end
    description { "set @#{sym} to #{description_of(expected)}" }
  end
end

module AliasedMatchers
  def a_new(*args)
    be_a_new(*args)
  end
end

module NoTransactionalFixtures
  def self.included(base)
    base.class_eval { self.use_transactional_fixtures = false }
  end
end

RSpec.configure do |config|
  config.use_transactional_fixtures = true
  config.include ControllerMatchers, type: :controller
  config.include AliasedMatchers
  config.include NoTransactionalFixtures, type: :feature
  config.include DeleteButton, type: :feature, js: true

  config.around(:example, :debug) do |example|
    old = ActiveRecord::Base.logger
    begin
      ActiveRecord::Base.logger = Logger.new($stderr)
      example.run
    ensure
      ActiveRecord::Base.logger = old
    end
  end

  Capybara.javascript_driver = :webkit

  config.before(:suite) { DatabaseCleaner.strategy = :truncation }
  config.before(:each, type: :feature) { DatabaseCleaner.start }
  config.after(:each, type: :feature) { DatabaseCleaner.clean }
end
<commit_msg>Silence Capybara warnings about unknown URL access<commit_after>ENV['RAILS_ENV'] ||= 'test'
require 'spec_helper'
require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails'
require 'capybara/rspec'

ActiveRecord::Migration.maintain_test_schema!

module ControllerMatchers
  extend RSpec::Matchers::DSL

  matcher :have_assigned do |sym, expected|
    include RSpec::Matchers::Composable
    match do |actual|
      actual.call if actual.is_a?(Proc)
      values_match?(expected, assigns[sym])
    end
    description { "set @#{sym} to #{description_of(expected)}" }
  end
end

module AliasedMatchers
  def a_new(*args)
    be_a_new(*args)
  end
end

module NoTransactionalFixtures
  def self.included(base)
    base.class_eval { self.use_transactional_fixtures = false }
  end
end

RSpec.configure do |config|
  config.before(:each, type: :feature, js: true) do
    page.driver.block_unknown_urls
  end

  config.use_transactional_fixtures = true
  config.include ControllerMatchers, type: :controller
  config.include AliasedMatchers
  config.include NoTransactionalFixtures, type: :feature
  config.include DeleteButton, type: :feature, js: true

  config.around(:example, :debug) do |example|
    old = ActiveRecord::Base.logger
    begin
      ActiveRecord::Base.logger = Logger.new($stderr)
      example.run
    ensure
      ActiveRecord::Base.logger = old
    end
  end

  Capybara.javascript_driver = :webkit

  config.before(:suite) { DatabaseCleaner.strategy = :truncation }
  config.before(:each, type: :feature) { DatabaseCleaner.start }
  config.after(:each, type: :feature) { DatabaseCleaner.clean }
end

{'fraction_non_alphanumeric': 0.10864745011086474, 'fraction_numerical': 0.0, 'mean_word_length': 4.511343804537522, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1960965', 'n_tokens_mistral': 1007, 'n_tokens_neox': 992, 'n_words': 224}