Sha256: 15d95af900f2528abe281209fb1c70546e0cf08862f39c3caec2cca0588bf1a0

Contents?: true

Size: 1.74 KB

Versions: 16

Compression:

Stored size: 1.74 KB

Contents

require 'generator_spec_helper'

# require_generator :active_record => :roles
require 'generators/active_record/roles/roles_generator'

# root_dir = Rails3::Assist::Directory.rails_root
# root_dir = File.join(Rails.application.config.root_dir, 'rails')
root_dir = Rails.root

describe 'roles generator' do
  describe 'ORM: active_record' do  
    use_orm :active_record

    before do              
      setup_generator 'AR_generator' do
        tests ActiveRecord::Generators::RolesGenerator
      end    
    end
    
    before :each do              
      remove_model :user    
    end

    after :each do
      remove_model :user
    end
    
    it "should configure 'many_roles' strategy" do
      create_model :user do
        '# content'
      end
      with_generator do |g|   
        arguments = "User --strategy many_roles --roles admin user"
        puts "arguments: #{arguments}"
        g.run_generator arguments.args
        root_dir.should have_model :user do |clazz|
          clazz.should include_module 'Roles::ActiveRecord'
          clazz.should have_call :valid_roles_are, :args => ':admin, :guest, :user'
          clazz.should have_call :strategy, :args => ":many_roles"
        end
        
        root_dir.should have_model :role do |clazz|                  
          clazz.should have_call :validates, :args => ':name, :uniqueness => true'
          clazz.should have_call :has_many, :args => ':users, :through => :user_roles'
          clazz.should have_call :has_many, :args => ':user_roles'
        end

        root_dir.should have_model :user_role do |clazz|                  
          clazz.should have_call :belongs_to, :args => ':user'
          clazz.should have_call :belongs_to, :args => ':role'
        end
      end
    end    
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
roles_active_record-0.5.1 spec/roles_active_record/generators/many_roles_gen_spec.rb
roles_active_record-0.5.0 spec/roles_active_record/generators/many_roles_gen_spec.rb
roles_active_record-0.4.9 spec/roles_active_record/generators/many_roles_gen_spec.rb
roles_active_record-0.4.8 spec/roles_active_record/generators/many_roles_gen_spec.rb
roles_active_record-0.4.7 spec/roles_active_record/generators/many_roles_gen_spec.rb
roles_active_record-0.4.6.4 spec/roles_active_record/generators/many_roles_gen_spec.rb
roles_active_record-0.4.6.3 spec/roles_active_record/generators/many_roles_gen_spec.rb
roles_active_record-0.4.6.2 spec/roles_active_record/generators/many_roles_gen_spec.rb
roles_active_record-0.4.6.1 spec/roles_active_record/generators/many_roles_gen_spec.rb
roles_active_record-0.4.6 spec/roles_active_record/generators/many_roles_gen_spec.rb
roles_active_record-0.4.5 spec/roles_active_record/generators/many_roles_gen_spec.rb
roles_active_record-0.4.4 spec/roles_active_record/generators/many_roles_gen_spec.rb
roles_active_record-0.4.3 spec/roles_active_record/generators/many_roles_gen_spec.rb
roles_active_record-0.4.2 spec/roles_active_record/generators/many_roles_gen_spec.rb
roles_active_record-0.4.1 spec/roles_active_record/generators/many_roles_gen_spec.rb
roles_active_record-0.4.0 spec/roles_active_record/generators/many_roles_gen_spec.rb