Sha256: f1f4facc4bd9c3a5a930140ed0d80f1394e2f139001ffa7243254cdece4fb62f

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

module Adhearsion
  describe Calls do
    before { Adhearsion.active_calls.clear! }

    let(:call) { Adhearsion::Call.new mock_offer }

    it 'can create a call and add it to the active calls' do
      Adhearsion.active_calls.any?.should == false
      call = Adhearsion.active_calls.from_offer mock_offer
      call.should be_a Adhearsion::Call
      Adhearsion.active_calls.size.should == 1
    end

    it '#size should return the size of the collection' do
      subject.size.should == 0
      subject << call
      subject.size.should == 1
    end

    it '#remove_inactive_call should delete the call in the Hash' do
      number_of_calls = 10
      calls = Array.new(number_of_calls) { Adhearsion::Call.new mock_offer }
      calls.each { |call| subject << call }

      deleted_call = calls[number_of_calls / 2]
      subject.remove_inactive_call deleted_call
      subject.size.should == number_of_calls - 1
    end

    it '#find should pull the Call from the Hash using the id' do
      subject << call
      subject.find(call.id).should be call
    end

    it "finding calls by a tag" do
      calls = Array.new(3) { Adhearsion::Call.new mock_offer }
      calls.each { |call| subject << call }

      tagged_call = calls.last
      tagged_call.tag :moderator

      subject.with_tag(:moderator).should == [tagged_call]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
adhearsion-2.0.0.alpha1 spec/adhearsion/calls_spec.rb