spec/rsolr-ext_spec.rb in rsolr-ext-0.12.1 vs spec/rsolr-ext_spec.rb in rsolr-ext-1.0.0

- old
+ new

@@ -10,68 +10,68 @@ client.should respond_to(:find) end it 'should produce results from the #find method' do c = client - c.should_receive(:request). - with('/select', {:rows=>10, :start=>20, :q=>"*:*"}). + c.should_receive(:send_and_receive). + with('select', {:params => {:rows=>10, :start=>20, :q=>"*:*"}}). and_return({'response'=>{'docs' => []}, 'responseHeader' => {}}) response = c.find :page=>3, :per_page=>10, :q=>'*:*'#, :page=>1, :per_page=>10 response.should be_a(Mash) end it 'should call the #find method with a custom request handler' do c = client expected_response = {'response'=>{'docs' => []}, 'responseHeader' => {}} # ok this is hacky... the raw method needs to go into a mixin dude def expected_response.raw - {:path => '/select'} + {:path => 'select'} end - c.should_receive(:request). - with('/select', {:q=>'*:*'}). + c.should_receive(:send_and_receive). + with('select', {:params => {:q=>'*:*'}}). and_return(expected_response) - response = c.find '/select', :q=>'*:*' - response.raw[:path].should match(/\/select/) + response = c.find 'select', :q=>'*:*' + response.raw[:path].should match(/select/) end it 'should be ok' do c = client - c.should_receive(:request). - with('/select', :q=>'*:*'). + c.should_receive(:send_and_receive). + with('select', {:params => {:q=>'*:*'}}). and_return({'response'=>{'docs' => []}, 'responseHeader' => {'status'=>0}}) response = c.find :q=>'*:*' response.should respond_to(:ok?) response.ok?.should == true end it 'should call the #luke method' do c = client - c.should_receive(:request). - with('/admin/luke', {"numTerms"=>0}). + c.should_receive(:get). + with('admin/luke', {"numTerms"=>0}). and_return({"fields"=>nil, "index"=>nil, "info" => nil}) info = c.luke info.should be_a(Mash) info.should have_key('fields') info.should have_key('index') info.should have_key('info') end - it 'should forwad #ping? calls to the connection' do - client.connection.should_receive(:request). - with('/admin/ping', :wt => :ruby ). + it 'should forward #ping? calls to the connection' do + client.should_receive(:get). + with('admin/ping', :wt => :ruby ). and_return( :params => { :wt => :ruby }, :status_code => 200, :body => "{'responseHeader'=>{'status'=>0,'QTime'=>44,'params'=>{'echoParams'=>'all','echoParams'=>'all','q'=>'solrpingquery','qt'=>'standard','wt'=>'ruby'}},'status'=>'OK'}" ) client.ping? end it 'should raise an error if the ping service is not available' do - client.connection.should_receive(:request). - with('/admin/ping', :wt => :ruby ). + client.should_receive(:get). + with('admin/ping', :wt => :ruby ). # the first part of the what the message would really be - and_raise( RSolr::RequestError.new("Solr Response: pingQuery_not_configured_consider_registering_PingRequestHandler_with_the_name_adminping_instead__") ) - lambda { client.ping? }.should raise_error( RSolr::RequestError ) + and_raise( RuntimeError.new("Solr Response: pingQuery_not_configured_consider_registering_PingRequestHandler_with_the_name_adminping_instead__") ) + lambda { client.ping? }.should raise_error( RuntimeError ) end end context 'requests' do @@ -135,11 +135,11 @@ context 'response' do def create_response raw_response = eval(mock_query_response) - RSolr::Ext::Response::Base.new(raw_response, '/select', raw_response['params']) + RSolr::Ext::Response::Base.new(raw_response, 'select', raw_response['params']) end it 'should create a valid response' do r = create_response r.should respond_to(:header) @@ -197,10 +197,10 @@ expected = "electronics - 14, memory - 3, card - 2, connector - 2, drive - 2, graphics - 2, hard - 2, monitor - 2, search - 2, software - 2" received = first_facet.items.collect do |item| item.value + ' - ' + item.hits.to_s end.join(', ') - expected.should == received + received.should == expected r.facets.each do |facet| facet.respond_to?(:name).should == true facet.items.each do |item| item.respond_to?(:value).should == true