Sha256: 38c8ad311f59f9538a71241c006922658ec96153cc193806effd86e998fcdb63

Contents?: true

Size: 631 Bytes

Versions: 1

Compression:

Stored size: 631 Bytes

Contents

# frozen_string_literal: true

require 'rails/generators'

module TestUnit
  module Generators
    class QueryGenerator < Rails::Generators::NamedBase

      source_root File.expand_path('../templates', __FILE__)
      check_class_collision suffix: 'QueryTest'

      def create_test_file
        path = File.join('test', 'queries', class_path, "#{file_name}_query_test.rb")
        template('query_test.rb.tt', path)
      end

      private

      def file_name
        @_file_name ||= remove_possible_suffix(super)
      end

      def remove_possible_suffix(name)
        name.sub(/_?query$/i, '')
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lite-query-1.0.0 lib/generators/test_unit/query_generator.rb