Sha256: 2f2806b92de5df89985b20d5ae9ac0624f0edcd76caf18336fa277b007e8e03f

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

describe Apartment::Elevators::HostHash do

  describe "#parse_database_name" do
    it "parses the host for a domain name" do
      request = ActionDispatch::Request.new('HTTP_HOST' => 'example.com')
      elevator = Apartment::Elevators::HostHash.new(nil, 'example.com' => 'example_database')
      elevator.parse_database_name(request).should == 'example_database'
    end

    it "raises DatabaseNotFound exception if there is no host" do
      request = ActionDispatch::Request.new('HTTP_HOST' => '')
      elevator = Apartment::Elevators::HostHash.new(nil, 'example.com' => 'example_database')
      expect { elevator.parse_database_name(request) }.to raise_error(Apartment::DatabaseNotFound)
    end

    it "raises DatabaseNotFound exception if there is no database associated to current host" do
      request = ActionDispatch::Request.new('HTTP_HOST' => 'example2.com')
      elevator = Apartment::Elevators::HostHash.new(nil, 'example.com' => 'example_database')
      expect { elevator.parse_database_name(request) }.to raise_error(Apartment::DatabaseNotFound)
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
apartment-0.22.1 spec/unit/middleware/host_hash_elevator_spec.rb
apartment-0.22.0 spec/unit/middleware/host_hash_elevator_spec.rb