Sha256: 29a0782a2087b1550d19692d142d36ff4733d6e060c8daf23a7549daea4f2ff8

Contents?: true

Size: 1.48 KB

Versions: 2

Compression:

Stored size: 1.48 KB

Contents

require 'test_helper'
require 'canard'

describe 'Canard::Abilities' do

  subject { Canard::Abilities }

  describe "ability_paths" do

    it "defaults to app/abilities" do
      subject.definition_paths.must_include 'app/abilities'
    end

    it "appends paths" do
      subject.definition_paths << 'other_abilities'
      subject.definition_paths.must_include 'other_abilities'
    end

    it "can be overwritten" do
      subject.definition_paths = ['other_abilities']

      subject.definition_paths.must_equal ['other_abilities']
    end

  end

  describe "default_path" do

    it "defaults to app/abilities" do
      subject.default_path.must_equal 'app/abilities'
    end

    it "can be changhed" do
      subject.default_path = 'other_abilities'

      subject.default_path.must_equal 'other_abilities'
    end


  end

  describe "for" do

    it "adds the block to the definitions" do
      block = lambda { puts 'some block' }

      subject.for(:definition, &block)

      assert_equal block, subject.definitions[:definition]
    end

    it "normalises the key to a symbol" do
      subject.for('definition') { puts 'a block' }

      subject.definitions.keys.must_include :definition
    end

    it "rasises ArgumentError if no block is provided" do
      proc { subject.for(:definition) }.must_raise ArgumentError
    end

    it 'creates a lowercaae key' do
      subject.for('NotCamelCase') { puts 'a block' }

      subject.definitions.keys.must_include :not_camel_case
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
canard-0.5.0.pre test/canard/abilities_test.rb
canard-0.4.3 test/canard/abilities_test.rb