File: test_helper.rb

package info (click to toggle)
ruby-derailed-benchmarks 1.7.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 760 kB
  • sloc: ruby: 1,317; makefile: 4
file content (65 lines) | stat: -rw-r--r-- 1,713 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# frozen_string_literal: true

require 'rubygems'
require 'bundler/setup'

# Configure Rails Envinronment
ENV["RAILS_ENV"] = "test"

require 'rails'
require 'rails/test_help'

require 'stringio'
require 'pathname'

require 'derailed_benchmarks'

require File.expand_path("../rails_app/config/environment.rb",  __FILE__)
require "rails/test_help"

ActionMailer::Base.delivery_method    = :test
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.default_url_options[:host] = "test.com"

Rails.backtrace_cleaner.remove_silencers!

# Configure capybara for integration testing
require "capybara/rails"
Capybara.default_driver   = :rack_test
Capybara.default_selector = :css

require_relative "rails_app/config/environment"

# https://github.com/plataformatec/devise/blob/master/test/orm/active_record.rb
migrate_path = File.expand_path("../rails_app/db/migrate", __FILE__)
if Rails.version.start_with? '6'
  ActiveRecord::MigrationContext.new(migrate_path, ActiveRecord::SchemaMigration).migrate
elsif Rails.version.start_with? '5.2'
  ActiveRecord::MigrationContext.new(migrate_path).migrate
else
  ActiveRecord::Migrator.migrate(migrate_path)
end

ActiveRecord::Migration.maintain_test_schema!

# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }

class ActiveSupport::IntegrationCase
  def assert_has_content?(content)
    assert has_content?(content), "Expected #{page.body} to include #{content.inspect}"
  end
end


def fixtures_dir(name = "")
  root_path("test/fixtures").join(name)
end

def root_path(name = "")
  Pathname.new(File.expand_path("../..", __FILE__)).join(name)
end

def rails_app_path(name = "")
  root_path("test/rails_app").join(name)
end