Skip to content

Commit 6673cf7

Browse files
committed
Use require_relative instead of require with full path
1 parent 326914d commit 6673cf7

File tree

21 files changed

+26
-26
lines changed

21 files changed

+26
-26
lines changed

actioncable/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ application. The recommended basic setup is as follows:
409409

410410
```ruby
411411
# cable/config.ru
412-
require ::File.expand_path('../config/environment', __dir__)
412+
require_relative '../config/environment'
413413
Rails.application.eager_load!
414414

415415
run ActionCable.server

actioncable/bin/test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env ruby
22

33
COMPONENT_ROOT = File.expand_path("..", __dir__)
4-
require File.expand_path("../tools/test", COMPONENT_ROOT)
4+
require_relative "../../tools/test"

actioncable/test/subscription_adapter/async_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require "test_helper"
2-
require_relative "./common"
2+
require_relative "common"
33

44
class AsyncAdapterTest < ActionCable::TestCase
55
include CommonSubscriptionAdapterTest

actioncable/test/subscription_adapter/evented_redis_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require "test_helper"
2-
require_relative "./common"
3-
require_relative "./channel_prefix"
2+
require_relative "common"
3+
require_relative "channel_prefix"
44

55
class EventedRedisAdapterTest < ActionCable::TestCase
66
include CommonSubscriptionAdapterTest

actioncable/test/subscription_adapter/inline_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require "test_helper"
2-
require_relative "./common"
2+
require_relative "common"
33

44
class InlineAdapterTest < ActionCable::TestCase
55
include CommonSubscriptionAdapterTest

actioncable/test/subscription_adapter/postgresql_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require "test_helper"
2-
require_relative "./common"
2+
require_relative "common"
33

44
require "active_record"
55

actioncable/test/subscription_adapter/redis_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require "test_helper"
2-
require_relative "./common"
3-
require_relative "./channel_prefix"
2+
require_relative "common"
3+
require_relative "channel_prefix"
44

55
class RedisAdapterTest < ActionCable::TestCase
66
include CommonSubscriptionAdapterTest

actionmailer/bin/test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env ruby
22

33
COMPONENT_ROOT = File.expand_path("..", __dir__)
4-
require File.expand_path("../tools/test", COMPONENT_ROOT)
4+
require_relative "../../tools/test"

actionpack/bin/test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env ruby
22

33
COMPONENT_ROOT = File.expand_path("..", __dir__)
4-
require File.expand_path("../tools/test", COMPONENT_ROOT)
4+
require_relative "../../tools/test"

actionview/bin/test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env ruby
22

33
COMPONENT_ROOT = File.expand_path("..", __dir__)
4-
require File.expand_path("../tools/test", COMPONENT_ROOT)
4+
require_relative "../../tools/test"

activejob/bin/test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env ruby
22

33
COMPONENT_ROOT = File.expand_path("..", __dir__)
4-
require File.expand_path("../tools/test", COMPONENT_ROOT)
4+
require_relative "../../tools/test"

activemodel/bin/test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env ruby
22

33
COMPONENT_ROOT = File.expand_path("..", __dir__)
4-
require File.expand_path("../tools/test", COMPONENT_ROOT)
4+
require_relative "../../tools/test"

activerecord/Rakefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require "rake/testtask"
22

3-
require File.expand_path("test/config", __dir__)
4-
require File.expand_path("test/support/config", __dir__)
3+
require_relative "test/config"
4+
require_relative "test/support/config"
55

66
def run_without_aborting(*tasks)
77
errors = []

activerecord/bin/test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env ruby
22

33
COMPONENT_ROOT = File.expand_path("..", __dir__)
4-
require File.expand_path("../tools/test", COMPONENT_ROOT)
4+
require_relative "../../tools/test"
55

66
module Minitest
77
def self.plugin_active_record_options(opts, options)

activerecord/test/cases/errors_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require_relative "../cases/helper"
1+
require "cases/helper"
22

33
class ErrorsTest < ActiveRecord::TestCase
44
def test_can_be_instantiated_with_no_args

activesupport/bin/test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env ruby
22

33
COMPONENT_ROOT = File.expand_path("..", __dir__)
4-
require File.expand_path("../tools/test", COMPONENT_ROOT)
4+
require_relative "../../tools/test"

railties/bin/test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env ruby
22

33
COMPONENT_ROOT = File.expand_path("..", __dir__)
4-
require File.expand_path("../tools/test", COMPONENT_ROOT)
4+
require_relative "../../tools/test"

railties/lib/rails/generators/rails/app/templates/test/test_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require File.expand_path('../config/environment', __dir__)
1+
require_relative '../config/environment'
22
require 'rails/test_help'
33

44
class ActiveSupport::TestCase

railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require File.expand_path("../<%= options[:dummy_path] -%>/config/environment.rb", __dir__)
1+
require_relative "<%= File.join('..', options[:dummy_path], 'config/environment') -%>"
22
<% unless options[:skip_active_record] -%>
33
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../<%= options[:dummy_path] -%>/db/migrate", __dir__)]
44
<% if options[:mountable] -%>

railties/test/generators/plugin_generator_test.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def test_generating_without_options
6363
assert_no_file "config/routes.rb"
6464
assert_no_file "app/assets/config/bukkits_manifest.js"
6565
assert_file "test/test_helper.rb" do |content|
66-
assert_match(/require.+test\/dummy\/config\/environment/, content)
66+
assert_match(/require_relative.+test\/dummy\/config\/environment/, content)
6767
assert_match(/ActiveRecord::Migrator\.migrations_paths.+test\/dummy\/db\/migrate/, content)
6868
assert_match(/Minitest\.backtrace_filter = Minitest::BacktraceFilter\.new/, content)
6969
assert_match(/Rails::TestUnitReporter\.executable = 'bin\/test'/, content)
@@ -438,7 +438,7 @@ def test_passing_dummy_path_as_a_parameter
438438
assert_file "spec/dummy/config/application.rb"
439439
assert_no_file "test/dummy"
440440
assert_file "test/test_helper.rb" do |content|
441-
assert_match(/require.+spec\/dummy\/config\/environment/, content)
441+
assert_match(/require_relative.+spec\/dummy\/config\/environment/, content)
442442
assert_match(/ActiveRecord::Migrator\.migrations_paths.+spec\/dummy\/db\/migrate/, content)
443443
end
444444
end
@@ -449,7 +449,7 @@ def test_creating_dummy_application_with_different_name
449449
assert_file "spec/fake/config/application.rb"
450450
assert_no_file "test/dummy"
451451
assert_file "test/test_helper.rb" do |content|
452-
assert_match(/require.+spec\/fake\/config\/environment/, content)
452+
assert_match(/require_relative.+spec\/fake\/config\/environment/, content)
453453
assert_match(/ActiveRecord::Migrator\.migrations_paths.+spec\/fake\/db\/migrate/, content)
454454
end
455455
end

railties/test/generators_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def test_source_paths_for_not_namespaced_generators
233233
end
234234

235235
def test_usage_with_embedded_ruby
236-
require File.expand_path("fixtures/lib/generators/usage_template/usage_template_generator", __dir__)
236+
require_relative "fixtures/lib/generators/usage_template/usage_template_generator"
237237
output = capture(:stdout) { Rails::Generators.invoke :usage_template, ["--help"] }
238238
assert_match(/:: 2 ::/, output)
239239
end

0 commit comments

Comments
 (0)