require File.dirname(__FILE__) + '/../../../spec_helper' require 'rack/test' require 'useless/doc/rack/css' require 'useless/doc/ui/godel' describe Useless::Doc::Rack::CSS do include Rack::Test::Methods def base_app @base_app ||= lambda do |env| [200, {'Content-Type' => 'text/plain'}, ['Not a stylesheet request.']] end end def app @app ||= lambda do |env| env['useless.doc.ui'] = Useless::Doc::UI::Godel Useless::Doc::Rack::CSS.new(base_app).call(env) end end it 'should proxy requests if the path is not doc.css' do get 'http://some-api.granmal.com/not/doc.css' last_response.body.should == 'Not a stylesheet request.' end it 'should return the UI\'s CSS if the path is doc.css' do Useless::Doc::UI::Godel.should_receive(:css).and_return('some css') get 'http://some-api.granmal.com/doc.css' last_response.body.should == 'some css' last_response['Content-Type'].should == 'text/css' end end