| 
139 | 139 |         let(:raw_post) { { :bill => params }.to_json }  | 
140 | 140 | 
 
  | 
141 | 141 |         it "should send the raw post body" do  | 
142 |  | -          client.should_receive(method).with(path, raw_post)  | 
 | 142 | +          client.should_receive(method).with(path, raw_post, nil)  | 
143 | 143 |           do_request  | 
144 | 144 |         end  | 
145 | 145 |       end  | 
146 | 146 | 
 
  | 
147 | 147 |       context "when raw_post is not defined" do  | 
148 | 148 |         it "should send the params hash" do  | 
149 |  | -          client.should_receive(method).with(path, params)  | 
 | 149 | +          client.should_receive(method).with(path, params, nil)  | 
150 | 150 |           do_request  | 
151 | 151 |         end  | 
152 | 152 |       end  | 
153 | 153 | 
 
  | 
154 | 154 |       it "should allow extra parameters to be passed in" do  | 
155 |  | -        client.should_receive(method).with(path, params.merge("extra" => true))  | 
 | 155 | +        client.should_receive(method).with(path, params.merge("extra" => true), nil)  | 
156 | 156 |         do_request(:extra => true)  | 
157 | 157 |       end  | 
158 | 158 | 
 
  | 
159 | 159 |       it "should overwrite parameters" do  | 
160 |  | -        client.should_receive(method).with(path, params.merge("size" => "large"))  | 
 | 160 | +        client.should_receive(method).with(path, params.merge("size" => "large"), nil)  | 
161 | 161 |         do_request(:size => "large")  | 
162 | 162 |       end  | 
163 | 163 | 
 
  | 
164 | 164 |       it "should overwrite path variables" do  | 
165 |  | -        client.should_receive(method).with("/orders/2", params)  | 
 | 165 | +        client.should_receive(method).with("/orders/2", params, nil)  | 
166 | 166 |         do_request(:id => 2)  | 
167 | 167 |       end  | 
168 | 168 |     end  | 
 | 
283 | 283 | 
 
  | 
284 | 284 |       get "/users/:id/orders" do  | 
285 | 285 |         example "Page should be in the query string" do  | 
286 |  | -          client.should_receive(method).with do |path, data|  | 
 | 286 | +          client.should_receive(method).with do |path, data, headers|  | 
287 | 287 |             path.should =~ /^\/users\/1\/orders\?/  | 
288 | 288 |             path.split("?")[1].split("&").sort.should == "page=2&message=Thank+you".split("&").sort  | 
289 | 289 |             data.should be_nil  | 
 | 290 | +            headers.should be_nil  | 
290 | 291 |           end  | 
291 | 292 |           do_request  | 
292 | 293 |         end  | 
293 | 294 |       end  | 
294 | 295 | 
 
  | 
295 | 296 |       post "/users/:id/orders" do  | 
296 | 297 |         example "Page should be in the post body" do  | 
297 |  | -          client.should_receive(method).with("/users/1/orders", {"page" => 2, "message" => "Thank you"})  | 
 | 298 | +          client.should_receive(method).with("/users/1/orders", {"page" => 2, "message" => "Thank you"}, nil)  | 
298 | 299 |           do_request  | 
299 | 300 |         end  | 
300 | 301 |       end  | 
 | 
385 | 386 | 
 
  | 
386 | 387 |       context "no extra params" do  | 
387 | 388 |         before do  | 
388 |  | -          client.should_receive(:post).with("/orders", {})  | 
 | 389 | +          client.should_receive(:post).with("/orders", {}, nil)  | 
389 | 390 |         end  | 
390 | 391 | 
 
  | 
391 | 392 |         example_request "Creating an order"  | 
 | 
397 | 398 | 
 
  | 
398 | 399 |       context "extra options for do_request" do  | 
399 | 400 |         before do  | 
400 |  | -          client.should_receive(:post).with("/orders", {"order_type" => "big"})  | 
 | 401 | +          client.should_receive(:post).with("/orders", {"order_type" => "big"}, nil)  | 
401 | 402 |         end  | 
402 | 403 | 
 
  | 
403 | 404 |         example_request "should take an optional parameter hash", :order_type => "big"  | 
 | 
418 | 419 |       end  | 
419 | 420 |     end  | 
420 | 421 |   end  | 
 | 422 | + | 
 | 423 | +  context "headers" do  | 
 | 424 | +    put "/orders" do  | 
 | 425 | +      header "Accept", "application/json"  | 
 | 426 | + | 
 | 427 | +      it "should be sent with the request" do  | 
 | 428 | +        example.metadata[:headers].should == { "Accept" => "application/json" }  | 
 | 429 | +      end  | 
 | 430 | + | 
 | 431 | +      context "nested headers" do  | 
 | 432 | +        header "Content-Type", "application/json"  | 
 | 433 | + | 
 | 434 | +        it "does not affect the outer context's assertions" do  | 
 | 435 | +          # pass  | 
 | 436 | +        end  | 
 | 437 | +      end  | 
 | 438 | +    end  | 
 | 439 | +  end  | 
421 | 440 | end  | 
422 | 441 | 
 
  | 
423 | 442 | resource "top level parameters" do  | 
 | 
0 commit comments