Sha256: 4660788de569ab3142a80d0f91015be7f69f01dfe43e57cdc5ac7aaf2f7fb5e2

Contents?: true

Size: 1.99 KB

Versions: 2

Compression:

Stored size: 1.99 KB

Contents

require 'generator_spec_helper'

# require_generator :data_mapper => :roles
require 'generators/data_mapper/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 'role strategy generator: admin_flag' do
  describe 'ORM: data_mapper' do  
    use_orm :data_mapper
    
    before :each do              
      setup_generator 'datamapper_roles_generator' do
        tests DataMapper::Generators::RolesGenerator
      end    
      remove_model :user    
    end

    after :each do
      remove_model :user
    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
        g.should generate_model :user do |clazz|
          clazz.should include_module 'DataMapper::Resource'
          clazz.should include_module 'Roles::DataMapper'
          clazz.should have_call :valid_roles_are, :args => ':admin, :guest, :user'
          clazz.should have_call :strategy, :args => ":admin_flag"        
        end
      end
    end
    
    it "should configure 'one_role' strategy" do            
      create_model :user do
        '# content'
      end
      with_generator do |g|   
        arguments = "User --strategy one_role --roles admin user"
        puts "arguments: #{arguments}"
        g.run_generator arguments.args
        g.should generate_model :user do |clazz|
          clazz.should include_module 'DataMapper::Resource'
          clazz.should include_module 'Roles::DataMapper'
          clazz.should have_call :valid_roles_are, :args => ':admin, :guest, :user'
          # clazz.should have_call :role_class, :args => ":role"        
          clazz.should have_call :strategy, :args => ":one_role"        
        end
      end
    end    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
roles_data_mapper-0.3.1 spec/roles_data_mapper/generators/roles_generator_spec.rb
roles_data_mapper-0.3.0 spec/roles_data_mapper/generators/roles_generator_spec.rb