Skip to content

Commit

Permalink
Use require_relative instead of require with full path
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanvlviv committed Jun 14, 2017
1 parent 326914d commit 6673cf7
Show file tree
Hide file tree
Showing 21 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion actioncable/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ application. The recommended basic setup is as follows:

```ruby
# cable/config.ru
require ::File.expand_path('../config/environment', __dir__)
require_relative '../config/environment'
Rails.application.eager_load!

run ActionCable.server
Expand Down
2 changes: 1 addition & 1 deletion actioncable/bin/test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby

COMPONENT_ROOT = File.expand_path("..", __dir__)
require File.expand_path("../tools/test", COMPONENT_ROOT)
require_relative "../../tools/test"
2 changes: 1 addition & 1 deletion actioncable/test/subscription_adapter/async_test.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "test_helper"
require_relative "./common"
require_relative "common"

class AsyncAdapterTest < ActionCable::TestCase
include CommonSubscriptionAdapterTest
Expand Down
4 changes: 2 additions & 2 deletions actioncable/test/subscription_adapter/evented_redis_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "test_helper"
require_relative "./common"
require_relative "./channel_prefix"
require_relative "common"
require_relative "channel_prefix"

class EventedRedisAdapterTest < ActionCable::TestCase
include CommonSubscriptionAdapterTest
Expand Down
2 changes: 1 addition & 1 deletion actioncable/test/subscription_adapter/inline_test.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "test_helper"
require_relative "./common"
require_relative "common"

class InlineAdapterTest < ActionCable::TestCase
include CommonSubscriptionAdapterTest
Expand Down
2 changes: 1 addition & 1 deletion actioncable/test/subscription_adapter/postgresql_test.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "test_helper"
require_relative "./common"
require_relative "common"

require "active_record"

Expand Down
4 changes: 2 additions & 2 deletions actioncable/test/subscription_adapter/redis_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "test_helper"
require_relative "./common"
require_relative "./channel_prefix"
require_relative "common"
require_relative "channel_prefix"

class RedisAdapterTest < ActionCable::TestCase
include CommonSubscriptionAdapterTest
Expand Down
2 changes: 1 addition & 1 deletion actionmailer/bin/test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby

COMPONENT_ROOT = File.expand_path("..", __dir__)
require File.expand_path("../tools/test", COMPONENT_ROOT)
require_relative "../../tools/test"
2 changes: 1 addition & 1 deletion actionpack/bin/test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby

COMPONENT_ROOT = File.expand_path("..", __dir__)
require File.expand_path("../tools/test", COMPONENT_ROOT)
require_relative "../../tools/test"
2 changes: 1 addition & 1 deletion actionview/bin/test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby

COMPONENT_ROOT = File.expand_path("..", __dir__)
require File.expand_path("../tools/test", COMPONENT_ROOT)
require_relative "../../tools/test"
2 changes: 1 addition & 1 deletion activejob/bin/test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby

COMPONENT_ROOT = File.expand_path("..", __dir__)
require File.expand_path("../tools/test", COMPONENT_ROOT)
require_relative "../../tools/test"
2 changes: 1 addition & 1 deletion activemodel/bin/test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby

COMPONENT_ROOT = File.expand_path("..", __dir__)
require File.expand_path("../tools/test", COMPONENT_ROOT)
require_relative "../../tools/test"
4 changes: 2 additions & 2 deletions activerecord/Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "rake/testtask"

require File.expand_path("test/config", __dir__)
require File.expand_path("test/support/config", __dir__)
require_relative "test/config"
require_relative "test/support/config"

def run_without_aborting(*tasks)
errors = []
Expand Down
2 changes: 1 addition & 1 deletion activerecord/bin/test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby

COMPONENT_ROOT = File.expand_path("..", __dir__)
require File.expand_path("../tools/test", COMPONENT_ROOT)
require_relative "../../tools/test"

module Minitest
def self.plugin_active_record_options(opts, options)
Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/cases/errors_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require_relative "../cases/helper"
require "cases/helper"

class ErrorsTest < ActiveRecord::TestCase
def test_can_be_instantiated_with_no_args
Expand Down
2 changes: 1 addition & 1 deletion activesupport/bin/test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby

COMPONENT_ROOT = File.expand_path("..", __dir__)
require File.expand_path("../tools/test", COMPONENT_ROOT)
require_relative "../../tools/test"
2 changes: 1 addition & 1 deletion railties/bin/test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby

COMPONENT_ROOT = File.expand_path("..", __dir__)
require File.expand_path("../tools/test", COMPONENT_ROOT)
require_relative "../../tools/test"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.expand_path('../config/environment', __dir__)
require_relative '../config/environment'
require 'rails/test_help'

class ActiveSupport::TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.expand_path("../<%= options[:dummy_path] -%>/config/environment.rb", __dir__)
require_relative "<%= File.join('..', options[:dummy_path], 'config/environment') -%>"
<% unless options[:skip_active_record] -%>
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../<%= options[:dummy_path] -%>/db/migrate", __dir__)]
<% if options[:mountable] -%>
Expand Down
6 changes: 3 additions & 3 deletions railties/test/generators/plugin_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_generating_without_options
assert_no_file "config/routes.rb"
assert_no_file "app/assets/config/bukkits_manifest.js"
assert_file "test/test_helper.rb" do |content|
assert_match(/require.+test\/dummy\/config\/environment/, content)
assert_match(/require_relative.+test\/dummy\/config\/environment/, content)
assert_match(/ActiveRecord::Migrator\.migrations_paths.+test\/dummy\/db\/migrate/, content)
assert_match(/Minitest\.backtrace_filter = Minitest::BacktraceFilter\.new/, content)
assert_match(/Rails::TestUnitReporter\.executable = 'bin\/test'/, content)
Expand Down Expand Up @@ -438,7 +438,7 @@ def test_passing_dummy_path_as_a_parameter
assert_file "spec/dummy/config/application.rb"
assert_no_file "test/dummy"
assert_file "test/test_helper.rb" do |content|
assert_match(/require.+spec\/dummy\/config\/environment/, content)
assert_match(/require_relative.+spec\/dummy\/config\/environment/, content)
assert_match(/ActiveRecord::Migrator\.migrations_paths.+spec\/dummy\/db\/migrate/, content)
end
end
Expand All @@ -449,7 +449,7 @@ def test_creating_dummy_application_with_different_name
assert_file "spec/fake/config/application.rb"
assert_no_file "test/dummy"
assert_file "test/test_helper.rb" do |content|
assert_match(/require.+spec\/fake\/config\/environment/, content)
assert_match(/require_relative.+spec\/fake\/config\/environment/, content)
assert_match(/ActiveRecord::Migrator\.migrations_paths.+spec\/fake\/db\/migrate/, content)
end
end
Expand Down
2 changes: 1 addition & 1 deletion railties/test/generators_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def test_source_paths_for_not_namespaced_generators
end

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

0 comments on commit 6673cf7

Please sign in to comment.