Sha256: c91a307f998cea453b86c70c4a987d0528a97e68ca8ec078e7c924aaffb6c780

Contents?: true

Size: 620 Bytes

Versions: 1

Compression:

Stored size: 620 Bytes

Contents

# frozen_string_literal: true

require 'rails/generators'

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

      source_root File.expand_path('../templates', __FILE__)

      def create_test_file
        path = File.join('spec', 'queries', class_path, "#{file_name}_query_spec.rb")
        empty_directory('spec/queries')
        template('query_spec.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.1 lib/generators/rspec/query_generator.rb