useless 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. data/lib/useless.rb +11 -1
  2. data/lib/useless/rack.rb +18 -26
  3. data/lib/useless/rack/authentication/access_token.rb +39 -0
  4. data/lib/useless/rack/authentication/query_string.rb +19 -0
  5. data/lib/useless/rack/authentication/request_header.rb +19 -0
  6. data/lib/useless/rack/exceptions.rb +28 -0
  7. data/lib/useless/rack/files.rb +37 -0
  8. data/lib/useless/rack/fs.rb +17 -0
  9. data/lib/useless/rack/mongo.rb +16 -0
  10. data/lib/useless/version.rb +1 -1
  11. data/spec/spec_helper.rb +4 -3
  12. data/spec/useless/fs_spec.rb +1 -0
  13. data/spec/useless/mongo_spec.rb +1 -0
  14. data/spec/useless/rack/{middleware/authentication → authentication}/query_string_spec.rb +8 -7
  15. data/spec/useless/rack/{middleware/authentication → authentication}/request_header_spec.rb +8 -7
  16. data/spec/useless/rack/exceptions_spec.rb +31 -0
  17. data/spec/useless/rack/files_spec.rb +49 -0
  18. data/spec/useless/rack/fs_spec.rb +18 -0
  19. data/spec/useless/rack/mongo_spec.rb +18 -0
  20. data/spec/useless/rack_spec.rb +77 -0
  21. data/useless.gemspec +7 -7
  22. metadata +49 -50
  23. data/assets/DOC.html +0 -39
  24. data/assets/application.css +0 -134
  25. data/lib/useless/logger.rb +0 -48
  26. data/lib/useless/rack/base.rb +0 -26
  27. data/lib/useless/rack/base/files.rb +0 -33
  28. data/lib/useless/rack/middleware/assets.rb +0 -38
  29. data/lib/useless/rack/middleware/authentication/access_token.rb +0 -41
  30. data/lib/useless/rack/middleware/authentication/query_string.rb +0 -21
  31. data/lib/useless/rack/middleware/authentication/request_header.rb +0 -21
  32. data/lib/useless/rack/middleware/exceptions.rb +0 -41
  33. data/lib/useless/rack/middleware/fs.rb +0 -17
  34. data/lib/useless/rack/middleware/mongo.rb +0 -18
  35. data/spec/useless/logger_spec.rb +0 -87
  36. data/spec/useless/rack/base/files_spec.rb +0 -42
  37. data/spec/useless/rack/middleware/exceptions_spec.rb +0 -47
@@ -1,47 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper'
2
- require 'useless/rack/middleware/exceptions'
3
-
4
- describe Useless::Rack::Middleware::Exceptions do
5
- it 'should proxy transparently if nothing goes wrong in the main app' do
6
- main_app = lambda do |env|
7
- [200, {'Content-Type' => 'text/plain'}, ['No Problems!']]
8
- end
9
- exceptions_app = Useless::Rack::Middleware::Exceptions.new(main_app)
10
-
11
- res = Rack::MockRequest.new(exceptions_app).get('http://useless.info')
12
- res.should be_ok
13
- res.body.should == 'No Problems!'
14
- end
15
-
16
- def broken_app
17
- main_app = lambda do |env|
18
- raise 'It\'s all broken!'
19
- [200, {'Content-Type' => 'text/plain'}, ['No Problems!']]
20
- end
21
-
22
- Useless::Rack::Middleware::Exceptions.new(main_app)
23
- end
24
-
25
- it 'should return a 500 with a generic message if an exception is raised
26
- in the main app and the request is not authenticated' do
27
- res = Rack::MockRequest.new(broken_app).get('http://useless.info')
28
- res.status.should == 500
29
- res.body.should == 'An internal server error occurred. Please try again later.'
30
- end
31
-
32
- it 'should return a 500 with details of the exception if one is raised in
33
- the main app and the request is authenticated by an admin user' do
34
- res = Rack::MockRequest.new(broken_app).get('http://useless.info',
35
- 'useless.user' => {'handle' => 'khy', 'admin' => true})
36
- res.status.should == 500
37
- res.body.should =~ /^It's all broken!/
38
- end
39
-
40
- it 'should return a 500 with a generic message if an exception is raised
41
- in the main app and the request is authenticated by an non-admin user' do
42
- res = Rack::MockRequest.new(broken_app).get('http://useless.info',
43
- 'useless.user' => {'handle' => 'khy'})
44
- res.status.should == 500
45
- res.body.should == 'An internal server error occurred. Please try again later.'
46
- end
47
- end