Sha256: f820ec815d45a6f74d58f6b932d5203f1f161b22a861b86cc9c0f2dac49f95c8

Contents?: true

Size: 887 Bytes

Versions: 1

Compression:

Stored size: 887 Bytes

Contents

require 'rspec'
require 'cantango'
require 'hashie'
def permission_fixture
  group = 'bloggers'
  rules = Hashie::Mash.new({"can"=>{"read"=>["Article", "Comment"]}, "cannot"=>{"write"=>["Article", "Post"]}})
  CanTango::PermissionEngine::Parser::Permissions.new.parse(group, rules) do |permission|
    return permission
  end
end

describe CanTango::PermissionEngine::Compiler do
  let (:permission) { permission_fixture }

  let(:compiler) do 
    compiler = CanTango::PermissionEngine::Compiler.new
    compiler.compile! permission
  end

  it 'should produce cancan statements' do
    compiler.can_eval do |statements|
      statements.should == %|can(:read, Article)\ncan(:read, Comment)|
    end
  end

  it 'should produce cancan statements' do
    compiler.cannot_eval do |statements|
      statements.should == %|cannot(:write, Article)\ncannot(:write, Post)|
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cantango-0.8.0 spec/cantango/permission_engine/compiler_spec.rb