require 'spec_helper'

describe Conduit::Driver::Fusion::ChangeDevice::Parser do
  include ServerResponse

  subject { described_class.new(server_response) }

  context 'successful device change' do
    let(:response_file)   { %w(change_device success.xml) }
    it_should_behave_like 'parser success response'

    let(:expected) do
      {
        esn: '999999457809420396',
        mdn: '5617219600',
        msid: '000005555551166',
        msl: '555511'
      }
    end

    it 'parses the response correctly' do
      expect(subject.serializable_hash).to eql(expected)
    end
  end

  context 'unsuccessful device change' do
    let(:response_file)   { %w(change_device failure.xml) }
    it_should_behave_like 'parser failure response'
  end

  context 'server error' do
    let(:response_file)   { %w(failure.xml) }
    it_should_behave_like 'parser error response'
  end
end
