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
6262 end
6363
6464 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
6674 end
6775
6876 def method
Original file line number Diff line number Diff line change 436436 end
437437 end
438438 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
439469 end
440470end
441471
You can’t perform that action at this time.
0 commit comments