Sha256: 84ed5e3f9f4be43099e7400ae5d0888a5145a360a9d563f9eb9fd0d009205f9f

Contents?: true

Size: 992 Bytes

Versions: 7

Compression:

Stored size: 992 Bytes

Contents

require File.dirname(__FILE__) + '/../../spec_helper'

describe Low::Middleware::SubdomainMap do
  def map
    default_app = lambda do |env|
      [200, {'Content-Type' => 'text/plain'}, ['Default App']]
    end

    api_app = lambda do |env|
      [200, {'Content-Type' => 'text/plain'}, ['API App']]
    end

    Low::Middleware::SubdomainMap.new default_app, 'subdomain' => api_app
  end

  it 'should call the default app if no subdomain is specified' do
    res = Rack::MockRequest.new(map).get('http://useless.info')
    res.should be_ok
    res.body.should == 'Default App'
  end

  it 'should call the appropriate API app if a subdomain is specified' do
    res = Rack::MockRequest.new(map).get('http://subdomain.useless.info')
    res.should be_ok
    res.body.should == 'API App'
  end

  it 'should return a 403 Forbidden if the specified subdomain is not mapped' do
    res = Rack::MockRequest.new(map).get('http://nonexistant.useless.info')
    res.should be_forbidden
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
low-0.0.12 spec/low/middleware/subdomain_map_spec.rb
low-0.0.11 spec/low/middleware/subdomain_map_spec.rb
low-0.0.10 spec/low/middleware/subdomain_map_spec.rb
low-0.0.9 spec/low/middleware/subdomain_map_spec.rb
low-0.0.8 spec/low/middleware/subdomain_map_spec.rb
low-0.0.7 spec/low/middleware/subdomain_map_spec.rb
low-0.0.6 spec/low/middleware/subdomain_map_spec.rb