Sha256: 2d82c74bc090bebb5da611869f0083930bb61964b399e7762ed77aae55e28cbd

Contents?: true

Size: 776 Bytes

Versions: 20

Compression:

Stored size: 776 Bytes

Contents

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

module Rspec
  module Generators
    class AbilityGenerator < Base
      @_rspec_source_root = File.expand_path('../templates', __FILE__)
      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(&block)
        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

20 entries across 20 versions & 1 rubygems

Version Path
canard-0.5.0.pre lib/generators/rspec/ability/ability_generator.rb
canard-0.4.3 lib/generators/rspec/ability/ability_generator.rb
canard-0.4.2.pre lib/generators/rspec/ability/ability_generator.rb
canard-0.4.1 lib/generators/rspec/ability/ability_generator.rb
canard-0.4.0 lib/generators/rspec/ability/ability_generator.rb
canard-0.4.0.pre lib/generators/rspec/ability/ability_generator.rb
canard-0.3.7 lib/generators/rspec/ability/ability_generator.rb
canard-0.3.6 lib/generators/rspec/ability/ability_generator.rb
canard-0.3.5 lib/generators/rspec/ability/ability_generator.rb
canard-0.3.4 lib/generators/rspec/ability/ability_generator.rb
canard-0.3.2 lib/generators/rspec/ability/ability_generator.rb
canard-0.3.1 lib/generators/rspec/ability/ability_generator.rb
canard-0.2.7 lib/generators/rspec/ability/ability_generator.rb
canard-0.2.5 lib/generators/rspec/ability/ability_generator.rb
canard-0.2.4 lib/generators/rspec/ability/ability_generator.rb
canard-0.2.3 lib/generators/rspec/ability/ability_generator.rb
canard-0.2.2 lib/generators/rspec/ability/ability_generator.rb
canard-0.2.1 lib/generators/rspec/ability/ability_generator.rb
canard-0.2.0 lib/generators/rspec/ability/ability_generator.rb
canard-0.1.2 lib/generators/rspec/ability/ability_generator.rb