Sha256: 05324659a138bead61c8e2e1962dcf05d17d7d25aead26baec4e79b7e89fd0e2

Contents?: true

Size: 1.82 KB

Versions: 16

Compression:

Stored size: 1.82 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 'admin_flag' strategy without default roles" do
      create_model :user do
        '# content'
      end
      with_generator do |g|   
        arguments = "User --strategy admin_flag --roles special --no-default-roles"
        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 => ':special'
          clazz.should have_call :strategy, :args => ":admin_flag"
        end
      end
    end
        
    it "should configure 'admin_flag' strategy" do
      create_model :user do
        '# content'
      end
      with_generator do |g|   
        arguments = "User --strategy admin_flag --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 => ":admin_flag"        
        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/admin_flag_gen_spec.rb
roles_active_record-0.5.0 spec/roles_active_record/generators/admin_flag_gen_spec.rb
roles_active_record-0.4.9 spec/roles_active_record/generators/admin_flag_gen_spec.rb
roles_active_record-0.4.8 spec/roles_active_record/generators/admin_flag_gen_spec.rb
roles_active_record-0.4.7 spec/roles_active_record/generators/admin_flag_gen_spec.rb
roles_active_record-0.4.6.4 spec/roles_active_record/generators/admin_flag_gen_spec.rb
roles_active_record-0.4.6.3 spec/roles_active_record/generators/admin_flag_gen_spec.rb
roles_active_record-0.4.6.2 spec/roles_active_record/generators/admin_flag_gen_spec.rb
roles_active_record-0.4.6.1 spec/roles_active_record/generators/admin_flag_gen_spec.rb
roles_active_record-0.4.6 spec/roles_active_record/generators/admin_flag_gen_spec.rb
roles_active_record-0.4.5 spec/roles_active_record/generators/admin_flag_gen_spec.rb
roles_active_record-0.4.4 spec/roles_active_record/generators/admin_flag_gen_spec.rb
roles_active_record-0.4.3 spec/roles_active_record/generators/admin_flag_gen_spec.rb
roles_active_record-0.4.2 spec/roles_active_record/generators/admin_flag_gen_spec.rb
roles_active_record-0.4.1 spec/roles_active_record/generators/admin_flag_gen_spec.rb
roles_active_record-0.4.0 spec/roles_active_record/generators/admin_flag_gen_spec.rb