serverside 0.2.9 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/CHANGELOG +56 -0
  2. data/Rakefile +12 -52
  3. data/bin/serverside +1 -1
  4. data/lib/serverside/application.rb +2 -1
  5. data/lib/serverside/caching.rb +62 -50
  6. data/lib/serverside/controllers.rb +91 -0
  7. data/lib/serverside/core_ext.rb +6 -0
  8. data/lib/serverside/daemon.rb +25 -5
  9. data/lib/serverside/request.rb +17 -11
  10. data/lib/serverside/routing.rb +11 -10
  11. data/lib/serverside/server.rb +14 -6
  12. data/lib/serverside/static.rb +7 -18
  13. data/lib/serverside/template.rb +20 -12
  14. data/spec/caching_spec.rb +318 -0
  15. data/spec/cluster_spec.rb +140 -0
  16. data/{test/spec → spec}/connection_spec.rb +4 -4
  17. data/{test/spec/controller_spec.rb → spec/controllers_spec.rb} +15 -12
  18. data/{test/spec → spec}/core_ext_spec.rb +23 -18
  19. data/spec/daemon_spec.rb +99 -0
  20. data/{test/spec → spec}/request_spec.rb +45 -45
  21. data/spec/routing_spec.rb +240 -0
  22. data/spec/server_spec.rb +40 -0
  23. data/spec/static_spec.rb +279 -0
  24. data/spec/template_spec.rb +129 -0
  25. metadata +21 -35
  26. data/lib/serverside/controller.rb +0 -67
  27. data/test/functional/primitive_static_server_test.rb +0 -61
  28. data/test/functional/request_body_test.rb +0 -93
  29. data/test/functional/routing_server.rb +0 -14
  30. data/test/functional/routing_server_test.rb +0 -41
  31. data/test/functional/static_profile.rb +0 -17
  32. data/test/functional/static_rfuzz.rb +0 -31
  33. data/test/functional/static_server.rb +0 -7
  34. data/test/functional/static_server_test.rb +0 -31
  35. data/test/spec/caching_spec.rb +0 -139
  36. data/test/test_helper.rb +0 -2
  37. data/test/unit/cluster_test.rb +0 -129
  38. data/test/unit/connection_test.rb +0 -48
  39. data/test/unit/core_ext_test.rb +0 -46
  40. data/test/unit/daemon_test.rb +0 -75
  41. data/test/unit/request_test.rb +0 -278
  42. data/test/unit/routing_test.rb +0 -171
  43. data/test/unit/server_test.rb +0 -28
  44. data/test/unit/static_test.rb +0 -171
  45. data/test/unit/template_test.rb +0 -78
@@ -1,78 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
- require 'stringio'
3
- require 'fileutils'
4
-
5
- class ServerSide::Template
6
- def self.reset
7
- @@templates = {}
8
- end
9
-
10
- def self.templates
11
- @@templates
12
- end
13
- end
14
-
15
- class TemplateTest < Test::Unit::TestCase
16
- def test_set
17
- ServerSide::Template.reset
18
- assert_equal 0, ServerSide::Template.templates.size
19
- ServerSide::Template.set('sharon', 'Hello chilren!')
20
- assert_equal 1, ServerSide::Template.templates.size
21
- assert_equal ['sharon'], ServerSide::Template.templates.keys
22
- t = ServerSide::Template.templates['sharon']
23
- assert_kind_of Array, t
24
- assert_equal nil, t[0]
25
- assert_kind_of ERB, t[1]
26
- assert_equal 'Hello chilren!', t[1].result(binding)
27
-
28
- stamp = Time.now - 100
29
- ServerSide::Template.set('zohar', 'FSMV <%= wow %>', stamp)
30
- assert_equal 2, ServerSide::Template.templates.size
31
- assert_equal true, ServerSide::Template.templates.keys.include?('zohar')
32
- t = ServerSide::Template.templates['zohar']
33
- assert_kind_of Array, t
34
- assert_equal stamp, t[0]
35
- assert_kind_of ERB, t[1]
36
- wow = 'wow'
37
- assert_equal 'FSMV wow', t[1].result(binding)
38
- end
39
-
40
- def test_render
41
- ServerSide::Template.reset
42
- assert_raise(RuntimeError) {ServerSide::Template.render('sharon', binding)}
43
-
44
- ServerSide::Template.set('sharon', 'Hello <%= name %>!')
45
- name = 'world'
46
- assert_equal 'Hello world!', ServerSide::Template.render('sharon', binding)
47
- end
48
-
49
- FN = 'test.rhtml'
50
- HtmlTemplate = "<% cats.each do |name| %><li><%= name %></li><% end %>"
51
-
52
- def teardown
53
- FileUtils.rm(FN) if File.file?(FN)
54
- end
55
-
56
- def test_render_file
57
- FileUtils.rm(FN) if File.file?(FN)
58
- assert_raise(RuntimeError) {ServerSide::Template.render(FN, binding)}
59
-
60
- File.open(FN, 'w') {|f| f << HtmlTemplate}
61
- assert_raise(NoMethodError) {ServerSide::Template.render(FN, binding)}
62
-
63
- cats = %w{Ciconia Marie Tipa}
64
- s = ServerSide::Template.render(FN, binding)
65
- assert_equal "<li>Ciconia</li><li>Marie</li><li>Tipa</li>", s
66
-
67
- cats = []
68
- s = ServerSide::Template.render(FN, binding)
69
- assert_nil s.match('<li>')
70
-
71
- sleep 2
72
-
73
- cats = %w{Ciconia Marie Tipa}
74
- File.open(FN, 'w') {|f| f << "<%= cats.join(', ') %>"}
75
-
76
- assert_equal 'Ciconia, Marie, Tipa', ServerSide::Template.render(FN, binding)
77
- end
78
- end