Sha256: d2a2c7d4f0fc684f571e3352ff1f30cdc354db20c23e87b1524cfb99ab86f016

Contents?: true

Size: 580 Bytes

Versions: 1

Compression:

Stored size: 580 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")
        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.0 lib/generators/rspec/query_generator.rb