ramaze 0.1.0 → 0.1.1

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 (195) hide show
  1. data/Rakefile +4 -12
  2. data/bin/ramaze +95 -171
  3. data/doc/CHANGELOG +387 -4
  4. data/doc/README +81 -13
  5. data/doc/meta/announcement.txt +51 -8
  6. data/doc/meta/configuration.txt +17 -34
  7. data/doc/meta/internals.txt +34 -4
  8. data/doc/migrate/1110_to_1111.txt +131 -0
  9. data/doc/readme_chunks/features.txt +81 -12
  10. data/doc/readme_chunks/installing.txt +0 -1
  11. data/doc/tutorial/todolist.html +293 -65
  12. data/doc/tutorial/{todolist.txt → todolist.mkd} +251 -51
  13. data/examples/blog/main.rb +1 -1
  14. data/examples/blog/src/model.rb +0 -1
  15. data/examples/hello.rb +2 -5
  16. data/examples/templates/template/external.haml +5 -5
  17. data/examples/templates/template/external.liquid +1 -1
  18. data/examples/templates/template/external.mab +8 -8
  19. data/examples/templates/template/external.rem +30 -0
  20. data/examples/templates/template/external.rhtml +6 -7
  21. data/examples/templates/template/external.zmr +13 -9
  22. data/examples/templates/template_amrita2.rb +8 -8
  23. data/examples/templates/template_erubis.rb +11 -11
  24. data/examples/templates/template_ezamar.rb +9 -11
  25. data/examples/templates/template_haml.rb +13 -13
  26. data/examples/templates/template_liquid.rb +10 -10
  27. data/examples/templates/template_markaby.rb +13 -10
  28. data/examples/templates/template_remarkably.rb +59 -0
  29. data/examples/todolist/main.rb +1 -7
  30. data/examples/todolist/src/controller/main.rb +26 -13
  31. data/examples/todolist/src/element/page.rb +5 -0
  32. data/examples/whywiki/main.rb +1 -1
  33. data/lib/proto/main.rb +0 -8
  34. data/lib/proto/public/css/ramaze_error.css +12 -4
  35. data/lib/proto/public/error.zmr +6 -25
  36. data/lib/ramaze.rb +35 -245
  37. data/lib/ramaze/action.rb +21 -0
  38. data/lib/ramaze/adapter.rb +94 -29
  39. data/lib/ramaze/adapter/base.rb +57 -0
  40. data/lib/ramaze/adapter/mongrel.rb +12 -19
  41. data/lib/ramaze/adapter/webrick.rb +21 -20
  42. data/lib/ramaze/cache.rb +47 -3
  43. data/lib/ramaze/cache/memcached.rb +22 -0
  44. data/lib/ramaze/cache/yaml_store.rb +19 -0
  45. data/lib/ramaze/controller.rb +47 -271
  46. data/lib/ramaze/controller/error.rb +43 -0
  47. data/lib/ramaze/controller/render.rb +90 -0
  48. data/lib/ramaze/controller/resolve.rb +147 -0
  49. data/lib/ramaze/dispatcher.rb +41 -9
  50. data/lib/ramaze/dispatcher/file.rb +1 -1
  51. data/lib/ramaze/global.rb +73 -158
  52. data/lib/ramaze/global/dsl.rb +29 -0
  53. data/lib/ramaze/global/globalstruct.rb +90 -0
  54. data/lib/ramaze/helper.rb +1 -1
  55. data/lib/ramaze/helper/aspect.rb +39 -179
  56. data/lib/ramaze/helper/cache.rb +8 -9
  57. data/lib/ramaze/helper/cgi.rb +23 -0
  58. data/lib/ramaze/helper/file.rb +3 -0
  59. data/lib/ramaze/helper/inform.rb +3 -0
  60. data/lib/ramaze/helper/link.rb +56 -63
  61. data/lib/ramaze/helper/nitroform.rb +4 -0
  62. data/lib/ramaze/helper/redirect.rb +1 -1
  63. data/lib/ramaze/inform.rb +6 -2
  64. data/lib/ramaze/inform/analogger.rb +5 -1
  65. data/lib/ramaze/inform/hub.rb +1 -1
  66. data/lib/ramaze/inform/informing.rb +7 -0
  67. data/lib/ramaze/snippets/kernel/aquire.rb +2 -0
  68. data/lib/ramaze/snippets/kernel/constant.rb +2 -0
  69. data/lib/ramaze/snippets/kernel/pretty_inspect.rb +2 -0
  70. data/lib/ramaze/snippets/object/traits.rb +4 -0
  71. data/lib/ramaze/snippets/openstruct/temp.rb +3 -0
  72. data/lib/ramaze/snippets/string/DIVIDE.rb +2 -0
  73. data/lib/ramaze/snippets/string/camel_case.rb +2 -0
  74. data/lib/ramaze/snippets/string/color.rb +2 -0
  75. data/lib/ramaze/snippets/string/each.rb +2 -0
  76. data/lib/ramaze/snippets/string/snake_case.rb +3 -0
  77. data/lib/ramaze/snippets/struct/fill.rb +8 -2
  78. data/lib/ramaze/snippets/struct/values_at.rb +16 -0
  79. data/lib/ramaze/snippets/symbol/to_proc.rb +3 -0
  80. data/lib/ramaze/sourcereload.rb +89 -0
  81. data/lib/ramaze/template.rb +21 -12
  82. data/lib/ramaze/template/amrita2.rb +6 -6
  83. data/lib/ramaze/template/erubis.rb +4 -9
  84. data/lib/ramaze/template/ezamar.rb +13 -57
  85. data/lib/ramaze/template/ezamar/element.rb +10 -12
  86. data/lib/ramaze/template/ezamar/engine.rb +40 -101
  87. data/lib/ramaze/template/ezamar/morpher.rb +3 -3
  88. data/lib/ramaze/template/haml.rb +3 -6
  89. data/lib/ramaze/template/liquid.rb +4 -9
  90. data/lib/ramaze/template/markaby.rb +16 -22
  91. data/lib/ramaze/template/remarkably.rb +28 -0
  92. data/lib/ramaze/tool/mime.rb +2 -0
  93. data/lib/ramaze/tool/record.rb +6 -0
  94. data/lib/ramaze/trinity/request.rb +44 -54
  95. data/lib/ramaze/trinity/response.rb +1 -1
  96. data/lib/ramaze/trinity/session.rb +15 -37
  97. data/lib/ramaze/version.rb +1 -1
  98. data/rake_tasks/gem.rake +2 -2
  99. data/rake_tasks/maintaince.rake +42 -1
  100. data/rake_tasks/spec.rake +45 -0
  101. data/spec/examples/caching.rb +1 -1
  102. data/spec/examples/simple.rb +1 -1
  103. data/spec/examples/templates/template_amrita2.rb +1 -0
  104. data/spec/examples/templates/template_erubis.rb +2 -1
  105. data/spec/examples/templates/template_ezamar.rb +1 -1
  106. data/spec/examples/templates/template_haml.rb +2 -1
  107. data/spec/examples/templates/template_liquid.rb +2 -1
  108. data/spec/examples/templates/template_markaby.rb +2 -1
  109. data/spec/examples/templates/template_remarkably.rb +22 -0
  110. data/spec/examples/todolist.rb +125 -0
  111. data/spec/helper.rb +2 -23
  112. data/spec/helper/minimal.rb +20 -0
  113. data/spec/helper/mock_http.rb +24 -30
  114. data/spec/helper/simple_http.rb +2 -2
  115. data/spec/helper/wrap.rb +6 -9
  116. data/spec/ramaze/adapter.rb +1 -1
  117. data/spec/ramaze/adapter/record.rb +31 -0
  118. data/spec/ramaze/cache.rb +41 -54
  119. data/spec/ramaze/controller.rb +121 -137
  120. data/spec/ramaze/controller/template/list.xhtml +1 -0
  121. data/spec/ramaze/controller/template/other/greet/other.xhtml +1 -0
  122. data/spec/ramaze/controller/template_resolving.rb +27 -3
  123. data/spec/ramaze/element.rb +11 -7
  124. data/spec/ramaze/error.rb +1 -1
  125. data/spec/ramaze/gestalt.rb +2 -0
  126. data/spec/ramaze/helper/aspect.rb +30 -21
  127. data/spec/ramaze/helper/auth.rb +1 -1
  128. data/spec/ramaze/helper/cache.rb +2 -1
  129. data/spec/ramaze/helper/form.rb +14 -11
  130. data/spec/ramaze/helper/link.rb +18 -41
  131. data/spec/ramaze/localize.rb +29 -2
  132. data/spec/ramaze/morpher.rb +23 -12
  133. data/spec/ramaze/params.rb +46 -24
  134. data/spec/ramaze/request.rb +6 -2
  135. data/spec/ramaze/store/yaml.rb +5 -0
  136. data/spec/ramaze/template.rb +22 -27
  137. data/spec/ramaze/template/amrita2.rb +1 -2
  138. data/spec/ramaze/template/erubis.rb +1 -1
  139. data/spec/ramaze/template/ezamar.rb +1 -2
  140. data/spec/ramaze/template/haml.rb +2 -2
  141. data/spec/ramaze/template/haml/with_vars.haml +1 -1
  142. data/spec/ramaze/template/liquid.rb +1 -1
  143. data/spec/ramaze/template/markaby.rb +1 -1
  144. data/spec/ramaze/template/remarkably.rb +56 -0
  145. data/spec/ramaze/template/remarkably/external.rem +8 -0
  146. data/spec/ramaze/template/remarkably/sum.rem +1 -0
  147. metadata +38 -63
  148. data/doc/README.html +0 -637
  149. data/doc/allison/LICENSE +0 -184
  150. data/doc/allison/README +0 -37
  151. data/doc/allison/allison.css +0 -299
  152. data/doc/allison/allison.gif +0 -0
  153. data/doc/allison/allison.js +0 -307
  154. data/doc/allison/allison.rb +0 -287
  155. data/doc/allison/cache/BODY +0 -588
  156. data/doc/allison/cache/CLASS_INDEX +0 -4
  157. data/doc/allison/cache/CLASS_PAGE +0 -1
  158. data/doc/allison/cache/FILE_INDEX +0 -4
  159. data/doc/allison/cache/FILE_PAGE +0 -1
  160. data/doc/allison/cache/FONTS +0 -1
  161. data/doc/allison/cache/FR_INDEX_BODY +0 -1
  162. data/doc/allison/cache/IMGPATH +0 -1
  163. data/doc/allison/cache/INDEX +0 -1
  164. data/doc/allison/cache/JAVASCRIPT +0 -307
  165. data/doc/allison/cache/METHOD_INDEX +0 -4
  166. data/doc/allison/cache/METHOD_LIST +0 -1
  167. data/doc/allison/cache/SRC_PAGE +0 -1
  168. data/doc/allison/cache/STYLE +0 -321
  169. data/doc/allison/cache/URL +0 -1
  170. data/doc/changes.txt +0 -3375
  171. data/doc/changes.xml +0 -3378
  172. data/examples/todolist/conf/benchmark.yaml +0 -35
  173. data/examples/todolist/conf/debug.yaml +0 -34
  174. data/examples/todolist/conf/live.yaml +0 -33
  175. data/examples/todolist/conf/silent.yaml +0 -31
  176. data/examples/todolist/conf/stage.yaml +0 -33
  177. data/examples/todolist/public/css/coderay.css +0 -105
  178. data/examples/todolist/public/css/ramaze_error.css +0 -42
  179. data/lib/proto/conf/benchmark.yaml +0 -21
  180. data/lib/proto/conf/debug.yaml +0 -21
  181. data/lib/proto/conf/live.yaml +0 -21
  182. data/lib/proto/conf/silent.yaml +0 -21
  183. data/lib/proto/conf/stage.yaml +0 -21
  184. data/lib/proto/public/css/coderay.css +0 -105
  185. data/lib/ramaze/http_status.rb +0 -66
  186. data/lib/ramaze/snippets/hash/keys_to_sym.rb +0 -19
  187. data/lib/ramaze/snippets/kernel/method.rb +0 -26
  188. data/lib/ramaze/snippets/method/name.rb +0 -22
  189. data/lib/ramaze/snippets/ramaze/autoreload.rb +0 -135
  190. data/lib/ramaze/snippets/rdoc/usage_no_exit.rb +0 -65
  191. data/spec/all.rb +0 -32
  192. data/spec/ramaze/conf/locale_de.yaml +0 -6
  193. data/spec/ramaze/conf/locale_en.yaml +0 -6
  194. data/spec/ramaze/dependencies.rb +0 -16
  195. data/spec/ramaze/global.rb +0 -44
@@ -6,7 +6,7 @@ describe 'Caching' do
6
6
  ramaze
7
7
 
8
8
  it '/' do
9
- n1 = 10_0000
9
+ n1 = 10_000
10
10
  n2 = 10_000
11
11
  result = n1 ** n2
12
12
  url = "/#{n1}/#{n2}"
@@ -16,7 +16,7 @@ describe 'Simple' do
16
16
 
17
17
  it '/simple' do
18
18
  @response = get('/simple')
19
- @response.body.should =~ /^#<Rack::Request/
19
+ @response.body.should =~ /^#<Ramaze::Request/
20
20
  end
21
21
 
22
22
  it '/join/foo/bar' do
@@ -1,5 +1,6 @@
1
1
  require 'spec/helper'
2
2
 
3
+ testcase_requires 'amrita2'
3
4
  require 'examples/templates/template_amrita2'
4
5
 
5
6
  describe 'Template Amrita2' do
@@ -1,5 +1,6 @@
1
1
  require 'spec/helper'
2
2
 
3
+ testcase_requires 'erubis'
3
4
  require 'examples/templates/template_erubis'
4
5
 
5
6
  describe 'Template Erubis' do
@@ -7,7 +8,7 @@ describe 'Template Erubis' do
7
8
 
8
9
  it '/' do
9
10
  get('/').body.strip.should ==
10
- "<a href=\"/\">index</a> | <a href=\"/internal\">internal</a> | <a href=\"/external\">external</a>"
11
+ "<a href=\"/\">Home</a> | <a href=\"/internal\">internal</a> | <a href=\"/external\">external</a>"
11
12
  end
12
13
 
13
14
  %w[/internal /external].each do |url|
@@ -7,7 +7,7 @@ describe 'Template Ezamar' do
7
7
 
8
8
  it '/' do
9
9
  get('/').body.should ==
10
- "<a href=\"/\">index</a> | <a href=\"/internal\">internal</a> | <a href=\"/external\">external</a>"
10
+ "<a href=\"/\">Home</a> | <a href=\"/internal\">internal</a> | <a href=\"/external\">external</a>"
11
11
  end
12
12
 
13
13
  %w[/internal /external].each do |url|
@@ -1,5 +1,6 @@
1
1
  require 'spec/helper'
2
2
 
3
+ testcase_requires 'haml'
3
4
  require 'examples/templates/template_haml'
4
5
 
5
6
  describe 'Template Haml' do
@@ -7,7 +8,7 @@ describe 'Template Haml' do
7
8
 
8
9
  it '/' do
9
10
  get('/').body.strip.should ==
10
- "<a href=\"/\">index</a> | <a href=\"/internal\">internal</a> | <a href=\"/external\">external</a>"
11
+ "<a href=\"/\">Home</a> | <a href=\"/internal\">internal</a> | <a href=\"/external\">external</a>"
11
12
  end
12
13
 
13
14
  %w[/internal /external].each do |url|
@@ -1,5 +1,6 @@
1
1
  require 'spec/helper'
2
2
 
3
+ testcase_requires 'liquid'
3
4
  require 'examples/templates/template_liquid'
4
5
 
5
6
  describe 'Template Liquid' do
@@ -7,7 +8,7 @@ describe 'Template Liquid' do
7
8
 
8
9
  it '/' do
9
10
  get('/').body.strip.should ==
10
- "<a href=\"/\">index</a> | <a href=\"/internal\">internal</a> | <a href=\"/external\">external</a>"
11
+ "<a href=\"/\">Home</a> | <a href=\"/internal\">internal</a> | <a href=\"/external\">external</a>"
11
12
  end
12
13
 
13
14
  %w[/internal /external].each do |url|
@@ -1,5 +1,6 @@
1
1
  require 'spec/helper'
2
2
 
3
+ testcase_requires 'markaby'
3
4
  require 'examples/templates/template_markaby'
4
5
 
5
6
  describe 'Template Markaby' do
@@ -7,7 +8,7 @@ describe 'Template Markaby' do
7
8
 
8
9
  it '/' do
9
10
  get('/').body.strip.should ==
10
- "<a href=\"/\">index</a> | <a href=\"/internal\">internal</a> | <a href=\"/external\">external</a>"
11
+ "<a href=\"/\">Home</a> | <a href=\"/internal\">internal</a> | <a href=\"/external\">external</a>"
11
12
  end
12
13
 
13
14
  %w[/internal /external].each do |url|
@@ -0,0 +1,22 @@
1
+ require 'spec/helper'
2
+
3
+ testcase_requires 'remarkably/engines/html'
4
+ require 'examples/templates/template_remarkably'
5
+
6
+ describe 'Template Remarkably' do
7
+ ramaze
8
+
9
+ it '/' do
10
+ get('/').body.strip.should ==
11
+ "<a href=\"/\">Home</a> | <a href=\"/internal\">internal</a> | <a href=\"/external\">external</a>"
12
+ end
13
+
14
+ %w[/internal /external].each do |url|
15
+ it url do
16
+ html = get(url).body
17
+ html.should_not == nil
18
+ html.should =~ %r{<title>Template::Remarkably (internal|external)</title>}
19
+ html.should =~ %r{<h1>The (internal|external) Template for Remarkably</h1>}
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,125 @@
1
+ require 'spec/helper'
2
+
3
+ testcase_requires 'hpricot'
4
+
5
+ $:.unshift 'examples/todolist'
6
+ require 'main'
7
+
8
+ # fix the paths to template and public for the spec
9
+ class MainController
10
+ template_root 'examples/todolist/template'
11
+ public_root 'examples/todolist/public'
12
+ end
13
+
14
+ describe 'todolist' do
15
+ def h_get(*args)
16
+ Hpricot(get(*args).body)
17
+ end
18
+
19
+ def task_titles
20
+ doc = h_get('/')
21
+ doc.search("td[@class='title']").
22
+ map{|t| t.inner_html.strip}.sort
23
+ end
24
+
25
+ def tasks
26
+ (h_get('/')/:tr)
27
+ end
28
+
29
+ def spectask
30
+ tasks.find do |task|
31
+ (task/:td).find do |td|
32
+ td['class'] == 'title' and
33
+ td.inner_html.strip == 'spectask'
34
+ end
35
+ end
36
+ end
37
+
38
+ def spectask_status
39
+ spectask.search("td[@class='status']").inner_html.strip
40
+ end
41
+
42
+ def error_on_page(url, response)
43
+ doc = h_get(url, :cookie => response.headers['Set-Cookie'])
44
+
45
+ error = doc.search("div[@class='error']")
46
+ error.inner_html.strip
47
+ end
48
+
49
+ it 'should start' do
50
+ ramaze :port => 7080
51
+ get('/').status.should == 200
52
+ end
53
+
54
+ it 'should have no empty mainpage' do
55
+ get('/').body.should_not be_nil
56
+ end
57
+
58
+ it 'should have two preset tasks' do
59
+ task_titles.should == %w[Laundry Wash\ dishes]
60
+ end
61
+
62
+ it 'should have a link to new tasks' do
63
+ doc = h_get('/')
64
+ link = (doc/:a).find{|a| a.inner_html == 'New Task'}
65
+ link['href'].should == '/new'
66
+ end
67
+
68
+ it 'should have a page to create new tasks' do
69
+ get('/new').body.should_not be_nil
70
+ end
71
+
72
+ it 'should have a form to create a tasks on the /new page' do
73
+ doc = h_get('/new')
74
+ form = doc.at :form
75
+ form.should_not be_nil
76
+ input = form.at(:input)
77
+ input['type'].should == 'text'
78
+ input['name'].should == 'title'
79
+ end
80
+
81
+ it 'should POST new task and redirect to /' do
82
+ result = post('/create', 'title' => 'spectask')
83
+ result.status.should == 303
84
+ end
85
+
86
+ it 'should show have the new task' do
87
+ task_titles.should include('spectask')
88
+ end
89
+
90
+ it 'should toggle the spectask' do
91
+ get('/close/spectask').status.should == 303
92
+ spectask.should_not be_nil
93
+ spectask_status.should == 'done'
94
+ get('/open/spectask').status.should == 303
95
+ spectask.should_not be_nil
96
+ spectask_status.should == 'not done'
97
+ end
98
+
99
+ it 'should raise on modifying a not existing task' do
100
+ %w[open close].each do |action|
101
+ response = get("/#{action}/nothere", :referrer => "/")
102
+ response.status.should == 303
103
+ response.original_headers['Location'].should == '/'
104
+ error_on_page('/', response).should == "No such Task: `nothere'"
105
+ end
106
+ end
107
+
108
+ it 'should delete the new task' do
109
+ get('/delete/spectask').status.should == 303
110
+ task_titles.should_not include('spectask')
111
+ end
112
+
113
+ it 'should not create empty tasks but show a subtle error message' do
114
+ response = post('/create', 'title' => '', :referrer => "/new")
115
+
116
+ response.status.should == 303
117
+ response.original_headers['Location'].should == '/new'
118
+
119
+ error_on_page('/new', response).should == 'Please enter a title'
120
+ end
121
+
122
+ after :all do
123
+ FileUtils.rm('todolist.db') rescue nil
124
+ end
125
+ end
@@ -1,27 +1,7 @@
1
1
  # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
- require 'timeout'
5
-
6
- $:.unshift File.join(File.dirname(File.expand_path(__FILE__)), '..', 'lib')
7
- $:.unshift '/home/manveru/prog/projects/rack/lib'
8
-
9
- # $VERBOSE = 1
10
- $context_runner = false
11
-
12
- require 'ramaze'
13
-
14
- begin
15
- require 'rubygems'
16
- rescue LoadError => ex
17
- end
18
-
19
- require 'spec'
20
- if Spec::VERSION::FULL_VERSION < "0.9.1 (r1880)"
21
- puts "please update rspec >= 0.9.1"
22
- exit 1
23
- end
24
-
4
+ require 'spec/helper/minimal'
25
5
  require 'spec/helper/mock_http'
26
6
  require 'spec/helper/simple_http'
27
7
  require 'spec/helper/requester'
@@ -43,14 +23,13 @@ end
43
23
 
44
24
  def ramaze_start hash = {}
45
25
  options = {
46
- :mode => :debug,
47
26
  :adapter => false,
48
27
  :run_loose => true,
49
28
  :error_page => false,
50
29
  :port => 7007,
51
30
  :host => '127.0.0.1',
52
31
  :force => true,
53
- :force_setup => true,
32
+ :origin => :spec,
54
33
  }.merge(hash)
55
34
 
56
35
  Ramaze.start(options)
@@ -0,0 +1,20 @@
1
+ require 'timeout'
2
+
3
+ base = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
4
+ $:.unshift base.gsub(/^#{Dir.pwd}/, '.')
5
+
6
+ # $VERBOSE = 1
7
+ $context_runner = false
8
+
9
+ require 'ramaze'
10
+
11
+ begin
12
+ require 'rubygems'
13
+ rescue LoadError => ex
14
+ end
15
+
16
+ require 'spec'
17
+ if Spec::VERSION::FULL_VERSION < "0.9.1 (r1880)"
18
+ puts "please update rspec >= 0.9.1"
19
+ exit 1
20
+ end
@@ -1,8 +1,10 @@
1
1
  require 'ramaze'
2
2
  require 'rack/mock'
3
3
 
4
- module Ramaze::Adapter
5
- class Fake < Ramaze::Adapter::Base
4
+ module Ramaze
5
+ module Adapter
6
+ class Fake < Base
7
+ end
6
8
  end
7
9
  end
8
10
 
@@ -16,34 +18,30 @@ module MockHTTP
16
18
  :port => 80
17
19
  )
18
20
 
19
- def get(path, query = {})
20
- uri = create_url(path, query)
21
- mock_request.get(uri, DEFAULTS)
22
- end
21
+ FISHING = {
22
+ :input => :input,
23
+ :referrer => 'HTTP_REFERER',
24
+ :referer => 'HTTP_REFERER',
25
+ :cookie => 'HTTP_COOKIE',
26
+ }
23
27
 
24
- def post(path, query = {})
25
- input = query.delete(:input)
26
- uri = create_url(path, query)
27
- if input
28
- mock_request.post(uri, DEFAULTS.merge(:input => input))
29
- else
30
- mock_request.post(uri, DEFAULTS)
31
- end
32
- end
28
+ MOCK_REQUEST = ::Rack::MockRequest.new(Ramaze::Adapter::Fake)
33
29
 
34
- def put(path, query = {})
35
- input = query.delete(:input)
36
- uri = create_url(path, query)
37
- if input
38
- mock_request.put(uri, DEFAULTS.merge(:input => input))
39
- else
40
- mock_request.put(uri, DEFAULTS)
41
- end
30
+ def get(*args) mock_request(:get, *args) end
31
+ def put(*args) mock_request(:put, *args) end
32
+ def post(*args) mock_request(:post, *args) end
33
+ def delete(*args) mock_request(:delete, *args) end
34
+
35
+ def mock_request(meth, path, query = {})
36
+ uri, options = process_request(path, query)
37
+ MOCK_REQUEST.send(meth, uri, DEFAULTS.merge(options))
42
38
  end
43
39
 
44
- def delete(path, query = {})
45
- uri = create_url(path, query)
46
- mock_request.delete(uri, DEFAULTS)
40
+ def process_request(path, query)
41
+ options = {}
42
+ FISHING.each{|key, value|
43
+ options[value] = query.delete(key)}
44
+ [create_url(path, query), options]
47
45
  end
48
46
 
49
47
  def create_url(path, query)
@@ -59,8 +57,4 @@ module MockHTTP
59
57
  s + [CGI::escape(key) + "=" + CGI::escape(value)]
60
58
  end.join('&')
61
59
  end
62
-
63
- def mock_request
64
- ::Rack::MockRequest.new(Ramaze::Adapter::Fake)
65
- end
66
60
  end
@@ -342,10 +342,10 @@ class SimpleHttp
342
342
  # add custom request headers.
343
343
 
344
344
  @request_headers.each {|key,value|
345
- request[key]=value;
345
+ request[key]=value
346
346
  }
347
347
 
348
- handle_response(request, http.request(request));
348
+ handle_response(request, http.request(request))
349
349
  end
350
350
 
351
351
  # internal
@@ -134,26 +134,23 @@ class SpecFile
134
134
  total = f[@passed + @failed] rescue nil
135
135
  failed, passed = f[@failed], f[@passed]
136
136
  color = :red
137
+ width = 22
137
138
 
138
139
  if total_failure?
139
- text = 'total failure'
140
+ text = 'total failure'.center(width)
140
141
  elsif failed?
141
- text = "#{total} specs - #{failed} failed"
142
+ text = "#{total} specs - #{failed} failed".rjust(width)
142
143
  if @stdout =~ /Usually you should not worry about this failure, just install the/
143
144
  lib = @stdout.scan(/^no such file to load -- (.*?)$/).flatten.first
144
- text = "needs #{lib}"
145
+ text = "needs #{lib}".center(width)
145
146
  @mark_passed = true
146
147
  end
147
148
  elsif (not @mark_passed) and succeeded?
148
149
  color = :green
149
- text = "#{total} specs - all passed"
150
+ text = "#{total} specs - all passed".rjust(width)
150
151
  end
151
152
 
152
- text.strip!
153
- text = (' ' + text + ' ').center(24)
154
- text = "[#{text}]"
155
-
156
- puts(text.send(color))
153
+ puts "[ #{text.send(color)} ]"
157
154
  end
158
155
 
159
156
  def long_summary
@@ -10,7 +10,7 @@ class TCAdapterController < Ramaze::Controller
10
10
  end
11
11
 
12
12
  describe "Adapter" do
13
- ramaze ramaze_options.merge( :port => '7007..7010', :mapping => {'/' => TCAdapterController} )
13
+ ramaze ramaze_options.merge( :port => 7007, :spawn => 10, :mapping => {'/' => TCAdapterController} )
14
14
 
15
15
  describe "multiple" do
16
16
  it "simple request" do