Sha256: c7e4ad5001e92544aa85d3b598a980d1551f9fff8594be5a63f42fe807eecaf8
Contents?: true
Size: 927 Bytes
Versions: 2
Compression:
Stored size: 927 Bytes
Contents
require 'bundler/setup' require 'sphinx' require 'stringio' # Helper exception class to omit real dialogue between client and server class SphinxSpecError < StandardError; end # Runs PHP fixture to get request dump def sphinx_fixture(name, type = :request) File.open(File.join(File.dirname(__FILE__), 'fixtures', "#{type}s", "#{name}.dat"), 'rb') do |f| f.read end end class SphinxFakeSocket def initialize(data = '', mode = 'rb') @sock = StringIO.new(data, mode) end def method_missing(method, *args) @sock.__send__(method, *args) rescue IOError end end def sphinx_create_client @sphinx = Sphinx::Client.new @sock = mock('SocketMock') servers = @sphinx.instance_variable_get(:@servers) servers.first.stub(:get_socket => @sock, :free_socket => nil) @sphinx.stub!(:parse_response).and_raise(SphinxSpecError) return @sphinx end def sphinx_safe_call yield rescue SphinxSpecError end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sphinx-2.1.1.3712 | spec/spec_helper.rb |
sphinx-2.1.1.3711 | spec/spec_helper.rb |