Sha256: c5aa4d91574ad5468ad0bcc7fdb2390b819cf853ef42ce9e8bfa71d192a5b9c1

Contents?: true

Size: 1.29 KB

Versions: 28

Compression:

Stored size: 1.29 KB

Contents

require 'migration_spec_helper'
require_generator :active_record => :roles_migration

describe 'roles_migration_generator' do
  use_orm :active_record  
  use_helper :migration
  
  before :each do              
    setup_generator 'roles_migration_generator' do
      tests ActiveRecord::Generators::RolesMigrationGenerator
    end    
  end

  after :each do
  end


  it "should generate migration 'add_role_to_user' and 'create_roles' for role strategy 'one_role'" do    
    with_generator do |g|
      remove_migrations :add_role_to_users, :create_roles
            
      g.run_generator [:user, %w{--strategy one_role}].args

      # def up          
      #   create_roles
      #   add_user_role
      # end
      # 
      # def down      
      #   drop_roles
      #   remove_user_role
      # end

      g.should generate_migration :add_one_role_strategy do |content|
        content.should have_class_self do |class_self|        
          class_self.should have_method :up do |up|
            up.should have_call :create_roles
            up.should have_call :add_user_role
          end

          class_self.should have_method :down do |down|
            down.should have_call :drop_roles
            down.should have_call :remove_user_role
          end
        end
      end
    end # with
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
roles_active_record-0.5.1 spec/roles_active_record/generators/roles_migration/one_role_spec.rb
roles_active_record-0.5.0 spec/roles_active_record/generators/roles_migration/one_role_spec.rb
roles_active_record-0.4.9 spec/roles_active_record/generators/roles_migration/one_role_spec.rb
roles_active_record-0.4.8 spec/roles_active_record/generators/roles_migration/one_role_spec.rb
roles_active_record-0.4.7 spec/roles_active_record/generators/roles_migration/one_role_spec.rb
roles_active_record-0.4.6.4 spec/roles_active_record/generators/roles_migration/one_role_spec.rb
roles_active_record-0.4.6.3 spec/roles_active_record/generators/roles_migration/one_role_spec.rb
roles_active_record-0.4.6.2 spec/roles_active_record/generators/roles_migration/one_role_spec.rb
roles_active_record-0.4.6.1 spec/roles_active_record/generators/roles_migration/one_role_spec.rb
roles_active_record-0.4.6 spec/roles_active_record/generators/roles_migration/one_role_spec.rb
roles_active_record-0.4.5 spec/roles_active_record/generators/roles_migration/one_role_spec.rb
roles_active_record-0.4.4 spec/roles_active_record/generators/roles_migration/one_role_spec.rb
roles_active_record-0.4.3 spec/roles_active_record/generators/roles_migration/one_role_spec.rb
roles_active_record-0.4.2 spec/roles_active_record/generators/roles_migration/one_role_spec.rb
roles_active_record-0.4.1 spec/roles_active_record/generators/roles_migration/one_role_spec.rb
roles_active_record-0.4.0 spec/roles_active_record/generators/roles_migration/one_role_spec.rb
roles_active_record-0.3.6 spec/roles_active_record/generators/roles_migration/one_role_spec.rb
roles_active_record-0.3.5 spec/roles_active_record/generators/roles_migration/one_role_spec.rb
roles_active_record-0.3.4 spec/roles_active_record/generators/roles_migration/one_role_spec.rb
roles_active_record-0.3.3 spec/roles_active_record/generators/roles_migration/one_role_spec.rb