ramaze 2009.05 → 2009.06

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. data/.gitignore +3 -0
  2. data/MANIFEST +11 -7
  3. data/README.md +3 -3
  4. data/Rakefile +17 -15
  5. data/bin/ramaze +7 -2
  6. data/doc/AUTHORS +6 -5
  7. data/doc/CHANGELOG +10057 -12259
  8. data/doc/meta/announcement.txt +93 -46
  9. data/doc/tutorial/todolist.html +22 -58
  10. data/doc/tutorial/todolist.txt +20 -39
  11. data/examples/app/wikore/src/model.rb +7 -1
  12. data/examples/app/wiktacular/template/html_layout.xhtml +1 -1
  13. data/lib/proto/config.ru +5 -1
  14. data/lib/ramaze/cache/localmemcache.rb +1 -1
  15. data/lib/ramaze/cache/memcache.rb +26 -1
  16. data/lib/ramaze/cache/sequel.rb +9 -6
  17. data/lib/ramaze/contrib/addressable_route.rb +55 -0
  18. data/lib/ramaze/contrib/facebook/facebook.rb +4 -4
  19. data/lib/ramaze/controller.rb +28 -18
  20. data/lib/ramaze/gestalt.rb +1 -1
  21. data/lib/ramaze/helper/auth.rb +0 -5
  22. data/lib/ramaze/helper/cache.rb +0 -9
  23. data/lib/ramaze/helper/form.rb +14 -2
  24. data/lib/ramaze/helper/formatting.rb +1 -1
  25. data/lib/ramaze/helper/layout.rb +97 -0
  26. data/lib/ramaze/helper/link.rb +6 -25
  27. data/lib/ramaze/helper/paginate.rb +2 -2
  28. data/lib/ramaze/helper/user.rb +3 -3
  29. data/lib/ramaze/helper.rb +1 -0
  30. data/lib/ramaze/setup.rb +22 -9
  31. data/lib/ramaze/spec/bacon.rb +34 -0
  32. data/lib/ramaze/spec/helper/template_examples.rb +13 -23
  33. data/lib/ramaze/spec.rb +8 -9
  34. data/lib/ramaze/tool/bin.rb +16 -6
  35. data/lib/ramaze/tool/project_creator.rb +1 -1
  36. data/lib/ramaze/version.rb +1 -1
  37. data/lib/ramaze.rb +8 -8
  38. data/lib/vendor/etag.rb +4 -2
  39. data/lib/vendor/route_exceptions.rb +6 -11
  40. data/ramaze.gemspec +52 -8
  41. data/spec/contrib/addressable_route.rb +32 -0
  42. data/spec/contrib/rest.rb +1 -1
  43. data/spec/examples/caching.rb +1 -1
  44. data/spec/examples/css.rb +1 -1
  45. data/spec/examples/element.rb +1 -1
  46. data/spec/examples/hello.rb +1 -1
  47. data/spec/examples/helpers/httpdigest.rb +1 -1
  48. data/spec/examples/linking.rb +1 -1
  49. data/spec/examples/simple.rb +1 -1
  50. data/spec/examples/templates/template_erubis.rb +3 -2
  51. data/spec/examples/templates/template_ezamar.rb +3 -2
  52. data/spec/examples/templates/template_haml.rb +3 -2
  53. data/spec/examples/templates/template_liquid.rb +3 -2
  54. data/spec/examples/templates/template_markaby.rb +5 -4
  55. data/spec/examples/templates/template_nagoro.rb +3 -3
  56. data/spec/examples/templates/template_redcloth.rb +3 -2
  57. data/spec/examples/templates/template_remarkably.rb +3 -2
  58. data/spec/examples/templates/template_tenjin.rb +3 -2
  59. data/spec/helper.rb +1 -2
  60. data/spec/ramaze/app.rb +1 -1
  61. data/spec/ramaze/bin/ramaze.rb +91 -0
  62. data/spec/ramaze/cache/memcache.rb +6 -0
  63. data/spec/ramaze/controller/actionless_templates.rb +1 -1
  64. data/spec/ramaze/controller/lonely_mapping.rb +16 -0
  65. data/spec/ramaze/controller/mapping.rb +0 -14
  66. data/spec/ramaze/controller/provide_inheritance.rb +1 -1
  67. data/spec/ramaze/controller/resolve.rb +1 -1
  68. data/spec/ramaze/controller/subclass.rb +1 -1
  69. data/spec/ramaze/controller/template_resolving.rb +1 -1
  70. data/spec/ramaze/dispatcher/directory.rb +1 -1
  71. data/spec/ramaze/dispatcher/file.rb +7 -7
  72. data/spec/ramaze/error.rb +2 -2
  73. data/spec/ramaze/files.rb +1 -1
  74. data/spec/ramaze/helper/auth.rb +1 -1
  75. data/spec/ramaze/helper/bench.rb +2 -1
  76. data/spec/ramaze/helper/cache.rb +1 -1
  77. data/spec/ramaze/helper/flash.rb +1 -1
  78. data/spec/ramaze/helper/form.rb +2 -2
  79. data/spec/ramaze/helper/httpdigest.rb +3 -3
  80. data/spec/ramaze/helper/layout/default.xhtml +5 -0
  81. data/spec/ramaze/helper/layout.rb +79 -0
  82. data/spec/ramaze/helper/link.rb +32 -11
  83. data/spec/ramaze/helper/localize.rb +1 -1
  84. data/spec/ramaze/helper/maruku.rb +1 -1
  85. data/spec/ramaze/helper/pager.rb +1 -1
  86. data/spec/ramaze/helper/paginate.rb +1 -1
  87. data/spec/ramaze/helper/request_accessor.rb +1 -1
  88. data/spec/ramaze/helper/sequel_form.rb +1 -1
  89. data/spec/ramaze/helper/simple_captcha.rb +1 -1
  90. data/spec/ramaze/helper/stack.rb +1 -1
  91. data/spec/ramaze/helper/user.rb +1 -1
  92. data/spec/ramaze/params.rb +4 -5
  93. data/spec/ramaze/session/memcache.rb +66 -0
  94. data/spec/ramaze/view/erubis.rb +1 -1
  95. data/spec/ramaze/view/ezamar.rb +1 -1
  96. data/spec/ramaze/view/gestalt.rb +1 -1
  97. data/spec/ramaze/view/haml.rb +1 -1
  98. data/spec/ramaze/view/liquid.rb +1 -1
  99. data/spec/ramaze/view/nagoro.rb +1 -1
  100. data/spec/ramaze/view/redcloth.rb +1 -1
  101. data/spec/ramaze/view/remarkably.rb +1 -1
  102. data/spec/ramaze/view/sass.rb +1 -1
  103. data/spec/ramaze/view/tagz.rb +1 -1
  104. data/spec/ramaze/view/tenjin.rb +1 -1
  105. data/spec/ramaze/view.rb +1 -1
  106. data/tasks/changelog.rake +3 -1
  107. data/tasks/{gem_installer.rake → gem_setup.rake} +45 -22
  108. data/tasks/release.rake +6 -4
  109. data/tasks/setup.rake +3 -21
  110. data/tasks/todo.rake +2 -4
  111. metadata +164 -10
  112. data/CHANGELOG +0 -16918
  113. data/doc/tutorial/todolist.mkd +0 -787
  114. data/lib/ramaze/snippets/divide.rb +0 -22
  115. data/lib/ramaze/snippets/object/acquire.rb +0 -37
  116. data/spec/snippets/kernel/constant.rb +0 -23
  117. data/tasks/install_dependencies.rake +0 -6
@@ -0,0 +1,32 @@
1
+ require 'spec/helper'
2
+ require 'ramaze/contrib/addressable_route'
3
+
4
+ class SpecAddressableRoute < Ramaze::Controller
5
+ map '/'
6
+
7
+ def order__show(*args)
8
+ [args, request.params].inspect
9
+ end
10
+ end
11
+
12
+ describe 'addressable routing' do
13
+ behaves_like :rack_test
14
+
15
+ RAR = Ramaze::AddressableRoute
16
+ RAR.map('/customer/{customer_id}/order/{order_id}', '/order/show')
17
+
18
+ Ramaze.middleware! :spec do |m|
19
+ m.use RAR
20
+ m.run Ramaze::AppMap
21
+ end
22
+
23
+ it 'should route based on URI template' do
24
+ body = eval(get('/customer/12/order/15').body)
25
+ body.should == [[], {'customer_id' => '12', 'order_id' => '15'}]
26
+ end
27
+
28
+ it "should not route URIs that don't match" do
29
+ get('/order/nothing/15')
30
+ last_response.status.should == 404
31
+ end
32
+ end
data/spec/contrib/rest.rb CHANGED
@@ -13,7 +13,7 @@ class Posts < Ramaze::Controller
13
13
  end
14
14
 
15
15
  describe 'Contrib REST rewrite' do
16
- behaves_like :mock
16
+ behaves_like :rack_test
17
17
 
18
18
  it('rewrites GET to show'){ get('/').body.should == 'Showing' }
19
19
  it('rewrites POST to create'){ post('/').body.should == 'Creating' }
@@ -2,7 +2,7 @@ require 'spec/helper'
2
2
  require 'examples/helpers/cache'
3
3
 
4
4
  describe 'Caching' do
5
- behaves_like :mock
5
+ behaves_like :rack_test
6
6
 
7
7
  it '/' do
8
8
  3.times do
data/spec/examples/css.rb CHANGED
@@ -3,7 +3,7 @@ spec_require 'haml'
3
3
  require 'examples/misc/css'
4
4
 
5
5
  describe 'CSSController' do
6
- behaves_like :mock
6
+ behaves_like :rack_test
7
7
 
8
8
  def req(path) r = get(path); [r.content_type, r.body] end
9
9
 
@@ -3,7 +3,7 @@ spec_require 'nagoro'
3
3
  require 'examples/basic/element'
4
4
 
5
5
  describe 'Element' do
6
- behaves_like :mock
6
+ behaves_like :rack_test
7
7
 
8
8
  it '/' do
9
9
  r = get('/').body
@@ -2,7 +2,7 @@ require 'spec/helper'
2
2
  require 'examples/basic/hello'
3
3
 
4
4
  describe 'Hello' do
5
- behaves_like :mock
5
+ behaves_like :rack_test
6
6
 
7
7
  it 'serves the index page' do
8
8
  get('/').body.should == 'Hello, World!'
@@ -11,7 +11,7 @@ require 'examples/helpers/httpdigest'
11
11
  # @digest_password before we make a request.
12
12
 
13
13
  describe Ramaze::Helper do
14
- behaves_like :mock
14
+ behaves_like :rack_test
15
15
 
16
16
  it 'authorizes request for /eyes_only' do
17
17
  digest_authorize nil, nil
@@ -2,7 +2,7 @@ require 'spec/helper'
2
2
  require 'examples/basic/linking'
3
3
 
4
4
  describe 'Linking' do
5
- behaves_like :mock
5
+ behaves_like :rack_test
6
6
 
7
7
  it 'should provide a link to help' do
8
8
  r = get('/').body
@@ -2,7 +2,7 @@ require 'spec/helper'
2
2
  require 'examples/basic/simple'
3
3
 
4
4
  describe 'Simple' do
5
- behaves_like :mock
5
+ behaves_like :rack_test
6
6
 
7
7
  def check(url)
8
8
  response = get(url)
@@ -4,6 +4,7 @@ require 'ramaze/spec/helper/template_examples'
4
4
  spec_require 'erubis'
5
5
  require 'examples/templates/template_erubis'
6
6
 
7
- describe 'Template Erubis' do |describe|
8
- ::Ramaze::Spec::Examples::Templates.tests( describe, 'Erubis' )
7
+ describe 'Template Erubis' do
8
+ behaves_like :template_spec
9
+ spec_template 'Erubis'
9
10
  end
@@ -4,6 +4,7 @@ require 'ramaze/spec/helper/template_examples'
4
4
  spec_require 'ezamar'
5
5
  require 'examples/templates/template_ezamar'
6
6
 
7
- describe 'Template Ezamar' do |describe|
8
- ::Ramaze::Spec::Examples::Templates.tests( describe, 'Ezamar' )
7
+ describe 'Template Ezamar' do
8
+ behaves_like :template_spec
9
+ spec_template 'Ezamar'
9
10
  end
@@ -4,6 +4,7 @@ require 'ramaze/spec/helper/template_examples'
4
4
  spec_require 'haml'
5
5
  require 'examples/templates/template_haml'
6
6
 
7
- describe 'Template Haml' do |describe|
8
- ::Ramaze::Spec::Examples::Templates.tests( describe, 'Haml' )
7
+ describe 'Template Haml' do
8
+ behaves_like :template_spec
9
+ spec_template 'Haml'
9
10
  end
@@ -4,6 +4,7 @@ require 'ramaze/spec/helper/template_examples'
4
4
  spec_require 'liquid'
5
5
  require 'examples/templates/template_liquid'
6
6
 
7
- describe 'Template Liquid' do |describe|
8
- ::Ramaze::Spec::Examples::Templates.tests( describe, 'Liquid' )
7
+ describe 'Template Liquid' do
8
+ behaves_like :template_spec
9
+ spec_template 'Liquid'
9
10
  end
@@ -1,10 +1,11 @@
1
1
  require 'spec/helper'
2
2
  require 'ramaze/spec/helper/template_examples'
3
3
 
4
- #spec_require 'markaby'
5
- #require 'examples/templates/template_markaby'
4
+ # spec_require 'markaby'
5
+ # require 'examples/templates/template_markaby'
6
6
 
7
- describe 'Template Markaby' do |describe|
8
- #::Ramaze::Spec::Examples::Templates.tests( describe, 'Markaby' )
7
+ describe 'Template Markaby' do
8
+ # behaves_like :template_spec
9
+ # spec_template 'Markaby'
9
10
  it("isn't yet implemented"){ should.flunk('needed Ramaze::View::Markaby') }
10
11
  end
@@ -4,7 +4,7 @@ require 'ramaze/spec/helper/template_examples'
4
4
  spec_require 'nagoro'
5
5
  require 'examples/templates/template_nagoro'
6
6
 
7
- describe 'Template Nagoro' do |describe|
8
- ::Ramaze::Spec::Examples::Templates.tests( describe, 'Nagoro' )
7
+ describe 'Template Nagoro' do
8
+ behaves_like :template_spec
9
+ spec_template 'Nagoro'
9
10
  end
10
-
@@ -4,6 +4,7 @@ require 'ramaze/spec/helper/template_examples'
4
4
  spec_require 'redcloth'
5
5
  spec_require 'examples/templates/template_redcloth'
6
6
 
7
- describe 'Template RedCloth' do |describe|
8
- ::Ramaze::Spec::Examples::Templates.tests( describe, 'RedCloth' )
7
+ describe 'Template RedCloth' do
8
+ behaves_like :template_spec
9
+ spec_template 'RedCloth'
9
10
  end
@@ -4,6 +4,7 @@ require 'ramaze/spec/helper/template_examples'
4
4
  spec_require 'remarkably/engines/html'
5
5
  require 'examples/templates/template_remarkably'
6
6
 
7
- describe 'Template Remarkably' do |describe|
8
- ::Ramaze::Spec::Examples::Templates.tests( describe, 'Remarkably' )
7
+ describe 'Template Remarkably' do
8
+ behaves_like :template_spec
9
+ spec_template 'Remarkably'
9
10
  end
@@ -4,6 +4,7 @@ require 'ramaze/spec/helper/template_examples'
4
4
  spec_require 'tenjin'
5
5
  require 'examples/templates/template_tenjin'
6
6
 
7
- describe 'Template Tenjin' do |describe|
8
- ::Ramaze::Spec::Examples::Templates.tests( describe, 'Tenjin' )
7
+ describe 'Template Tenjin' do
8
+ behaves_like :template_spec
9
+ spec_template 'Tenjin'
9
10
  end
data/spec/helper.rb CHANGED
@@ -4,7 +4,6 @@ if caller_line = caller.grep(%r!spec/ramaze/!).first
4
4
  $0 = caller_file
5
5
  end
6
6
 
7
- require File.expand_path(File.join(File.dirname(__FILE__), "../lib/ramaze"))
8
- require 'ramaze/spec'
7
+ require File.expand_path('../../lib/ramaze/spec/bacon', __FILE__)
9
8
 
10
9
  Ramaze.options.roots = [caller_root] if caller_root
data/spec/ramaze/app.rb CHANGED
@@ -36,7 +36,7 @@ Ramaze::App[:core].location = '/'
36
36
  Ramaze::App[:other].location = '/other'
37
37
 
38
38
  describe Ramaze::App do
39
- behaves_like :mock
39
+ behaves_like :rack_test
40
40
 
41
41
  it 'handles call with rack env' do
42
42
  get('/').body.should == 'core main'
@@ -0,0 +1,91 @@
1
+ require "spec/helper"
2
+ require "ramaze/tool/bin"
3
+ require "pathname"
4
+ module Ramaze
5
+ BINPATH = Pathname.new(Ramaze::ROOT).join("..", "bin", "ramaze").expand_path
6
+ end
7
+
8
+ USAGE = <<TXT
9
+
10
+ Usage:
11
+ ramaze <start [PIDFILE]|stop [PIDFILE]|restart [PIDFILE]|status [PIDFILE]|create PROJECT|console> [ruby/rack options]
12
+
13
+ Commands:
14
+
15
+ * All commands which take an optional PIDFILE (defaults to PROJECT.pid otherwise).
16
+ * All commands which start a ramaze instance will default to webrick on port 7000
17
+ unless you supply the rack options -p/--port PORT and/or * -s/--server SERVER.
18
+
19
+ start - Starts an instance of this application.
20
+
21
+ stop - Stops a running instance of this application.
22
+
23
+ restart - Stops running instance of this application, then starts it back up. Pidfile
24
+ (if supplied) is used for both stop and start.
25
+
26
+ status - Gives status of a running ramaze instance
27
+
28
+ create - Creates a new prototype Ramaze application in a directory named PROJECT in
29
+ the current directory. ramaze create foo would make ./foo containing an
30
+ application prototype. Rack options are ignored here.
31
+
32
+ console - Starts an irb console with app.rb (and irb completion) loaded. This command
33
+ ignores rack options, ARGV is passed on to IRB.
34
+
35
+
36
+ Ruby options:
37
+ -e, --eval LINE evaluate a LINE of code
38
+ -d, --debug set debugging flags (set $DEBUG to true)
39
+ -w, --warn turn warnings on for your script
40
+ -I, --include PATH specify $LOAD_PATH (may be used more than once)
41
+ -r, --require LIBRARY require the library, before executing your script
42
+
43
+ Rack options:
44
+ -s, --server SERVER serve using SERVER (webrick/mongrel)
45
+ -o, --host HOST listen on HOST (default: 0.0.0.0)
46
+ -p, --port PORT use PORT (default: 9292)
47
+ -E, --env ENVIRONMENT use ENVIRONMENT for defaults (default: development)
48
+ -D, --daemonize run daemonized in the background
49
+ -P, --pid FILE file to store PID (default: rack.pid)
50
+
51
+ Common options:
52
+ -h, --help Show this message
53
+ --version Show version
54
+ TXT
55
+
56
+ describe "bin/ramaze command" do
57
+ it "Can find the ramaze binary" do
58
+ Ramaze::BINPATH.file?.should == true
59
+ end
60
+
61
+ it "Shows command line help" do
62
+ output = `#{Ramaze::BINPATH} -h`
63
+ output.should == USAGE
64
+ end
65
+
66
+ it "Shows the correct version" do
67
+ output = %x{#{Ramaze::BINPATH} --version}
68
+ output.strip.should == Ramaze::VERSION
69
+ end
70
+
71
+ it "Can create a new tree from prototype" do
72
+ require "fileutils"
73
+ root = Pathname.new("/tmp/test_tree")
74
+ raise "#{root} already exists, please move it out of the way before running this test" if root.directory?
75
+ begin
76
+ output = %x{#{Ramaze::BINPATH} create #{root}}
77
+ root.directory?.should.be.true
78
+ root.join("config.ru").file?.should.be.true
79
+ root.join("start.rb").file?.should.be.true
80
+ root.join("controller").directory?.should.be.true
81
+ root.join("controller", "init.rb").file?.should.be.true
82
+ root.join("view").directory?.should.be.true
83
+ root.join("model").directory?.should.be.true
84
+ root.join("model", "init.rb").file?.should.be.true
85
+ ensure
86
+ FileUtils.rm_rf(root)
87
+ end
88
+ end
89
+
90
+ end
91
+
@@ -45,6 +45,12 @@ describe Ramaze::Cache::MemCache do
45
45
  cache.fetch(:hello).should == nil
46
46
  end
47
47
 
48
+ should 'amend the ttl if it is too high' do
49
+ ttl = Ramaze::Cache::MemCache::MAX_TTL + 1
50
+ cache.store(:hello, @hello, :ttl => ttl)
51
+ cache.fetch(:hello).should == @hello
52
+ end
53
+
48
54
  should 'clear' do
49
55
  cache.store(:hello, @hello)
50
56
  cache.fetch(:hello).should == @hello
@@ -23,7 +23,7 @@ class SpecActionlessTemplatesLayout < Ramaze::Controller
23
23
  end
24
24
 
25
25
  describe "Testing Actionless Templates" do
26
- behaves_like :mock
26
+ behaves_like :rack_test
27
27
 
28
28
  it "should not find template file for non existant method" do
29
29
  get('/list').status.should == 404
@@ -0,0 +1,16 @@
1
+ require 'spec/helper'
2
+
3
+
4
+ class SpecHello < Ramaze::Controller
5
+ def index
6
+ 'automatically mapped'
7
+ end
8
+ end
9
+
10
+ describe 'Lonely Controller automap' do
11
+ behaves_like :rack_test
12
+
13
+ it 'automatically creates an app and maps the controller into it' do
14
+ get('/').body.should == 'automatically mapped'
15
+ end
16
+ end
@@ -41,17 +41,3 @@ describe 'Controller::generate_mapping' do
41
41
  gen(Class.new.name).should == nil
42
42
  end
43
43
  end
44
-
45
- class SpecControllerMapping < Ramaze::Controller
46
- def index
47
- 'automatically mapped'
48
- end
49
- end
50
-
51
- describe 'Controller automap' do
52
- behaves_like :mock
53
-
54
- it 'automatically creates an app and maps the controller into it' do
55
- get('/spec_controller_mapping').body.should == 'automatically mapped'
56
- end
57
- end
@@ -25,7 +25,7 @@ class SpecControllerInheritedYetAnother < SpecControllerInheritedAnother
25
25
  end
26
26
 
27
27
  describe 'Ramaze::Controller#self.inherited' do
28
- behaves_like :mock
28
+ behaves_like :rack_test
29
29
 
30
30
  should 'default renders nagoro' do
31
31
  get('/').body.should == "<p>Main is nagoro</p>"
@@ -13,7 +13,7 @@ class MainController < Ramaze::Controller
13
13
  end
14
14
 
15
15
  describe 'Controller resolving' do
16
- behaves_like :mock
16
+ behaves_like :rack_test
17
17
 
18
18
  it 'should work with .' do
19
19
  get('/file.ext').body.should == 'file.ext'
@@ -14,7 +14,7 @@ class MainController < BaseController
14
14
  end
15
15
 
16
16
  describe 'Controller' do
17
- behaves_like :mock
17
+ behaves_like :rack_test
18
18
 
19
19
  it 'allows sub-classing MainController' do
20
20
  get('/test').body.should == 'test'
@@ -44,7 +44,7 @@ class SpecViewAlias2 < SpecViewAlias
44
44
  end
45
45
 
46
46
  describe "Template aliasing" do
47
- behaves_like :mock
47
+ behaves_like :rack_test
48
48
 
49
49
  it 'serves normal template' do
50
50
  get('/greet/asdf').body.should == '<html>asdf : Message</html>'
@@ -10,7 +10,7 @@ module Ramaze
10
10
  end
11
11
 
12
12
  describe 'Directory listing' do
13
- behaves_like :mock
13
+ behaves_like :rack_test
14
14
 
15
15
  @hierarchy = %w[
16
16
  /test/deep/hierarchy/one.txt