Skip to content

Commit

Permalink
chore: Fix deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
hasghari committed Aug 14, 2024
1 parent 7ddd609 commit 81eae60
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
5 changes: 5 additions & 0 deletions spec/dummy/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ class Application < Rails::Application
if Rails.version.match?(/(6.1|7.0)/)
config.active_record.legacy_connection_handling = false
end

if Rails.gem_version >= Gem::Version.new("7.1")
config.active_support.cache_format_version = 7.0
end

config.active_support.deprecation = :stderr
config.eager_load = false

Expand Down
14 changes: 5 additions & 9 deletions spec/generators/clearance/install/install_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
require "generators/clearance/install/install_generator"

describe Clearance::Generators::InstallGenerator, :generator do
def get_migration(path)
Pathname.new(migration_file(path))
end

describe "initializer" do
it "is copied to the application" do
provide_existing_application_controller
Expand Down Expand Up @@ -70,7 +66,7 @@ def get_migration(path)
table_does_not_exist(:users)

run_generator
migration = get_migration("db/migrate/create_users.rb")
migration = migration_file("db/migrate/create_users.rb")

expect(migration).to exist
expect(migration).to have_correct_syntax
Expand All @@ -92,7 +88,7 @@ def get_migration(path)
table_does_not_exist(:users)

run_generator
migration = get_migration("db/migrate/create_users.rb")
migration = migration_file("db/migrate/create_users.rb")

expect(migration).to exist
expect(migration).to have_correct_syntax
Expand All @@ -106,8 +102,8 @@ def get_migration(path)
provide_existing_application_controller

run_generator
create_migration = get_migration("db/migrate/create_users.rb")
add_migration = get_migration("db/migrate/add_clearance_to_users.rb")
create_migration = migration_file("db/migrate/create_users.rb")
add_migration = migration_file("db/migrate/add_clearance_to_users.rb")

expect(create_migration).not_to exist
expect(add_migration).not_to exist
Expand All @@ -130,7 +126,7 @@ def get_migration(path)
and_return(existing_indexes)

run_generator
migration = get_migration("db/migrate/add_clearance_to_users.rb")
migration = migration_file("db/migrate/add_clearance_to_users.rb")

expect(migration).to exist
expect(migration).to have_correct_syntax
Expand Down
11 changes: 11 additions & 0 deletions spec/support/generator_spec_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
require "ammeter/init"

module GeneratorSpecHelpers
module FileMethods
def file(path)
Pathname.new(super)
end

def migration_file(path)
Pathname.new(super)
end
end

TEMPLATE_PATH = File.expand_path("../../app_templates", __FILE__)

def provide_existing_routes_file
Expand Down Expand Up @@ -36,6 +46,7 @@ def copy_to_generator_root(destination, template)

RSpec.configure do |config|
config.include GeneratorSpecHelpers
config.prepend GeneratorSpecHelpers::FileMethods

config.before(:example, :generator) do
destination File.expand_path("../../../tmp", __FILE__)
Expand Down

0 comments on commit 81eae60

Please sign in to comment.