Sha256: 62640d5219ee6cb02db922b10f805cfe8d7bd6f52b3a6aee7d66cd3b73c0ad87

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

require 'spec_helper'

module Telephony
  describe ConversationsPresenter do
    describe '#as_json' do
      before do
        @conversations = 2.times.map do
          conversation = create :conversation
          calls = create_list :call, 2, conversation: conversation
          calls.each do |call|
            create :recording, call: call
          end
          conversation
        end
        conversations_presenter = ConversationsPresenter.new @conversations

        @as_json = conversations_presenter.as_json
      end

      it 'includes each of its conversations' do
        @as_json.should have(@conversations.size).conversations
      end

      it 'includes the calls for each of its conversations' do
        @as_json.each do |conversation|
          conversation[:calls].should have(2).calls
        end
      end

      it 'includes the recordings for each of its calls for each of its conversations' do
        @as_json.each do |conversation|
          calls = conversation[:calls]
          calls.each do |call|
            call[:recordings].should have(1).recording
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
telephony-1.0.4 spec/models/telephony/conversations_presenter_spec.rb
telephony-1.0.3 spec/models/telephony/conversations_presenter_spec.rb