File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed
lib/rspec_api_documentation/dsl Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,15 @@ def params
62
62
end
63
63
64
64
def headers
65
- example . metadata [ :headers ]
65
+ return unless example . metadata [ :headers ]
66
+ example . metadata [ :headers ] . inject ( { } ) do |hash , header |
67
+ if header [ 1 ] . is_a? ( Symbol )
68
+ hash [ header [ 0 ] ] = send ( header [ 1 ] ) if respond_to? ( header [ 1 ] )
69
+ else
70
+ hash [ header [ 0 ] ] = header [ 1 ]
71
+ end
72
+ hash
73
+ end
66
74
end
67
75
68
76
def method
Original file line number Diff line number Diff line change 436
436
end
437
437
end
438
438
end
439
+
440
+ put "/orders" do
441
+ header "Accept" , :accept
442
+
443
+ let ( :accept ) { "application/json" }
444
+
445
+ it "should be sent with the request" do
446
+ example . metadata [ :headers ] . should == { "Accept" => :accept }
447
+ end
448
+
449
+ it "should fill out into the headers" do
450
+ headers . should == { "Accept" => "application/json" }
451
+ end
452
+
453
+ context "nested headers" do
454
+ header "Content-Type" , "application/json"
455
+
456
+ it "does not affect the outer context's assertions" do
457
+ headers . should == { "Accept" => "application/json" , "Content-Type" => "application/json" }
458
+ end
459
+ end
460
+
461
+ context "header was not let" do
462
+ header "X-My-Header" , :my_header
463
+
464
+ it "should not be in the headers hash" do
465
+ headers . should == { "Accept" => "application/json" }
466
+ end
467
+ end
468
+ end
439
469
end
440
470
end
441
471
You can’t perform that action at this time.
0 commit comments