Sha256: 49f8f9bde24f5b28b8cdd03955cf09698340232d4aa1893d6887a9d547777235

Contents?: true

Size: 1.91 KB

Versions: 7

Compression:

Stored size: 1.91 KB

Contents

require 'generator_spec_helper'
require_generator :data_mapper => :roles

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

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

7 entries across 7 versions & 1 rubygems

Version Path
roles_data_mapper-0.2.2 spec/roles_data_mapper/generators/roles_generator_spec.rb
roles_data_mapper-0.2.1 spec/roles_data_mapper/generators/roles_generator_spec.rb
roles_data_mapper-0.2.0 spec/roles_data_mapper/generators/roles_generator_spec.rb
roles_data_mapper-0.1.3 spec/roles_data_mapper/generators/roles_generator_spec.rb
roles_data_mapper-0.1.2 spec/roles_data_mapper/generators/roles_generator_spec.rb
roles_data_mapper-0.1.1 spec/roles_data_mapper/generators/roles_generator_spec.rb
roles_data_mapper-0.1.0 spec/roles_data_mapper/generators/roles_generator_spec.rb