Skip to content

Instantly share code, notes, and snippets.

@cmar
Created March 14, 2012 14:57
Show Gist options
  • Save cmar/2037033 to your computer and use it in GitHub Desktop.
Save cmar/2037033 to your computer and use it in GitHub Desktop.
require 'spree_shared/apartment_elevator'
require 'action_dispatch'
require 'rails/rack/logger'
module Apartment
module Elevators
describe Subdomain do
before do
@env = double("env")
@request = double("request")
@request.stub(:url => "http://fancy-mart-123.spreeworks.com/cart",
:subdomain => "fancy-mart-123")
ActionDispatch::Request.stub(:new => @request)
@app = double("app")
@rack = Apartment::Elevators::Subdomain.new(@app)
end
it "sets the cache to internal_subdomain name" do
@app.should_receive(:call).with(@env)
@rack.call(@env)
ENV['RAILS_CACHE_ID'].should eq "fancy-mart-123"
end
it "parses out the subdomain" do
@rack.subdomain(@request).should eq 'fancy-mart-123'
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment