Sha256: db330acc788e4802305bb6e45a4af76d7804374e22a9039887e5fb189d7cff3a

Contents?: true

Size: 1.33 KB

Versions: 4

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

describe ThinkingSphinx::SphinxError do
  describe '.new_from_mysql' do
    let(:error) { double 'error', :message => 'index foo: unknown error',
      :backtrace => ['foo', 'bar'] }

    it "translates syntax errors" do
      error.stub :message => 'index foo: syntax error: something is wrong'

      ThinkingSphinx::SphinxError.new_from_mysql(error).
        should be_a(ThinkingSphinx::SyntaxError)
    end

    it "translates parse errors" do
      error.stub :message => 'index foo: parse error: something is wrong'

      ThinkingSphinx::SphinxError.new_from_mysql(error).
        should be_a(ThinkingSphinx::ParseError)
    end

    it "translates query errors" do
      error.stub :message => 'index foo: query error: something is wrong'

      ThinkingSphinx::SphinxError.new_from_mysql(error).
        should be_a(ThinkingSphinx::QueryError)
    end

    it "defaults to sphinx errors" do
      error.stub :message => 'index foo: unknown error: something is wrong'

      ThinkingSphinx::SphinxError.new_from_mysql(error).
        should be_a(ThinkingSphinx::SphinxError)
    end

    it "keeps the original error's backtrace" do
      error.stub :message => 'index foo: unknown error: something is wrong'

      ThinkingSphinx::SphinxError.new_from_mysql(error).
        backtrace.should == error.backtrace
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
thinking-sphinx-3.0.5 spec/thinking_sphinx/errors_spec.rb
thinking-sphinx-3.0.4 spec/thinking_sphinx/errors_spec.rb
thinking-sphinx-3.0.3 spec/thinking_sphinx/errors_spec.rb
thinking-sphinx-3.0.2 spec/thinking_sphinx/errors_spec.rb