Sha256: 4f4c5c7555170f8de8170dc5bf2cbaea8ad1cad3ad4dde1bad9e80b659da986e
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
require 'rubygems' begin require 'simplecov' SimpleCov.start do add_filter "/spec/" end rescue LoadError # simplecov not installed end require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'add_http_header')) describe AddHttpHeader do before :each do @app = Proc.new{|env| [200, {"Content-Type" => "text/html"}, "Success"]} end it "should add headers to a request" do middleware = AddHttpHeader.new(@app, :test => "here", "x-Test" => 1) status, headers, body = middleware.call({}) status.should == 200 body.should == "Success" headers.should == {"Content-Type" => "text/html", "test" => "here", "x-Test" => "1"} end it "should add dynamic headers to a request" do middleware = AddHttpHeader.new(@app, :test => lambda{|env, status, headers| "#{env['HOST']} / #{status} / #{headers['Content-Type']}"}) status, headers, body = middleware.call('HOST' => 'locahost') status.should == 200 body.should == "Success" headers.should == {"Content-Type" => "text/html", "test" => "locahost / 200 / text/html"} end it "should not add blank headers" do middleware = AddHttpHeader.new(@app, :test => "") status, headers, body = middleware.call({}) status.should == 200 body.should == "Success" headers.should == {"Content-Type" => "text/html"} end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
add_http_header-1.0.3 | spec/add_http_header_spec.rb |
add_http_header-1.0.2 | spec/add_http_header_spec.rb |