Sha256: 7fa0f5dbdc0ba2c373e199153b0c54b93849ab3c49ae1e037989f0d656f46173

Contents?: true

Size: 1.77 KB

Versions: 3

Compression:

Stored size: 1.77 KB

Contents

require 'spec_helper' 
require 'generator-spec'

require_generator :cantango => :role_permits

RSpec::Generator.configure do |config|
  config.debug = true
  config.remove_temp_dir = true #false
  config.default_rails_root(__FILE__) 
  config.lib = File.dirname(__FILE__) + '/../lib'
  config.logger = :stdout  # :file
end


describe CanTango::Generators::RolePermitsGenerator do
  use_helpers :controller, :special, :file

  setup_generator :permits do
    tests CanTango::Generators::RolePermitsGenerator
  end

  describe 'result of running generator with default profile' do
    before :each do
      @generator = with_generator do |g|    
        g.run_generator "--orm mongoid --account editor".args
      end
    end

    describe 'result of running Permits generator' do
      it "should create Admin permit" do
        @generator.should generate_permit :admin
      end

      it "should generate a permits initializer file with orm set to mongoid" do      
        File.read(initializer_file(:cantango)).should match /config.orm = :mongoid/
      end      
    end
  end

  describe 'result of running generator with option to create permit for each registered role' do
    context "Registered roles :editor, :admin" do
      before :each do
        @generator = with_generator do |g|    
          g.run_generator "admin editor".args
        end
      end
  
      it "should have created Guest and Admin permits" do
        @generator.should have_permit_files :guest, :admin
      end
      
      it "should have created the Editor permit for the :editor role and the permit should not use licenses" do      
        @generator.should have_permit_file :editor do |editor_permit|
          editor_permit.should_not have_licenses :user_admin, :blogging 
        end
      end
    end #ctx
  end    
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cantango-0.8.6 spec/generators/cantango/account_role_permits_generator_spec.rb
cantango-0.8.5.1 spec/generators/cantango/account_role_permits_generator_spec.rb
cantango-0.8.0 spec/generators/cantango/account_role_permits_generator_spec.rb