Sha256: 96fde921a1d087e10660e22f734fedc968c4f7a7f2fa708c6bfab8a32d2323aa

Contents?: true

Size: 1.16 KB

Versions: 17

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe ThinkingSphinx::Middlewares::ValidOptions do
  let(:app)        { double 'app', :call => true }
  let(:middleware) { ThinkingSphinx::Middlewares::ValidOptions.new app }
  let(:context)    { double 'context', :search => search }
  let(:search)     { double 'search', :options => {} }

  before :each do
    allow(ThinkingSphinx::Logger).to receive(:log)
  end

  context 'with unknown options' do
    before :each do
      search.options[:foo] = :bar
    end

    it "adds a warning" do
      expect(ThinkingSphinx::Logger).to receive(:log).
        with(:caution, "Unexpected search options: [:foo]")

      middleware.call [context]
    end

    it 'continues on' do
      expect(app).to receive(:call).with([context])

      middleware.call [context]
    end
  end

  context "with known options" do
    before :each do
      search.options[:ids_only] = true
    end

    it "is silent" do
      expect(ThinkingSphinx::Logger).to_not receive(:log)

      middleware.call [context]
    end

    it 'continues on' do
      expect(app).to receive(:call).with([context])

      middleware.call [context]
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
thinking-sphinx-5.6.0 spec/thinking_sphinx/middlewares/valid_options_spec.rb
thinking-sphinx-5.5.1 spec/thinking_sphinx/middlewares/valid_options_spec.rb
thinking-sphinx-5.5.0 spec/thinking_sphinx/middlewares/valid_options_spec.rb
thinking-sphinx-5.4.0 spec/thinking_sphinx/middlewares/valid_options_spec.rb
thinking-sphinx-5.3.0 spec/thinking_sphinx/middlewares/valid_options_spec.rb
thinking-sphinx-5.2.1 spec/thinking_sphinx/middlewares/valid_options_spec.rb
thinking-sphinx-5.2.0 spec/thinking_sphinx/middlewares/valid_options_spec.rb
thinking-sphinx-5.1.0 spec/thinking_sphinx/middlewares/valid_options_spec.rb
thinking-sphinx-5.0.0 spec/thinking_sphinx/middlewares/valid_options_spec.rb
thinking-sphinx-4.4.1 spec/thinking_sphinx/middlewares/valid_options_spec.rb
thinking-sphinx-4.4.0 spec/thinking_sphinx/middlewares/valid_options_spec.rb
thinking-sphinx-4.3.2 spec/thinking_sphinx/middlewares/valid_options_spec.rb
thinking-sphinx-4.3.1 spec/thinking_sphinx/middlewares/valid_options_spec.rb
thinking-sphinx-4.3.0 spec/thinking_sphinx/middlewares/valid_options_spec.rb
thinking-sphinx-4.2.0 spec/thinking_sphinx/middlewares/valid_options_spec.rb
thinking-sphinx-4.1.0 spec/thinking_sphinx/middlewares/valid_options_spec.rb
thinking-sphinx-4.0.0 spec/thinking_sphinx/middlewares/valid_options_spec.rb