spec/api/client_spec.rb in rsolr-1.0.6 vs spec/api/client_spec.rb in rsolr-1.0.7

- old
+ new

@@ -3,11 +3,11 @@ module ClientHelper def client @client ||= ( connection = RSolr::Connection.new - RSolr::Client.new connection, :url => "http://localhost:9999/solr" + RSolr::Client.new connection, :url => "http://localhost:9999/solr", :read_timeout => 42, :open_timeout=>43 ) end end context "initialize" do @@ -23,10 +23,17 @@ client.connection.should_receive(:execute). and_return({:status => 200, :body => "{}", :headers => {}}) client.send_and_receive '', :method => meth, :params => {}, :data => nil, :headers => {} end end + + it "should be timeout aware" do + [:get, :post, :head].each do |meth| + client.connection.should_receive(:execute).with(client, hash_including(:read_timeout => 42, :open_timeout=>43)) + client.send_and_receive '', :method => meth, :params => {}, :data => nil, :headers => {} + end + end end context "post" do include ClientHelper it "should pass the expected params to the connection's #execute method" do @@ -195,22 +202,22 @@ end result[:data].should == "data" result[:headers].should == {} end - it "should set the Content-Type header to application/x-www-form-urlencoded if a hash is passed in to the data arg" do + it "should set the Content-Type header to application/x-www-form-urlencoded; charset=UTF-8 if a hash is passed in to the data arg" do result = client.build_request('select', :method => :post, :data => {:q=>'test', :fq=>[0,1]}, :headers => {} ) result[:query].should == "wt=ruby" [/fq=0/, /fq=1/, /q=test/].each do |pattern| result[:data].should match pattern end result[:data].should_not match /wt=ruby/ - result[:headers].should == {"Content-Type" => "application/x-www-form-urlencoded"} + result[:headers].should == {"Content-Type" => "application/x-www-form-urlencoded; charset=UTF-8"} end end -end \ No newline at end of file +end