X7ROOT File Manager
Current Path:
/opt/alt/ruby19/lib64/ruby/gems/1.9.1/gems/rack-1.6.4/test
opt
/
alt
/
ruby19
/
lib64
/
ruby
/
gems
/
1.9.1
/
gems
/
rack-1.6.4
/
test
/
ðŸ“
..
ðŸ“
builder
ðŸ“
cgi
📄
gemloader.rb
(298 B)
ðŸ“
multipart
ðŸ“
rackup
ðŸ“
registering_handler
📄
spec_auth_basic.rb
(2.26 KB)
📄
spec_auth_digest.rb
(8.08 KB)
📄
spec_body_proxy.rb
(2.2 KB)
📄
spec_builder.rb
(6.2 KB)
📄
spec_cascade.rb
(2.11 KB)
📄
spec_cgi.rb
(2.92 KB)
📄
spec_chunked.rb
(3.87 KB)
📄
spec_commonlogger.rb
(2.37 KB)
📄
spec_conditionalget.rb
(3.28 KB)
📄
spec_config.rb
(544 B)
📄
spec_content_length.rb
(2.8 KB)
📄
spec_content_type.rb
(1.47 KB)
📄
spec_deflater.rb
(10.04 KB)
📄
spec_directory.rb
(2.19 KB)
📄
spec_etag.rb
(3.84 KB)
📄
spec_fastcgi.rb
(3.08 KB)
📄
spec_file.rb
(6.32 KB)
📄
spec_handler.rb
(1.87 KB)
📄
spec_head.rb
(1.36 KB)
📄
spec_lint.rb
(19.23 KB)
📄
spec_lobster.rb
(1.23 KB)
📄
spec_lock.rb
(4.33 KB)
📄
spec_logger.rb
(622 B)
📄
spec_methodoverride.rb
(2.38 KB)
📄
spec_mime.rb
(1.81 KB)
📄
spec_mock.rb
(9.34 KB)
📄
spec_mongrel.rb
(5.73 KB)
📄
spec_multipart.rb
(23.62 KB)
📄
spec_nulllogger.rb
(514 B)
📄
spec_recursive.rb
(1.83 KB)
📄
spec_request.rb
(42.52 KB)
📄
spec_response.rb
(10.08 KB)
📄
spec_rewindable_input.rb
(2.78 KB)
📄
spec_runtime.rb
(1.53 KB)
📄
spec_sendfile.rb
(4.12 KB)
📄
spec_server.rb
(5.57 KB)
📄
spec_session_abstract_id.rb
(1.29 KB)
📄
spec_session_cookie.rb
(12.94 KB)
📄
spec_session_memcache.rb
(11.12 KB)
📄
spec_session_pool.rb
(6.53 KB)
📄
spec_showexceptions.rb
(2.01 KB)
📄
spec_showstatus.rb
(2.74 KB)
📄
spec_static.rb
(4.6 KB)
📄
spec_tempfile_reaper.rb
(1.57 KB)
📄
spec_thin.rb
(2.55 KB)
📄
spec_urlmap.rb
(8.82 KB)
📄
spec_utils.rb
(24.89 KB)
📄
spec_version.rb
(504 B)
📄
spec_webrick.rb
(5.5 KB)
ðŸ“
static
📄
testrequest.rb
(1.96 KB)
ðŸ“
unregistered_handler
Editing: spec_builder.rb
require 'rack/builder' require 'rack/lint' require 'rack/mock' require 'rack/showexceptions' require 'rack/urlmap' class NothingMiddleware def initialize(app) @app = app end def call(env) @@env = env response = @app.call(env) response end def self.env @@env end end describe Rack::Builder do def builder(&block) Rack::Lint.new Rack::Builder.new(&block) end def builder_to_app(&block) Rack::Lint.new Rack::Builder.new(&block).to_app end it "supports mapping" do app = builder_to_app do map '/' do |outer_env| run lambda { |inner_env| [200, {"Content-Type" => "text/plain"}, ['root']] } end map '/sub' do run lambda { |inner_env| [200, {"Content-Type" => "text/plain"}, ['sub']] } end end Rack::MockRequest.new(app).get("/").body.to_s.should.equal 'root' Rack::MockRequest.new(app).get("/sub").body.to_s.should.equal 'sub' end it "doesn't dupe env even when mapping" do app = builder_to_app do use NothingMiddleware map '/' do |outer_env| run lambda { |inner_env| inner_env['new_key'] = 'new_value' [200, {"Content-Type" => "text/plain"}, ['root']] } end end Rack::MockRequest.new(app).get("/").body.to_s.should.equal 'root' NothingMiddleware.env['new_key'].should.equal 'new_value' end it "chains apps by default" do app = builder_to_app do use Rack::ShowExceptions run lambda { |env| raise "bzzzt" } end Rack::MockRequest.new(app).get("/").should.be.server_error Rack::MockRequest.new(app).get("/").should.be.server_error Rack::MockRequest.new(app).get("/").should.be.server_error end it "has implicit #to_app" do app = builder do use Rack::ShowExceptions run lambda { |env| raise "bzzzt" } end Rack::MockRequest.new(app).get("/").should.be.server_error Rack::MockRequest.new(app).get("/").should.be.server_error Rack::MockRequest.new(app).get("/").should.be.server_error end it "supports blocks on use" do app = builder do use Rack::ShowExceptions use Rack::Auth::Basic do |username, password| 'secret' == password end run lambda { |env| [200, {"Content-Type" => "text/plain"}, ['Hi Boss']] } end response = Rack::MockRequest.new(app).get("/") response.should.be.client_error response.status.should.equal 401 # with auth... response = Rack::MockRequest.new(app).get("/", 'HTTP_AUTHORIZATION' => 'Basic ' + ["joe:secret"].pack("m*")) response.status.should.equal 200 response.body.to_s.should.equal 'Hi Boss' end it "has explicit #to_app" do app = builder do use Rack::ShowExceptions run lambda { |env| raise "bzzzt" } end Rack::MockRequest.new(app).get("/").should.be.server_error Rack::MockRequest.new(app).get("/").should.be.server_error Rack::MockRequest.new(app).get("/").should.be.server_error end it "can mix map and run for endpoints" do app = builder do map '/sub' do run lambda { |inner_env| [200, {"Content-Type" => "text/plain"}, ['sub']] } end run lambda { |inner_env| [200, {"Content-Type" => "text/plain"}, ['root']] } end Rack::MockRequest.new(app).get("/").body.to_s.should.equal 'root' Rack::MockRequest.new(app).get("/sub").body.to_s.should.equal 'sub' end it "accepts middleware-only map blocks" do app = builder do map('/foo') { use Rack::ShowExceptions } run lambda { |env| raise "bzzzt" } end proc { Rack::MockRequest.new(app).get("/") }.should.raise(RuntimeError) Rack::MockRequest.new(app).get("/foo").should.be.server_error end it "yields the generated app to a block for warmup" do warmed_up_app = nil app = Rack::Builder.new do warmup { |a| warmed_up_app = a } run lambda { |env| [200, {}, []] } end.to_app warmed_up_app.should.equal app end should "initialize apps once" do app = builder do class AppClass def initialize @called = 0 end def call(env) raise "bzzzt" if @called > 0 @called += 1 [200, {'Content-Type' => 'text/plain'}, ['OK']] end end use Rack::ShowExceptions run AppClass.new end Rack::MockRequest.new(app).get("/").status.should.equal 200 Rack::MockRequest.new(app).get("/").should.be.server_error end it "allows use after run" do app = builder do run lambda { |env| raise "bzzzt" } use Rack::ShowExceptions end Rack::MockRequest.new(app).get("/").should.be.server_error Rack::MockRequest.new(app).get("/").should.be.server_error Rack::MockRequest.new(app).get("/").should.be.server_error end it 'complains about a missing run' do proc do Rack::Lint.new Rack::Builder.app { use Rack::ShowExceptions } end.should.raise(RuntimeError) end describe "parse_file" do def config_file(name) File.join(File.dirname(__FILE__), 'builder', name) end it "parses commented options" do app, options = Rack::Builder.parse_file config_file('options.ru') options[:debug].should.be.true Rack::MockRequest.new(app).get("/").body.to_s.should.equal 'OK' end it "removes __END__ before evaluating app" do app, _ = Rack::Builder.parse_file config_file('end.ru') Rack::MockRequest.new(app).get("/").body.to_s.should.equal 'OK' end it "supports multi-line comments" do lambda { Rack::Builder.parse_file config_file('comment.ru') }.should.not.raise(SyntaxError) end it "requires anything not ending in .ru" do $: << File.dirname(__FILE__) app, * = Rack::Builder.parse_file 'builder/anything' Rack::MockRequest.new(app).get("/").body.to_s.should.equal 'OK' $:.pop end it "sets __LINE__ correctly" do app, _ = Rack::Builder.parse_file config_file('line.ru') Rack::MockRequest.new(app).get("/").body.to_s.should.equal '1' end end describe 'new_from_string' do it "builds a rack app from string" do app, = Rack::Builder.new_from_string "run lambda{|env| [200, {'Content-Type' => 'text/plane'}, ['OK']] }" Rack::MockRequest.new(app).get("/").body.to_s.should.equal 'OK' end end end
Upload File
Create Folder