1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
require 'spec_helper'
describe Rack::Adapter do
before do
@config_ru_path = File.dirname(__FILE__) + '/../../example'
@rails_path = File.dirname(__FILE__) + '/../rails_app'
end
it "should load Rack app from config" do
Rack::Adapter.load(@config_ru_path + '/config.ru').class.should == Proc
end
it "should guess Rack app from dir" do
Rack::Adapter.guess(@config_ru_path).should == :rack
end
it "should guess rails app from dir" do
Rack::Adapter.guess(@rails_path).should == :rails
end
it "should return nil when can't guess from dir" do
proc { Rack::Adapter.guess('.') }.should raise_error(Rack::AdapterNotFound)
end
it "should load Rack adapter" do
Rack::Adapter.for(:rack, :chdir => @config_ru_path).class.should == Proc
end
it "should load Rails adapter" do
Rack::Adapter::Rails.should_receive(:new)
Rack::Adapter.for(:rails, :chdir => @rails_path)
end
it "should load File adapter" do
Rack::File.should_receive(:new)
Rack::Adapter.for(:file)
end
it "should raise error when adapter can't be found" do
proc { Rack::Adapter.for(:fart, {}) }.should raise_error(Rack::AdapterNotFound)
end
end
|