Sha256: 60f227d2a5f64080bc6181926d507bf4293528f4a9ed7db8174e1cd6b0c6e981

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

require "hanami/cli"
require "zeitwerk"

# @see Hanami::RSpec
# @since 2.0.0
module Hanami
  # RSpec and testing support for Hanami applications.
  #
  # @since 2.0.0
  # @api private
  module RSpec
    # @since 2.0.0
    # @api private
    def self.gem_loader
      @gem_loader ||= Zeitwerk::Loader.new.tap do |loader|
        root = File.expand_path("..", __dir__)
        loader.tag = "hanami-rspec"
        loader.inflector = Zeitwerk::GemInflector.new("#{root}/hanami-rspec.rb")
        loader.push_dir(root)
        loader.ignore(
          "#{root}/hanami-rspec.rb",
          "#{root}/hanami/rspec/{rake_tasks,version}.rb"
        )
        loader.inflector.inflect("rspec" => "RSpec")
      end
    end

    gem_loader.setup
    require_relative "rspec/version"
    require_relative "rspec/rake_tasks"

    if Hanami::CLI.within_hanami_app?
      Hanami::CLI.before "install", Commands::Install
      Hanami::CLI.after "generate slice", Commands::Generate::Slice

      if Hanami.bundled?("hanami-controller")
        Hanami::CLI.after "generate action", Commands::Generate::Action
      end

      if Hanami.bundled?("hanami-view")
        Hanami::CLI.after "generate part", Commands::Generate::Part
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hanami-rspec-2.2.1 lib/hanami/rspec.rb