Sha256: 9103adcd31d48feab68e65b626dd93bfc3d659c12fec5ca9dfc9378a385121ad

Contents?: true

Size: 626 Bytes

Versions: 1

Compression:

Stored size: 626 Bytes

Contents

require File.expand_path("helper", File.dirname(__FILE__))

test "eval only in a given subdomain" do
  Cuba.define do
    on subdomain("api"), root do
      as do
        "Subdomain"
      end
    end

    on root do
      as do
        "Main"
      end
    end
  end

  subdomain_env = { "SCRIPT_NAME" => "/", "PATH_INFO" => "/", "HTTP_HOST" => "api.example.com" }
  standard_env = { "SCRIPT_NAME" => "/", "PATH_INFO" => "/", "HTTP_HOST" => "example.com" }

  _, _, sub_resp = Cuba.call(subdomain_env)
  _, _, resp = Cuba.call(standard_env)

  assert_equal ["Subdomain"], sub_resp.body
  assert_equal ["Main"], resp.body
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cuba-sugar-0.2.1 test/subdomain.rb