Sha256: 1d783746146d63e989db3d22f5f832b1ad9099e38a3d53c06b611332f9faf5be

Contents?: true

Size: 1.37 KB

Versions: 141

Compression:

Stored size: 1.37 KB

Contents

require 'spec_helper'

require 'rack'
require 'picky-client/spec'

describe Picky::TestClient do
  
  class TestApplication; end
  
  let(:client) { described_class.new(TestApplication, :path => '/some/path') }
  
  context 'search' do
    it 'does extract the hash' do
      TestApplication.stub! :call => [200, { 'Content-Type' => 'application/json' }, ['{"allocations":[["boooookies",0.0,1,[["title","hell","hell"]],[313]]],"offset":0,"duration":0.000584,"total":1}']]
      
      client.search('test').should == { :allocations => [['boooookies', 0.0, 1, [['title', 'hell', 'hell']], [313]]], :offset => 0, :duration => 0.000584, :total => 1 }
    end
    it 'does extend the result with convenience methods' do
      TestApplication.stub! :call => [200, { 'Content-Type' => 'application/json' }, ['{"allocations":[["boooookies",0.0,1,[["title","hell","hell"]],[313]]],"offset":0,"duration":0.000584,"total":1}']]
      
      client.search('test').total.should == 1
    end
  end
  
  context 'send_search' do
    it 'sends correctly' do
      response = stub :response
      request = stub :request
      client.stub! :request => request
      
      request.should_receive(:get).once.with('/some/path?query=some_query').and_return response
      response.should_receive(:body).once.and_return :some_body
      
      client.send_search(:query => :some_query).should == :some_body
    end
  end
  
end

Version data entries

141 entries across 141 versions & 1 rubygems

Version Path
picky-client-4.2.4 spec/picky-client/spec/test_client_spec.rb
picky-client-4.2.3 spec/picky-client/spec/test_client_spec.rb
picky-client-4.2.2 spec/picky-client/spec/test_client_spec.rb
picky-client-4.2.1 spec/picky-client/spec/test_client_spec.rb
picky-client-4.2.0 spec/picky-client/spec/test_client_spec.rb
picky-client-4.1.0 spec/picky-client/spec/test_client_spec.rb
picky-client-4.0.9 spec/picky-client/spec/test_client_spec.rb
picky-client-4.0.8 spec/picky-client/spec/test_client_spec.rb
picky-client-4.0.7 spec/picky-client/spec/test_client_spec.rb
picky-client-4.0.6 spec/picky-client/spec/test_client_spec.rb
picky-client-4.0.5 spec/picky-client/spec/test_client_spec.rb
picky-client-4.0.4 spec/picky-client/spec/test_client_spec.rb
picky-client-4.0.3 spec/picky-client/spec/test_client_spec.rb
picky-client-4.0.1 spec/picky-client/spec/test_client_spec.rb
picky-client-4.0.0 spec/picky-client/spec/test_client_spec.rb
picky-client-4.0.0pre6 spec/picky-client/spec/test_client_spec.rb
picky-client-4.0.0pre5 spec/picky-client/spec/test_client_spec.rb
picky-client-4.0.0pre3 spec/picky-client/spec/test_client_spec.rb
picky-client-4.0.0pre2 spec/picky-client/spec/test_client_spec.rb
picky-client-4.0.0pre1 spec/picky-client/spec/test_client_spec.rb