Sha256: 49606059208f94b4f8c84f77c3f72b275d4be6f9d5d473ae6683b06ef1d411a0

Contents?: true

Size: 848 Bytes

Versions: 1

Compression:

Stored size: 848 Bytes

Contents

require 'spec_helper'

describe Esearch::Connection, '#run' do
  subject { object.run(request) }

  let(:object) { described_class.new(connection, logger) }

  let(:connection) { double('Connection')                                  }
  let(:logger)     { DummyLogger.new                                       }
  let(:request)    { double('Request', :log_string => 'the-logged-string') }
  let(:response)   { double('Response', :status => 200)                    }

  class DummyLogger
    attr_reader :messages

    def initialize
      @messages = []
    end

    def debug
      @messages << yield
    end
  end

  before do
    request.should_receive(:run).with(connection).and_return(response)
  end

  it { should be(response) }

  it 'should log requests' do
    subject
    logger.messages.should eql(%w(the-logged-string 200))
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
esearch-0.2.1 spec/unit/esearch/connection/run_spec.rb