Sha256: 631f8bd093cebc47521261788bbfb2918daa1fe5ac564f2ba9ff9655f87480ac
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
module ThinkingSphinx module Middlewares; end end require 'thinking_sphinx/middlewares/middleware' require 'thinking_sphinx/middlewares/inquirer' describe ThinkingSphinx::Middlewares::Inquirer do let(:app) { double('app', :call => true) } let(:middleware) { ThinkingSphinx::Middlewares::Inquirer.new app } let(:context) { {:sphinxql => sphinx_sql} } let(:sphinx_sql) { double('sphinx_sql', :to_sql => 'SELECT * FROM index') } let(:batch_inquirer) { double('batcher', :append_query => true, :results => [[:raw], [{'Variable_name' => 'meta', 'Value' => 'value'}]]) } before :each do batch_class = double batch_class.stub(:new).and_return(batch_inquirer) stub_const 'Riddle::Query', double(:meta => 'SHOW META') stub_const 'ThinkingSphinx::Search::BatchInquirer', batch_class end describe '#call' do it "passes through the SphinxQL from a Riddle::Query::Select object" do batch_inquirer.should_receive(:append_query).with('SELECT * FROM index') batch_inquirer.should_receive(:append_query).with('SHOW META') middleware.call [context] end it "sets up the raw results" do middleware.call [context] context[:raw].should == [:raw] end it "sets up the meta results as a hash" do middleware.call [context] context[:meta].should == {'meta' => 'value'} end it "uses the raw values as the initial results" do middleware.call [context] context[:results].should == [:raw] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
thinking-sphinx-3.1.2 | spec/thinking_sphinx/middlewares/inquirer_spec.rb |
thinking-sphinx-3.1.1 | spec/thinking_sphinx/middlewares/inquirer_spec.rb |