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

Version Path
hyperdrive-0.0.25 spec/hyperdrive/middleware/cors_spec.rb
hyperdrive-0.0.24 spec/hyperdrive/middleware/cors_spec.rb
hyperdrive-0.0.23 spec/hyperdrive/middleware/cors_spec.rb
hyperdrive-0.0.22 spec/hyperdrive/middleware/cors_spec.rb
hyperdrive-0.0.21 spec/hyperdrive/middleware/cors_spec.rb
hyperdrive-0.0.20 spec/hyperdrive/middleware/cors_spec.rb
hyperdrive-0.0.19 spec/hyperdrive/middleware/cors_spec.rb
hyperdrive-0.0.18 spec/hyperdrive/middleware/cors_spec.rb
hyperdrive-0.0.17 spec/hyperdrive/middleware/cors_spec.rb
hyperdrive-0.0.16 spec/hyperdrive/middleware/cors_spec.rb
hyperdrive-0.0.15 spec/hyperdrive/middleware/cors_spec.rb
hyperdrive-0.0.14 spec/hyperdrive/middleware/cors_spec.rb
hyperdrive-0.0.13 spec/hyperdrive/middleware/cors_spec.rb
hyperdrive-0.0.12 spec/hyperdrive/middleware/cors_spec.rb
hyperdrive-0.0.11 spec/hyperdrive/middleware/cors_spec.rb
hyperdrive-0.0.10 spec/hyperdrive/middleware/cors_spec.rb
hyperdrive-0.0.9 spec/hyperdrive/middleware/cors_spec.rb
hyperdrive-0.0.8 spec/hyperdrive/middleware/cors_spec.rb
hyperdrive-0.0.7 spec/hyperdrive/middleware/cors_spec.rb
hyperdrive-0.0.6 spec/hyperdrive/middleware/cors_spec.rb