ramaze 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +360 -0
- data/bin/ramaze +152 -0
- data/doc/CHANGELOG +2021 -0
- data/doc/COPYING +56 -0
- data/doc/COPYING.ja +51 -0
- data/doc/README +275 -0
- data/doc/TODO +33 -0
- data/doc/allison/LICENSE +184 -0
- data/doc/allison/README +37 -0
- data/doc/allison/allison.css +300 -0
- data/doc/allison/allison.gif +0 -0
- data/doc/allison/allison.js +307 -0
- data/doc/allison/allison.rb +287 -0
- data/doc/allison/cache/BODY +588 -0
- data/doc/allison/cache/CLASS_INDEX +4 -0
- data/doc/allison/cache/CLASS_PAGE +1 -0
- data/doc/allison/cache/FILE_INDEX +4 -0
- data/doc/allison/cache/FILE_PAGE +1 -0
- data/doc/allison/cache/FONTS +1 -0
- data/doc/allison/cache/FR_INDEX_BODY +1 -0
- data/doc/allison/cache/IMGPATH +1 -0
- data/doc/allison/cache/INDEX +1 -0
- data/doc/allison/cache/JAVASCRIPT +307 -0
- data/doc/allison/cache/METHOD_INDEX +4 -0
- data/doc/allison/cache/METHOD_LIST +1 -0
- data/doc/allison/cache/SRC_PAGE +1 -0
- data/doc/allison/cache/STYLE +322 -0
- data/doc/allison/cache/URL +1 -0
- data/examples/blog/main.rb +16 -0
- data/examples/blog/public/screen.css +106 -0
- data/examples/blog/src/controller.rb +50 -0
- data/examples/blog/src/element.rb +53 -0
- data/examples/blog/src/model.rb +29 -0
- data/examples/blog/template/edit.xhtml +6 -0
- data/examples/blog/template/index.xhtml +24 -0
- data/examples/blog/template/new.xhtml +5 -0
- data/examples/blog/template/view.xhtml +15 -0
- data/examples/blog/test/tc_entry.rb +18 -0
- data/examples/caching.rb +23 -0
- data/examples/element.rb +40 -0
- data/examples/hello.rb +23 -0
- data/examples/simple.rb +60 -0
- data/examples/templates/template/external.haml +21 -0
- data/examples/templates/template/external.liquid +28 -0
- data/examples/templates/template/external.mab +27 -0
- data/examples/templates/template/external.rhtml +29 -0
- data/examples/templates/template/external.rmze +24 -0
- data/examples/templates/template_erubis.rb +50 -0
- data/examples/templates/template_haml.rb +48 -0
- data/examples/templates/template_liquid.rb +64 -0
- data/examples/templates/template_markaby.rb +52 -0
- data/examples/templates/template_ramaze.rb +49 -0
- data/examples/whywiki/main.rb +56 -0
- data/examples/whywiki/template/edit.xhtml +14 -0
- data/examples/whywiki/template/show.xhtml +17 -0
- data/lib/proto/conf/benchmark.yaml +35 -0
- data/lib/proto/conf/debug.yaml +34 -0
- data/lib/proto/conf/live.yaml +33 -0
- data/lib/proto/conf/silent.yaml +31 -0
- data/lib/proto/conf/stage.yaml +33 -0
- data/lib/proto/main.rb +18 -0
- data/lib/proto/public/404.jpg +0 -0
- data/lib/proto/public/css/coderay.css +105 -0
- data/lib/proto/public/css/ramaze_error.css +42 -0
- data/lib/proto/public/error.xhtml +74 -0
- data/lib/proto/public/favicon.ico +0 -0
- data/lib/proto/public/js/jquery.js +1923 -0
- data/lib/proto/public/ramaze.png +0 -0
- data/lib/proto/src/controller/main.rb +7 -0
- data/lib/proto/src/element/page.rb +16 -0
- data/lib/proto/src/model.rb +5 -0
- data/lib/proto/template/index.xhtml +6 -0
- data/lib/ramaze.rb +317 -0
- data/lib/ramaze/adapter/mongrel.rb +111 -0
- data/lib/ramaze/adapter/webrick.rb +161 -0
- data/lib/ramaze/cache.rb +11 -0
- data/lib/ramaze/cache/memcached.rb +52 -0
- data/lib/ramaze/cache/memory.rb +6 -0
- data/lib/ramaze/cache/yaml_store.rb +37 -0
- data/lib/ramaze/controller.rb +10 -0
- data/lib/ramaze/dispatcher.rb +315 -0
- data/lib/ramaze/error.rb +11 -0
- data/lib/ramaze/gestalt.rb +108 -0
- data/lib/ramaze/global.rb +120 -0
- data/lib/ramaze/helper.rb +32 -0
- data/lib/ramaze/helper/aspect.rb +189 -0
- data/lib/ramaze/helper/auth.rb +120 -0
- data/lib/ramaze/helper/cache.rb +52 -0
- data/lib/ramaze/helper/feed.rb +135 -0
- data/lib/ramaze/helper/form.rb +204 -0
- data/lib/ramaze/helper/link.rb +80 -0
- data/lib/ramaze/helper/redirect.rb +48 -0
- data/lib/ramaze/helper/stack.rb +67 -0
- data/lib/ramaze/http_status.rb +66 -0
- data/lib/ramaze/inform.rb +166 -0
- data/lib/ramaze/snippets.rb +5 -0
- data/lib/ramaze/snippets/hash/keys_to_sym.rb +19 -0
- data/lib/ramaze/snippets/kernel/aquire.rb +22 -0
- data/lib/ramaze/snippets/kernel/autoreload.rb +79 -0
- data/lib/ramaze/snippets/kernel/caller_lines.rb +58 -0
- data/lib/ramaze/snippets/kernel/constant.rb +24 -0
- data/lib/ramaze/snippets/kernel/rescue_require.rb +12 -0
- data/lib/ramaze/snippets/kernel/self_method.rb +41 -0
- data/lib/ramaze/snippets/kernel/silently.rb +13 -0
- data/lib/ramaze/snippets/object/traits.rb +60 -0
- data/lib/ramaze/snippets/openstruct/temp.rb +10 -0
- data/lib/ramaze/snippets/string/DIVIDE.rb +16 -0
- data/lib/ramaze/snippets/string/camel_case.rb +14 -0
- data/lib/ramaze/snippets/string/snake_case.rb +12 -0
- data/lib/ramaze/snippets/symbol/to_proc.rb +14 -0
- data/lib/ramaze/snippets/thread/deadQUESTIONMARK.rb +11 -0
- data/lib/ramaze/store/default.rb +48 -0
- data/lib/ramaze/template.rb +102 -0
- data/lib/ramaze/template/amrita2.rb +40 -0
- data/lib/ramaze/template/erubis.rb +58 -0
- data/lib/ramaze/template/haml.rb +65 -0
- data/lib/ramaze/template/haml/actionview_stub.rb +20 -0
- data/lib/ramaze/template/liquid.rb +74 -0
- data/lib/ramaze/template/markaby.rb +68 -0
- data/lib/ramaze/template/ramaze.rb +177 -0
- data/lib/ramaze/template/ramaze/element.rb +166 -0
- data/lib/ramaze/template/ramaze/morpher.rb +156 -0
- data/lib/ramaze/tool/create.rb +70 -0
- data/lib/ramaze/tool/tidy.rb +71 -0
- data/lib/ramaze/trinity.rb +38 -0
- data/lib/ramaze/trinity/request.rb +244 -0
- data/lib/ramaze/trinity/response.rb +41 -0
- data/lib/ramaze/trinity/session.rb +129 -0
- data/lib/ramaze/version.rb +14 -0
- data/spec/spec_all.rb +73 -0
- data/spec/spec_helper.rb +215 -0
- data/spec/tc_adapter_mongrel.rb +24 -0
- data/spec/tc_adapter_webrick.rb +22 -0
- data/spec/tc_cache.rb +79 -0
- data/spec/tc_controller.rb +39 -0
- data/spec/tc_element.rb +100 -0
- data/spec/tc_error.rb +23 -0
- data/spec/tc_gestalt.rb +90 -0
- data/spec/tc_global.rb +46 -0
- data/spec/tc_helper_aspect.rb +65 -0
- data/spec/tc_helper_auth.rb +61 -0
- data/spec/tc_helper_cache.rb +81 -0
- data/spec/tc_helper_feed.rb +129 -0
- data/spec/tc_helper_form.rb +146 -0
- data/spec/tc_helper_link.rb +58 -0
- data/spec/tc_helper_redirect.rb +51 -0
- data/spec/tc_helper_stack.rb +55 -0
- data/spec/tc_morpher.rb +90 -0
- data/spec/tc_params.rb +84 -0
- data/spec/tc_request.rb +111 -0
- data/spec/tc_session.rb +56 -0
- data/spec/tc_store.rb +25 -0
- data/spec/tc_template_amrita2.rb +34 -0
- data/spec/tc_template_erubis.rb +41 -0
- data/spec/tc_template_haml.rb +44 -0
- data/spec/tc_template_liquid.rb +98 -0
- data/spec/tc_template_markaby.rb +74 -0
- data/spec/tc_template_ramaze.rb +54 -0
- data/spec/tc_tidy.rb +14 -0
- data/spec/template/amrita2/data.html +6 -0
- data/spec/template/amrita2/index.html +1 -0
- data/spec/template/amrita2/sum.html +1 -0
- data/spec/template/erubis/sum.rhtml +1 -0
- data/spec/template/haml/index.haml +5 -0
- data/spec/template/haml/with_vars.haml +4 -0
- data/spec/template/liquid/index.liquid +1 -0
- data/spec/template/liquid/products.liquid +45 -0
- data/spec/template/markaby/external.mab +8 -0
- data/spec/template/markaby/sum.mab +1 -0
- data/spec/template/ramaze/file_only.rmze +1 -0
- data/spec/template/ramaze/index.rmze +1 -0
- data/spec/template/ramaze/nested.rmze +1 -0
- data/spec/template/ramaze/sum.rmze +1 -0
- metadata +317 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
module Ramaze #:nodoc:
|
5
|
+
module Version #:nodoc:
|
6
|
+
MAJOR = 0
|
7
|
+
MINOR = 0
|
8
|
+
TINY = 6
|
9
|
+
|
10
|
+
STRING = [MAJOR, MINOR, TINY].join('.')
|
11
|
+
end
|
12
|
+
|
13
|
+
VERSION = Version::STRING
|
14
|
+
end
|
data/spec/spec_all.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'pp'
|
5
|
+
begin
|
6
|
+
require 'term/ansicolor'
|
7
|
+
class String
|
8
|
+
include Term::ANSIColor
|
9
|
+
end
|
10
|
+
rescue LoadError
|
11
|
+
class String
|
12
|
+
|
13
|
+
# this will be set in case term/ansicolor cannot be
|
14
|
+
# required, just makes colorless output
|
15
|
+
|
16
|
+
def red() self end
|
17
|
+
|
18
|
+
# this will be set in case term/ansicolor cannot be
|
19
|
+
# required, just makes colorless output
|
20
|
+
|
21
|
+
def green() self end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
$stdout.sync = true
|
26
|
+
|
27
|
+
specs = 0
|
28
|
+
failures = 0
|
29
|
+
problematic = {}
|
30
|
+
|
31
|
+
Dir['spec/**/tc_*.rb'].each do |test_case|
|
32
|
+
print "rspec #{test_case.ljust(48)} "
|
33
|
+
out = `ruby #{test_case}`
|
34
|
+
out.split("\n").each do |line|
|
35
|
+
if line =~ /(\d+) specifications?, (\d+) failures?/
|
36
|
+
s, f = $1.to_i, $2.to_i
|
37
|
+
|
38
|
+
specs += s
|
39
|
+
failures += f
|
40
|
+
|
41
|
+
message = "[#{s.to_s.rjust(3)} specs | "
|
42
|
+
|
43
|
+
if f.nonzero? or $?.exitstatus != 0
|
44
|
+
problematic[test_case] = out
|
45
|
+
message << "#{f.to_s.rjust(3)} failed ]"
|
46
|
+
puts message.red
|
47
|
+
else
|
48
|
+
message << "all passed ]"
|
49
|
+
puts message.green
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
puts "-" * 80
|
56
|
+
problematic.each do |key, value|
|
57
|
+
puts key.center(80)
|
58
|
+
puts "v" * 80
|
59
|
+
puts
|
60
|
+
puts value
|
61
|
+
puts "-" * 80
|
62
|
+
end
|
63
|
+
|
64
|
+
puts
|
65
|
+
puts "#{specs} specifications, #{failures} failures"
|
66
|
+
puts
|
67
|
+
|
68
|
+
unless (problems = problematic.keys.join(', ')).empty?
|
69
|
+
puts "These failed: #{problems}"
|
70
|
+
else
|
71
|
+
puts "No failing specifications, let's add some tests!"
|
72
|
+
end
|
73
|
+
puts
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,215 @@
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
$:.unshift File.join(File.dirname(File.expand_path(__FILE__)), '..', 'lib')
|
5
|
+
|
6
|
+
require 'ramaze'
|
7
|
+
|
8
|
+
begin
|
9
|
+
require 'rubygems'
|
10
|
+
rescue LoadError => ex
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'spec'
|
14
|
+
|
15
|
+
require 'timeout'
|
16
|
+
require 'open-uri'
|
17
|
+
require 'net/http'
|
18
|
+
|
19
|
+
# provides get/post methods for use inside your
|
20
|
+
# Spec::Runner
|
21
|
+
|
22
|
+
module StatelessContext
|
23
|
+
def raw_get url = ''
|
24
|
+
url = "http://localhost:#{Ramaze::Global.port}" + "/#{url}".squeeze('/')
|
25
|
+
Timeout.timeout(1) do
|
26
|
+
open(url)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# just GET an [url]
|
31
|
+
|
32
|
+
def get url = ''
|
33
|
+
raw_get(url).read.strip
|
34
|
+
end
|
35
|
+
|
36
|
+
# POST to an url the given params
|
37
|
+
|
38
|
+
def post url = '', params = {}
|
39
|
+
url = "http://localhost:#{Ramaze::Global.port}" + "/#{url}".squeeze('/')
|
40
|
+
uri = URI.parse(url)
|
41
|
+
Timeout.timeout(1) do
|
42
|
+
res = Net::HTTP.post_form(uri, params)
|
43
|
+
result = res.body.to_s.strip
|
44
|
+
#p res => result
|
45
|
+
result
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
include StatelessContext
|
51
|
+
|
52
|
+
# provides a convinient Context for your requests
|
53
|
+
# so you can simulate sessions and consecutive requests
|
54
|
+
|
55
|
+
class Context
|
56
|
+
attr_accessor :cookie
|
57
|
+
|
58
|
+
# initialize the context with an url to obtain your cookie
|
59
|
+
|
60
|
+
def initialize(url = '/', base = nil)
|
61
|
+
@base = base
|
62
|
+
@cookie_url = with_base(url)
|
63
|
+
@history = []
|
64
|
+
reset
|
65
|
+
end
|
66
|
+
|
67
|
+
# combines the url given with the @base given, sanitizes
|
68
|
+
# the result a bit.
|
69
|
+
|
70
|
+
def with_base(url = '/')
|
71
|
+
url = url.to_s.squeeze('/')
|
72
|
+
if @base
|
73
|
+
unless url[0...@base.size] == @base
|
74
|
+
url = [@base, url].join('/')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
url.strip.squeeze('/')
|
78
|
+
end
|
79
|
+
|
80
|
+
# reset your session
|
81
|
+
|
82
|
+
def reset(url = @cookie_url)
|
83
|
+
@cookie = obtain_cookie( with_base(url) )
|
84
|
+
end
|
85
|
+
|
86
|
+
# just get a cookie, doesn't reset your session
|
87
|
+
|
88
|
+
def obtain_cookie(url = @cookie_url)
|
89
|
+
open(url).meta['set-cookie']
|
90
|
+
end
|
91
|
+
|
92
|
+
# our custom little open, take into account parameters and
|
93
|
+
# the port the server is running on
|
94
|
+
# the parameters are used for the session but could use
|
95
|
+
# any headers you wanna use for the request
|
96
|
+
|
97
|
+
def open url, hash = {}
|
98
|
+
unless @history.empty?
|
99
|
+
hash = {'HTTP_REFERER' => @history.last}.merge(hash)
|
100
|
+
end
|
101
|
+
url = with_base(url)
|
102
|
+
uri = "http://localhost:#{Global.port}#{url}"
|
103
|
+
puts "GET: #{uri}"
|
104
|
+
result = Kernel.open(uri, hash)
|
105
|
+
@history << url
|
106
|
+
result
|
107
|
+
end
|
108
|
+
|
109
|
+
# use Context#open with our cookie
|
110
|
+
# you can pass any header you want with an hash
|
111
|
+
|
112
|
+
def get url = '', headers = {}
|
113
|
+
open(url, {'Set-Cookie' => @cookie}.merge(headers)).read
|
114
|
+
end
|
115
|
+
|
116
|
+
# Net::HTTP.post_form with the cookie
|
117
|
+
# params are for the POST-parameters
|
118
|
+
|
119
|
+
def post url_param = '', params = {}, limit = 10
|
120
|
+
raise "Too many redirections" if limit <= 0
|
121
|
+
|
122
|
+
params['Set-Cookie'] = @cookie
|
123
|
+
url = "http://localhost:#{Ramaze::Global.port}"
|
124
|
+
new = with_base("/#{url_param.gsub(url, '')}")
|
125
|
+
url << new
|
126
|
+
|
127
|
+
uri = URI.parse(url)
|
128
|
+
puts "POST: #{uri}"
|
129
|
+
res = Net::HTTP.post_form(uri, params)
|
130
|
+
@history << uri.path
|
131
|
+
|
132
|
+
case res
|
133
|
+
when Net::HTTPSuccess
|
134
|
+
result = res.body.to_s.strip
|
135
|
+
result
|
136
|
+
when Net::HTTPRedirection
|
137
|
+
post(res['location'], params, limit - 1)
|
138
|
+
else
|
139
|
+
res.error!
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
# like post, but seval the returned string
|
144
|
+
# very comfortable if you just do {'foo' => 'bar'}.inspect in your template
|
145
|
+
# and in your specs you can
|
146
|
+
# epost('/foo').should == {'foo' => 'bar'}
|
147
|
+
|
148
|
+
def epost opt = '', params = {}
|
149
|
+
seval(post(opt, params))
|
150
|
+
end
|
151
|
+
|
152
|
+
# like get, but seval the returned string
|
153
|
+
# very comfortable if you just do {'foo' => 'bar'}.inspect in your template
|
154
|
+
# and in your specs you can
|
155
|
+
# eget('/foo').should == {'foo' => 'bar'}
|
156
|
+
|
157
|
+
def eget opt = ''
|
158
|
+
seval(get(opt))
|
159
|
+
end
|
160
|
+
|
161
|
+
# a very simple wrapper for eval that returns the
|
162
|
+
# error-message instead of the result of the eval
|
163
|
+
# in case there are errors.
|
164
|
+
|
165
|
+
def seval(string)
|
166
|
+
eval(string)
|
167
|
+
rescue Object => ex
|
168
|
+
ex.message
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
module Spec::Runner::ContextEval::ModuleMethods
|
173
|
+
|
174
|
+
# start up ramaze with a given hash of options
|
175
|
+
# that will be merged with the default-options.
|
176
|
+
|
177
|
+
def ramaze_start hash = {}
|
178
|
+
options = {
|
179
|
+
:mode => :debug,
|
180
|
+
:adapter => :webrick,
|
181
|
+
:run_loose => true,
|
182
|
+
:error_page => false,
|
183
|
+
:port => 7007,
|
184
|
+
:host => '127.0.0.1',
|
185
|
+
:force => true,
|
186
|
+
:force_setup => true,
|
187
|
+
}.merge(hash)
|
188
|
+
|
189
|
+
Ramaze.start(options)
|
190
|
+
end
|
191
|
+
|
192
|
+
alias ramaze ramaze_start
|
193
|
+
|
194
|
+
# shutdown ramaze, this is not implemeted yet
|
195
|
+
# (and might never be due to limited possibilites)
|
196
|
+
|
197
|
+
def ramaze_teardown
|
198
|
+
#Ramaze.teardown
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
|
203
|
+
# require each of the following and rescue LoadError, telling you why it failed.
|
204
|
+
|
205
|
+
def testcase_requires(*following)
|
206
|
+
following.each do |file|
|
207
|
+
require(file.to_s)
|
208
|
+
end
|
209
|
+
rescue LoadError => ex
|
210
|
+
puts ex
|
211
|
+
puts "Can't run #{$0}: #{ex}"
|
212
|
+
puts "Usually you should not worry about this failure, just install the"
|
213
|
+
puts "library and try again (if you want to use that featureit later on)"
|
214
|
+
exit
|
215
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'spec/spec_helper'
|
5
|
+
|
6
|
+
testcase_requires 'mongrel'
|
7
|
+
|
8
|
+
include Ramaze
|
9
|
+
|
10
|
+
class TCAdapterController < Template::Ramaze
|
11
|
+
def index
|
12
|
+
"The index"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context "Mongrel" do
|
17
|
+
context "multiple" do
|
18
|
+
ramaze :mapping => {'/' => TCAdapterController}, :port => '7001..7003', :adapter => :mongrel
|
19
|
+
|
20
|
+
specify "simple request" do
|
21
|
+
get('/').should == "The index"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'spec/spec_helper'
|
5
|
+
|
6
|
+
include Ramaze
|
7
|
+
|
8
|
+
class TCAdapterController < Template::Ramaze
|
9
|
+
def index
|
10
|
+
"The index"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context "WEBrick" do
|
15
|
+
context "multiple" do
|
16
|
+
ramaze :mapping => {'/' => TCAdapterController}, :port => '7001..7003', :adapter => :webrick
|
17
|
+
|
18
|
+
specify "simple request" do
|
19
|
+
get('/').should == "The index"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/spec/tc_cache.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'spec/spec_helper'
|
5
|
+
|
6
|
+
include Ramaze
|
7
|
+
|
8
|
+
context "MemoryCache" do
|
9
|
+
cache = MemoryCache.new
|
10
|
+
|
11
|
+
specify "delete" do
|
12
|
+
cache.delete(:one)
|
13
|
+
cache.delete(:two)
|
14
|
+
end
|
15
|
+
|
16
|
+
specify "set keys" do
|
17
|
+
(cache[:one] = 'eins').should == "eins"
|
18
|
+
(cache[:two] = 'zwei').should == "zwei"
|
19
|
+
end
|
20
|
+
|
21
|
+
specify "read keys" do
|
22
|
+
cache[:one].should == 'eins'
|
23
|
+
cache[:two].should == 'zwei'
|
24
|
+
end
|
25
|
+
|
26
|
+
specify "values_at" do
|
27
|
+
cache.values_at(:one, :two).should == %w[eins zwei]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "YAMLStoreCache" do
|
32
|
+
cache = YAMLStoreCache.new
|
33
|
+
|
34
|
+
specify "delete" do
|
35
|
+
cache.delete(:one)
|
36
|
+
cache.delete(:two)
|
37
|
+
end
|
38
|
+
|
39
|
+
specify "set keys" do
|
40
|
+
(cache[:one] = 'eins').should == "eins"
|
41
|
+
(cache[:two] = 'zwei').should == "zwei"
|
42
|
+
end
|
43
|
+
|
44
|
+
specify "read keys" do
|
45
|
+
cache[:one].should == 'eins'
|
46
|
+
cache[:two].should == 'zwei'
|
47
|
+
end
|
48
|
+
|
49
|
+
specify "values_at" do
|
50
|
+
cache.values_at(:one, :two).should == %w[eins zwei]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
begin
|
55
|
+
context "MemcachedCache" do
|
56
|
+
cache = MemcachedCache.new
|
57
|
+
|
58
|
+
specify "delete" do
|
59
|
+
cache.delete(:one)
|
60
|
+
cache.delete(:two)
|
61
|
+
end
|
62
|
+
|
63
|
+
specify "set keys" do
|
64
|
+
(cache[:one] = 'eins').should == "eins"
|
65
|
+
(cache[:two] = 'zwei').should == "zwei"
|
66
|
+
end
|
67
|
+
|
68
|
+
specify "read keys" do
|
69
|
+
cache[:one].should == 'eins'
|
70
|
+
cache[:two].should == 'zwei'
|
71
|
+
end
|
72
|
+
|
73
|
+
specify "values_at" do
|
74
|
+
cache.values_at(:one, :two).should == %w[eins zwei]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
rescue LoadError
|
78
|
+
puts "cannot run test for memcached"
|
79
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'spec/spec_helper'
|
5
|
+
|
6
|
+
include Ramaze
|
7
|
+
|
8
|
+
class TCControllerRamazeController < Template::Ramaze
|
9
|
+
def index
|
10
|
+
"The index"
|
11
|
+
end
|
12
|
+
|
13
|
+
def sum first, second
|
14
|
+
first.to_i + second.to_i
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def test_private
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "Testing Ramaze" do
|
24
|
+
ramaze(:mapping => {'/ramaze' => TCControllerRamazeController})
|
25
|
+
|
26
|
+
specify "simple request to index" do
|
27
|
+
get('/ramaze').should == 'The index'
|
28
|
+
end
|
29
|
+
|
30
|
+
specify "summing two values" do
|
31
|
+
get('/ramaze/sum/1/2').should == '3'
|
32
|
+
end
|
33
|
+
|
34
|
+
specify "should not respond to private methods" do
|
35
|
+
%w[ session request response find_template handle_request trait test_private ].each do |action|
|
36
|
+
lambda{get("/ramaze/#{action}")}.should_raise OpenURI::HTTPError
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|