Sha256: de6a4718ebccd9dbb4a70889eb63c1b44947a3345d53f519b335db5d2274919e

Contents?: true

Size: 754 Bytes

Versions: 3

Compression:

Stored size: 754 Bytes

Contents

# frozen_string_literal: true

require 'generators/rspec'
require_relative '../../ability_definition'

module Rspec
  module Generators
    class AbilityGenerator < Base
      @_rspec_source_root = File.expand_path('templates', __dir__)
      argument :ability_definitions, type: :array, default: [], banner: 'can:abilities:models cannot:abilities:models'

      def generate_ability_spec
        template 'abilities_spec.rb.erb', "spec/abilities/#{file_name.pluralize}_spec.rb"
      end

      private

      def definitions
        ability_definitions.each { |definition| AbilityDefinition.parse(definition) }

        AbilityDefinition.models.sort.each do |model, definition|
          yield model, definition
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
canard-0.6.2.pre lib/generators/rspec/ability/ability_generator.rb
canard-0.6.1.pre lib/generators/rspec/ability/ability_generator.rb
canard-0.6.0.pre lib/generators/rspec/ability/ability_generator.rb