Sha256: c13dc85d6492d5a24eef92dcdb125619966352d137af5995ad6c15757051384f

Contents?: true

Size: 1.19 KB

Versions: 6

Compression:

Stored size: 1.19 KB

Contents

require 'test_helper'
require 'active_support/testing/deprecation'

describe Canard do
  
  include ActiveSupport::Testing::Deprecation
  
  before do
    # Stop the deprecation warnings coming to stderr for these tests.
    ActiveSupport::Deprecation.behavior = :notify
    
    Canard.abilities_path = File.expand_path('../abilities', __FILE__)
  end
  
  describe "find_abilities" do
    
    it "loads the abilities into ability_definitions" do
      Canard.find_abilities

      Canard.ability_definitions.keys.must_include :admin
    end
    
    it "finds the abilities with the new syntax" do
      Canard.find_abilities
      
      Canard.ability_definitions.keys.must_include :moderator
    end
    
    it "reloads existing abilities" do
      Canard.find_abilities
      Canard::Abilities.send(:instance_variable_set, '@definitions', {})
      Canard.find_abilities
      
      Canard.ability_definitions.keys.must_include :moderator
      Canard.ability_definitions.keys.must_include :admin
    end
    
  end
  
  describe "abilities_for" do
    
    it "raises a deprecation warning" do
      assert_deprecated do
        Canard.abilities_for(:this) { puts 'that' }
      end
    end
    
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
canard-0.2.7 test/find_abilities_test.rb
canard-0.2.5 test/find_abilities_test.rb
canard-0.2.4 test/find_abilities_test.rb
canard-0.2.3 test/find_abilities_test.rb
canard-0.2.2 test/find_abilities_test.rb
canard-0.2.1 test/find_abilities_test.rb