ramaze 2011.07.25 → 2011.10.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. data/.gitignore +3 -0
  2. data/.mailmap +3 -2
  3. data/.travis.yml +17 -0
  4. data/.yardopts +13 -0
  5. data/README.md +95 -352
  6. data/examples/app/blog/app.rb +25 -64
  7. data/examples/app/blog/config.ru +11 -9
  8. data/examples/app/blog/controller/init.rb +29 -86
  9. data/examples/app/blog/controller/posts.rb +232 -0
  10. data/examples/app/blog/controller/users.rb +160 -0
  11. data/examples/app/blog/layout/default.xhtml +61 -0
  12. data/examples/app/blog/migrations/01_create_schema.rb +50 -0
  13. data/examples/app/blog/model/comment.rb +41 -54
  14. data/examples/app/blog/model/init.rb +41 -13
  15. data/examples/app/blog/model/post.rb +35 -0
  16. data/examples/app/blog/model/user.rb +105 -0
  17. data/examples/app/blog/public/.htaccess +24 -0
  18. data/examples/app/blog/public/css/grid.css +107 -0
  19. data/examples/app/blog/public/css/layout.css +203 -0
  20. data/examples/app/blog/public/css/reset.css +123 -0
  21. data/examples/app/blog/public/css/text.css +109 -0
  22. data/examples/app/blog/public/dispatch.fcgi +11 -0
  23. data/examples/app/blog/public/favicon.ico +0 -0
  24. data/examples/app/blog/public/images/bg.png +0 -0
  25. data/examples/app/blog/start.rb +18 -3
  26. data/examples/app/blog/view/feed.xhtml +23 -0
  27. data/examples/app/blog/view/form.xhtml +11 -0
  28. data/examples/app/blog/view/index.xhtml +44 -0
  29. data/examples/app/blog/view/users/form.xhtml +12 -0
  30. data/examples/app/blog/view/users/index.xhtml +30 -0
  31. data/examples/app/blog/view/users/login.xhtml +8 -0
  32. data/examples/app/blog/view/view.xhtml +68 -0
  33. data/{doc → guide}/AUTHORS +5 -3
  34. data/{doc → guide}/CHANGELOG +428 -0
  35. data/{doc/GPL → guide/GPL_LICENSE} +0 -0
  36. data/{doc/COPYING → guide/RUBY_LICENSE} +3 -6
  37. data/guide/_static/logo.png +0 -0
  38. data/guide/_static/logo.svg +49 -0
  39. data/guide/_static/ramaze_console.png +0 -0
  40. data/guide/css/common.css +20 -0
  41. data/guide/general/cache.md +167 -0
  42. data/guide/general/configuration.md +168 -0
  43. data/guide/general/contributing.md +108 -0
  44. data/guide/general/controllers.md +115 -0
  45. data/guide/general/helpers.md +76 -0
  46. data/guide/general/installation.md +58 -0
  47. data/guide/general/logging.md +99 -0
  48. data/guide/general/middlewares.md +100 -0
  49. data/guide/general/models.md +78 -0
  50. data/guide/general/principles.md +53 -0
  51. data/guide/general/ramaze_command.md +155 -0
  52. data/guide/general/routes.md +81 -0
  53. data/guide/general/sessions.md +140 -0
  54. data/guide/general/special_thanks.md +67 -0
  55. data/guide/general/testing.md +61 -0
  56. data/guide/general/views.md +322 -0
  57. data/guide/tutorials/introduction.md +259 -0
  58. data/lib/proto/config.ru +1 -1
  59. data/lib/proto/public/favicon.ico +0 -0
  60. data/lib/proto/view/index.xhtml +7 -7
  61. data/lib/ramaze.rb +4 -4
  62. data/lib/ramaze/app.rb +11 -11
  63. data/lib/ramaze/app_graph.rb +2 -4
  64. data/lib/ramaze/bin/console.rb +3 -3
  65. data/lib/ramaze/bin/create.rb +2 -2
  66. data/lib/ramaze/bin/restart.rb +4 -4
  67. data/lib/ramaze/bin/runner.rb +5 -5
  68. data/lib/ramaze/bin/start.rb +19 -4
  69. data/lib/ramaze/bin/status.rb +3 -3
  70. data/lib/ramaze/bin/stop.rb +3 -3
  71. data/lib/ramaze/cache.rb +1 -0
  72. data/lib/ramaze/cache/lru.rb +8 -4
  73. data/lib/ramaze/cache/memcache.rb +32 -13
  74. data/lib/ramaze/cache/redis.rb +164 -0
  75. data/lib/ramaze/cache/sequel.rb +43 -28
  76. data/lib/ramaze/controller.rb +1 -2
  77. data/lib/ramaze/dependencies.rb +40 -3
  78. data/lib/ramaze/helper/bench.rb +26 -16
  79. data/lib/ramaze/helper/blue_form.rb +46 -73
  80. data/lib/ramaze/helper/cache.rb +10 -6
  81. data/lib/ramaze/helper/csrf.rb +35 -39
  82. data/lib/ramaze/helper/disqus.rb +5 -4
  83. data/lib/ramaze/helper/email.rb +35 -24
  84. data/lib/ramaze/helper/erector.rb +9 -13
  85. data/lib/ramaze/helper/flash.rb +7 -9
  86. data/lib/ramaze/helper/formatting.rb +194 -179
  87. data/lib/ramaze/helper/gravatar.rb +4 -8
  88. data/lib/ramaze/helper/identity.rb +3 -3
  89. data/lib/ramaze/helper/layout.rb +23 -8
  90. data/lib/ramaze/helper/markaby.rb +1 -1
  91. data/lib/ramaze/helper/paginate.rb +46 -39
  92. data/lib/ramaze/helper/request_accessor.rb +3 -1
  93. data/lib/ramaze/helper/simple_captcha.rb +18 -17
  94. data/lib/ramaze/helper/stack.rb +1 -1
  95. data/lib/ramaze/helper/tagz.rb +4 -2
  96. data/lib/ramaze/helper/upload.rb +523 -0
  97. data/lib/ramaze/helper/user.rb +4 -8
  98. data/lib/ramaze/helper/xhtml.rb +11 -15
  99. data/lib/ramaze/log.rb +9 -6
  100. data/lib/ramaze/log/rotatinginformer.rb +62 -27
  101. data/lib/ramaze/log/syslog.rb +20 -15
  102. data/lib/ramaze/log/xosd.rb +2 -1
  103. data/lib/ramaze/reloader.rb +2 -0
  104. data/lib/ramaze/request.rb +11 -10
  105. data/lib/ramaze/setup.rb +23 -6
  106. data/lib/ramaze/snippets/array/put_within.rb +3 -9
  107. data/lib/ramaze/snippets/binding/locals.rb +5 -10
  108. data/lib/ramaze/snippets/fiber.rb +1 -23
  109. data/lib/ramaze/snippets/kernel/pretty_inspect.rb +3 -6
  110. data/lib/ramaze/snippets/numeric/filesize_format.rb +3 -5
  111. data/lib/ramaze/snippets/numeric/time.rb +3 -7
  112. data/lib/ramaze/snippets/object/__dir__.rb +3 -7
  113. data/lib/ramaze/snippets/object/instance_variable_defined.rb +3 -6
  114. data/lib/ramaze/snippets/object/pretty.rb +3 -7
  115. data/lib/ramaze/snippets/object/scope.rb +7 -9
  116. data/lib/ramaze/snippets/proc/locals.rb +12 -12
  117. data/lib/ramaze/snippets/ramaze/acquire.rb +15 -14
  118. data/lib/ramaze/snippets/ramaze/deprecated.rb +1 -1
  119. data/lib/ramaze/snippets/ramaze/fiber.rb +1 -1
  120. data/lib/ramaze/snippets/ramaze/lru_hash.rb +2 -3
  121. data/lib/ramaze/snippets/ramaze/struct.rb +2 -4
  122. data/lib/ramaze/snippets/string/camel_case.rb +8 -10
  123. data/lib/ramaze/snippets/string/color.rb +3 -4
  124. data/lib/ramaze/snippets/string/end_with.rb +3 -6
  125. data/lib/ramaze/snippets/string/esc.rb +3 -8
  126. data/lib/ramaze/snippets/string/ord.rb +3 -8
  127. data/lib/ramaze/snippets/string/snake_case.rb +6 -9
  128. data/lib/ramaze/snippets/string/start_with.rb +3 -8
  129. data/lib/ramaze/snippets/string/unindent.rb +3 -6
  130. data/lib/ramaze/snippets/thread/into.rb +1 -3
  131. data/lib/ramaze/spec.rb +2 -31
  132. data/lib/ramaze/spec/bacon.rb +18 -2
  133. data/lib/ramaze/version.rb +1 -1
  134. data/lib/ramaze/view.rb +1 -1
  135. data/ramaze.gemspec +1 -1
  136. data/spec/helper.rb +2 -1
  137. data/spec/ramaze/bin/start.rb +16 -20
  138. data/spec/ramaze/cache/localmemcache.rb +4 -7
  139. data/spec/ramaze/cache/memcache.rb +3 -1
  140. data/spec/ramaze/cache/redis.rb +62 -0
  141. data/spec/ramaze/helper/blue_form.rb +33 -4
  142. data/spec/ramaze/helper/layout.rb +40 -7
  143. data/spec/ramaze/helper/upload.rb +149 -0
  144. data/spec/ramaze/helper/uploads/text_1.txt +1 -0
  145. data/spec/ramaze/helper/uploads/text_2.txt +1 -0
  146. data/spec/ramaze/log/growl.rb +4 -6
  147. data/spec/ramaze/log/syslog.rb +6 -0
  148. data/spec/ramaze/view/lokar.rb +5 -0
  149. data/spec/ramaze/view/nagoro.rb +5 -0
  150. data/tasks/authors.rake +1 -1
  151. data/tasks/bacon.rake +14 -5
  152. data/tasks/changelog.rake +1 -1
  153. data/tasks/yard.rake +12 -4
  154. metadata +277 -239
  155. data/doc/LEGAL +0 -26
  156. data/examples/app/blog/README +0 -3
  157. data/examples/app/blog/controller/comment.rb +0 -45
  158. data/examples/app/blog/controller/entry.rb +0 -85
  159. data/examples/app/blog/controller/main.rb +0 -20
  160. data/examples/app/blog/controller/tag.rb +0 -9
  161. data/examples/app/blog/layout/default.nag +0 -31
  162. data/examples/app/blog/model/entry.rb +0 -89
  163. data/examples/app/blog/model/tag.rb +0 -36
  164. data/examples/app/blog/public/css/screen.css +0 -273
  165. data/examples/app/blog/spec/blog.rb +0 -87
  166. data/examples/app/blog/view/comment/form.nag +0 -10
  167. data/examples/app/blog/view/comment/show.nag +0 -16
  168. data/examples/app/blog/view/entry/edit.nag +0 -14
  169. data/examples/app/blog/view/entry/feed.atom.nag +0 -8
  170. data/examples/app/blog/view/entry/feed.rss.nag +0 -7
  171. data/examples/app/blog/view/entry/index.nag +0 -7
  172. data/examples/app/blog/view/entry/new.nag +0 -13
  173. data/examples/app/blog/view/entry/show.nag +0 -36
  174. data/examples/app/blog/view/feed.atom.nag +0 -18
  175. data/examples/app/blog/view/feed.rss.nag +0 -25
  176. data/examples/app/blog/view/index.nag +0 -6
  177. data/examples/app/blog/view/tag/index.nag +0 -5
  178. data/lib/proto/public/ramaze.png +0 -0
  179. data/lib/ramaze/rest.rb +0 -36
  180. data/spec/ramaze/rest.rb +0 -28
  181. data/tasks/rcov.rake +0 -22
@@ -25,7 +25,6 @@ module Ramaze
25
25
  "\e[#{value}m" + self + "\e[0m"
26
26
  end
27
27
  end
28
- end
29
-
30
- end
31
- end
28
+ end # String
29
+ end # CoreExtensions
30
+ end # Ramaze
@@ -3,9 +3,7 @@
3
3
 
4
4
  module Ramaze
5
5
  module CoreExtensions
6
-
7
6
  # Extensions for String
8
-
9
7
  module String
10
8
  unless ''.respond_to?(:end_with?)
11
9
  # Compatibility with 1.9
@@ -14,7 +12,6 @@ module Ramaze
14
12
  self[-other.size, other.size] == other
15
13
  end
16
14
  end
17
- end
18
-
19
- end
20
- end
15
+ end # String
16
+ end # CoreExtensions
17
+ end # Ramaze
@@ -3,17 +3,13 @@ require 'uri'
3
3
 
4
4
  module Ramaze
5
5
  module CoreExtensions
6
-
7
6
  # Extensions for String
8
-
9
7
  module String
10
-
11
8
  # String#escape is an extensible escaping mechanism for string. currently
12
9
  # it suports
13
10
  # '<div>foo bar</div>'.esc(:html)
14
11
  # 'foo bar'.esc(:uri)
15
12
  # 'foo bar'.esc(:cgi)
16
-
17
13
  def escape which = :html
18
14
  case which
19
15
  when :html
@@ -28,7 +24,6 @@ module Ramaze
28
24
  end
29
25
 
30
26
  alias_method 'esc', 'escape'
31
- end
32
-
33
- end
34
- end
27
+ end # String
28
+ end # CoreExtensions
29
+ end # Ramaze
@@ -3,19 +3,14 @@
3
3
 
4
4
  module Ramaze
5
5
  module CoreExtensions
6
-
7
6
  # Extensions for String
8
-
9
7
  module String
10
8
  unless ''.respond_to?(:ord)
11
-
12
9
  # compatibility with Ruby 1.9
13
-
14
10
  def ord
15
11
  self[0]
16
12
  end
17
13
  end
18
- end
19
-
20
- end
21
- end
14
+ end # String
15
+ end # CoreExtensions
16
+ end # Ramaze
@@ -3,19 +3,16 @@
3
3
 
4
4
  module Ramaze
5
5
  module CoreExtensions
6
-
7
6
  # Extensions for String
8
-
9
7
  module String
10
-
11
8
  # convert to snake_case from CamelCase
12
9
  #
13
- # 'FooBar'.snake_case # => 'foo_bar'
14
-
10
+ # @example
11
+ # 'FooBar'.snake_case # => 'foo_bar'
12
+ #
15
13
  def snake_case
16
14
  gsub(/\B[A-Z][^A-Z]/, '_\&').downcase.gsub(' ', '_')
17
15
  end
18
- end
19
-
20
- end
21
- end
16
+ end # String
17
+ end # CoreExtensions
18
+ end # Ramaze
@@ -1,19 +1,14 @@
1
1
  module Ramaze
2
2
  module CoreExtensions
3
-
4
3
  # Extensions for String
5
-
6
4
  module String
7
-
8
5
  unless ''.respond_to?(:start_with?)
9
-
10
6
  # Compatibility with 1.9
11
-
12
7
  def start_with?(other)
13
8
  other = other.to_s
14
9
  self[0, other.size] == other
15
10
  end
16
11
  end
17
- end
18
- end
19
- end
12
+ end # String
13
+ end # CoreExtensions
14
+ end # Ramaze
@@ -1,10 +1,7 @@
1
1
  module Ramaze
2
2
  module CoreExtensions
3
-
4
3
  # Extensions for String
5
-
6
4
  module String
7
-
8
5
  # Useful for writing indented String and unindent on demand, based on the
9
6
  # first line with indentation.
10
7
  def unindent
@@ -23,6 +20,6 @@ module Ramaze
23
20
  self.replace unindent
24
21
  end
25
22
  alias ui! unindent!
26
- end
27
- end
28
- end
23
+ end # String
24
+ end # CoreExtensions
25
+ end # Ramaze
@@ -2,10 +2,8 @@
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
4
  # Extensions for Thread
5
-
6
5
  class Thread
7
6
  # Copy all thread variables into the new thread
8
-
9
7
  def self.into *args
10
8
  Thread.new(Thread.current, *args) do |thread, *args|
11
9
  thread.keys.each do |k|
@@ -15,4 +13,4 @@ class Thread
15
13
  yield(*args)
16
14
  end
17
15
  end
18
- end
16
+ end # Thread
@@ -1,33 +1,4 @@
1
1
  require File.expand_path('../', __FILE__) unless defined?(Ramaze)
2
2
 
3
- def spec_requires(*libs)
4
- spec_precondition 'require' do
5
- libs.each { |lib| require(lib) }
6
- end
7
- end
8
- alias spec_require spec_requires
9
-
10
- def spec_precondition(name)
11
- yield
12
- rescue LoadError => ex
13
- puts "Spec require: %p failed: %p" % [name, ex.message]
14
- exit 0
15
- rescue Exception => ex
16
- puts "Spec precondition: %p failed: %p" % [name, ex.message]
17
- exit 0
18
- end
19
-
20
- module Ramaze
21
- Mock::OPTIONS[:app] = Ramaze
22
-
23
- middleware!(:spec){|m| m.run(AppMap) }
24
- end
25
-
26
- # FIXME: will remove that in 2009.07, and then we can offer integration with
27
- # any other test-framework we like and they can share this code.
28
- # Then Ramaze can be:
29
- # Any ruby, any ORM, any templating-engine, any test-framework
30
- unless defined?(Bacon)
31
- Ramaze.deprecated "require('ramaze/spec')", "require('ramaze/spec/bacon')"
32
- require 'ramaze/spec/bacon'
33
- end
3
+ Ramaze.deprecated "require('ramaze/spec')", "require('ramaze/spec/bacon')"
4
+ require File.expand_path('../spec/bacon', __FILE__)
@@ -5,10 +5,26 @@ rescue LoadError
5
5
  require 'bacon'
6
6
  end
7
7
 
8
- require File.expand_path('../', __FILE__) unless defined?(Ramaze)
9
-
8
+ require File.expand_path('../../../ramaze', __FILE__)
10
9
  require 'innate/spec/bacon'
11
10
 
11
+ def spec_requires(*libs)
12
+ spec_precondition 'require' do
13
+ libs.each { |lib| require(lib) }
14
+ end
15
+ end
16
+ alias spec_require spec_requires
17
+
18
+ def spec_precondition(name)
19
+ yield
20
+ rescue LoadError => ex
21
+ puts "Spec require: %p failed: %p" % [name, ex.message]
22
+ exit 0
23
+ rescue Exception => ex
24
+ puts "Spec precondition: %p failed: %p" % [name, ex.message]
25
+ exit 0
26
+ end
27
+
12
28
  # minimal middleware, no exception handling
13
29
  Ramaze.middleware!(:spec) do |m|
14
30
  m.run(Ramaze::AppMap)
@@ -1,3 +1,3 @@
1
1
  module Ramaze
2
- VERSION = "2011.07.25"
2
+ VERSION = "2011.10.23"
3
3
  end
@@ -29,6 +29,6 @@ module Ramaze
29
29
  auto_register :Tagz, :tagz
30
30
  auto_register :Tenjin, :rbhtml, :tenjin
31
31
  auto_register :Slippers, :st
32
- auto_register :Mustache, :mt
32
+ auto_register :Mustache, :mustache, :mt
33
33
  end # View
34
34
  end # Ramaze
@@ -7,7 +7,7 @@ path = File.expand_path('../', __FILE__)
7
7
  Gem::Specification.new do |s|
8
8
  s.name = 'ramaze'
9
9
  s.version = Ramaze::VERSION
10
- s.date = '25-07-2011'
10
+ s.date = '2011-10-23'
11
11
  s.authors = ['Michael \'manveru\' Fellinger']
12
12
  s.email = 'm.fellinger@gmail.com'
13
13
  s.summary = 'Ramaze is a simple and modular web framework'
@@ -1,10 +1,11 @@
1
1
  if caller_line = caller.grep(%r!spec/ramaze/!).first
2
2
  caller_file = caller_line.split(':', 2).first
3
3
  caller_root = File.dirname(caller_file)
4
- $0 = caller_file
4
+ $0 = caller_file
5
5
  end
6
6
 
7
7
  require File.expand_path('../../lib/ramaze/spec/bacon', __FILE__)
8
+ require File.expand_path('../../lib/ramaze/dependencies', __FILE__)
8
9
 
9
10
  Ramaze.options.roots = [caller_root] if caller_root
10
11
 
@@ -1,9 +1,18 @@
1
1
  require File.expand_path('../../../../spec/helper', __FILE__)
2
2
  require __DIR__('../../../lib/ramaze/bin/runner')
3
- require 'open3'
4
3
 
5
- describe('Ramaze::Bin::Start') do
4
+ module Ramaze
5
+ module Bin
6
+ class Start
7
+ # Stub the method so that WEBrick doesn't have to be booted up.
8
+ def start_server(rackup_path, rackup_config, *params)
9
+ return true
10
+ end
11
+ end
12
+ end
13
+ end
6
14
 
15
+ describe('Ramaze::Bin::Start') do
7
16
  it('Should show a help message') do
8
17
  help = `#{Ramaze::BINPATH} start -h`.strip
9
18
 
@@ -11,28 +20,15 @@ describe('Ramaze::Bin::Start') do
11
20
  end
12
21
 
13
22
  it('Start using a directory') do
14
- output = ''
15
-
16
- Open3.popen3(Ramaze::BINPATH, 'start', Ramaze::BIN_APP) do |sin, sout, serr|
17
- output += serr.gets(100).strip
23
+ cmd = Ramaze::Bin::Start.new
18
24
 
19
- serr.close
20
- end
21
-
22
- output.should.match /INFO\s+WEBrick/
25
+ cmd.run([Ramaze::BIN_APP]).should == true
23
26
  end
24
27
 
25
28
  it('Start using a file') do
26
- output = ''
27
- path = File.join(Ramaze::BIN_APP, 'config.ru')
28
-
29
- Open3.popen3(Ramaze::BINPATH, 'start', path) do |sin, sout, serr|
30
- output += serr.gets(100).strip
29
+ path = File.join(Ramaze::BIN_APP, 'config.ru')
30
+ cmd = Ramaze::Bin::Start.new
31
31
 
32
- serr.close
33
- end
34
-
35
- output.should.match /INFO\s+WEBrick/
32
+ cmd.run([path]).should == true
36
33
  end
37
-
38
34
  end
@@ -3,15 +3,12 @@
3
3
 
4
4
  require File.expand_path('../../../../spec/helper', __FILE__)
5
5
 
6
- # Ignore this test on Mac OS X
7
- spec_precondition 'User isn\'t running Mac OS X' do
8
- if RUBY_PLATFORM.include? 'darwin'
9
- should.flunk "Localmemcache doesn't work on Mac OS X and thus this test will be ignored."
10
- else
11
- spec_require 'localmemcache'
12
- end
6
+ spec_precondition 'LocalMemcache should be supported' do
7
+ should.flunk if Ramaze::UNSUPPORTED_GEMS.include?('localmemcache')
13
8
  end
14
9
 
10
+ spec_require 'localmemcache'
11
+
15
12
  describe Ramaze::Cache::LocalMemCache do
16
13
  Ramaze.options.cache.names = [:one, :two]
17
14
  Ramaze.options.cache.default = Ramaze::Cache::LocalMemCache
@@ -2,7 +2,9 @@
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
4
  require File.expand_path('../../../../spec/helper', __FILE__)
5
- require 'dalli'
5
+ spec_require 'dalli'
6
+
7
+ Dalli.logger.level = Logger::ERROR
6
8
 
7
9
  spec_precondition 'memcached is running' do
8
10
  cache = Dalli::Client.new('localhost:11211')
@@ -0,0 +1,62 @@
1
+ # Copyright (c) 2011 Michael Fellinger m.fellinger@gmail.com
2
+ # All files in this distribution are subject to the terms of the Ruby license.
3
+
4
+ require File.expand_path('../../../../spec/helper', __FILE__)
5
+ spec_require 'redis'
6
+
7
+ spec_precondition 'redis is running' do
8
+ cache = Redis.new
9
+ cache['active'] = true
10
+ end
11
+
12
+ describe Ramaze::Cache::Redis do
13
+ Ramaze.options.cache.names = [:one, :two]
14
+ Ramaze.options.cache.default = Ramaze::Cache::Redis
15
+ Ramaze.setup_dependencies
16
+
17
+ cache = Ramaze::Cache.one
18
+ hello = 'Hello, World!'
19
+
20
+ should 'store without ttl' do
21
+ cache.store(:hello, hello).should == hello
22
+ end
23
+
24
+ should 'fetch' do
25
+ cache.fetch(:hello).should == hello
26
+ end
27
+
28
+ should 'delete' do
29
+ cache.delete(:hello)
30
+ cache.fetch(:hello).should == nil
31
+ end
32
+
33
+ should 'delete two key/value pairs at once' do
34
+ cache.store(:hello, hello).should == hello
35
+ cache.store(:ramaze, 'ramaze').should == 'ramaze'
36
+ cache.delete(:hello, :ramaze)
37
+ cache.fetch(:hello).should == nil
38
+ cache.fetch(:innate).should == nil
39
+ end
40
+
41
+ should 'store with ttl' do
42
+ cache.store(:hello, @hello, :ttl => 0.2)
43
+ cache.fetch(:hello).should == @hello
44
+ sleep 0.3
45
+ cache.fetch(:hello).should == nil
46
+ end
47
+
48
+ should 'clear' do
49
+ cache.store(:hello, @hello)
50
+ cache.fetch(:hello).should == @hello
51
+ cache.clear
52
+ cache.fetch(:hello).should == nil
53
+ end
54
+
55
+ should 'use a custom set of options' do
56
+ klass = Ramaze::Cache::Redis.using(:answer => 42)
57
+
58
+ klass.options[:answer].should == 42
59
+ klass.new.options[:answer].should == 42
60
+ end
61
+ end
62
+
@@ -1,7 +1,5 @@
1
- require File.expand_path('../../../../lib/ramaze/helper/blue_form', __FILE__)
2
-
3
- require 'bacon'
4
- Bacon.summary_at_exit
1
+ require File.expand_path('../../../../spec/helper', __FILE__)
2
+ require 'ramaze/helper/blue_form'
5
3
 
6
4
  describe BF = Ramaze::Helper::BlueForm do
7
5
  extend BF
@@ -251,6 +249,37 @@ describe BF = Ramaze::Helper::BlueForm do
251
249
  FORM
252
250
  end
253
251
 
252
+ it 'Make a form with input_checkbox and check multiple values using an array' do
253
+ out = form_for(@data, :method => :get) do |f|
254
+ f.input_checkbox 'Assigned', :assigned, ['boo'], :values => ['boo', 'foo']
255
+ end
256
+
257
+ assert(<<-FORM, out)
258
+ <form method="get">
259
+ <p>
260
+ <label for="form_assigned_0">Assigned</label>
261
+ <span class="checkbox_wrap"><input type="checkbox" name="assigned[]" id="form_assigned_0" checked="checked" value="boo" /> boo</span>
262
+ <span class="checkbox_wrap"><input type="checkbox" name="assigned[]" id="form_assigned_1" value="foo" /> foo</span>
263
+ </p>
264
+ </form>
265
+ FORM
266
+ end
267
+
268
+ it 'Make a form with input_checkbox and check multiple values using a hash' do
269
+ out = form_for(@data, :method => :get) do |f|
270
+ f.input_checkbox 'Assigned', :assigned, ['boo'], :values => {'Boo' => 'boo'}
271
+ end
272
+
273
+ assert(<<-FORM, out)
274
+ <form method="get">
275
+ <p>
276
+ <label for="form_assigned_0">Assigned</label>
277
+ <span class="checkbox_wrap"><input type="checkbox" name="assigned[]" id="form_assigned_0" checked="checked" value="boo" /> Boo</span>
278
+ </p>
279
+ </form>
280
+ FORM
281
+ end
282
+
254
283
  it 'Make a form with input_checkbox(label, name) but hide the value of the checkbox' do
255
284
  out = form_for(@data, :method => :get) do |f|
256
285
  f.input_checkbox 'Assigned', :assigned, nil, :show_value => false