Sha256: 3effb1db2bc237d6f11b3cdb18ed9b2d03d5b8101725045190ec965745b0c408
Contents?: true
Size: 1.28 KB
Versions: 20
Compression:
Stored size: 1.28 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Hyperdrive::Middleware::CORS do def app cors_options = { origins: '*', allow_headers: '*, Content-Type, Accept, AUTHORIZATION, Cache-Control', credentials: true, expose_headers: 'Cache-Control, Content-Language, Content-Type, Expires, Last-Modified, Pragma', max_age: 86400 } inner_app = ->(env) { [200, {}, ['']] } Hyperdrive::Middleware::CORS.new(inner_app, cors_options) end before do env = default_rack_env(default_resource) get '/', {}, env @headers = last_response.headers end it "allows origins" do @headers['Access-Control-Allow-Origin'].must_equal '*' end it "allows methods" do @headers['Access-Control-Allow-Methods'].must_equal 'OPTIONS, GET, HEAD' end it "allows headers" do @headers['Access-Control-Allow-Headers'].must_equal '*, Content-Type, Accept, AUTHORIZATION, Cache-Control' end it "allows credentials" do @headers['Access-Control-Allow-Credentials'].must_equal "true" end it "has a max age" do @headers['Access-Control-Max-Age'].must_equal "86400" end it "exposes headers" do @headers['Access-Control-Expose-Headers'].must_equal 'Cache-Control, Content-Language, Content-Type, Expires, Last-Modified, Pragma' end end
Version data entries
20 entries across 20 versions & 1 rubygems