padrino-core 0.9.6 → 0.9.7
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.
- data/README.rdoc +45 -45
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/padrino-core.rb +6 -6
- data/lib/padrino-core/application.rb +13 -18
- data/lib/padrino-core/application/mounter.rb +20 -20
- data/lib/padrino-core/application/rendering.rb +48 -21
- data/lib/padrino-core/application/routing.rb +20 -6
- data/lib/padrino-core/application/showexceptions.rb +25 -0
- data/lib/padrino-core/caller.rb +35 -36
- data/lib/padrino-core/cli/adapter.rb +4 -5
- data/lib/padrino-core/cli/base.rb +1 -1
- data/lib/padrino-core/cli/rake.rb +0 -1
- data/lib/padrino-core/loader.rb +12 -12
- data/lib/padrino-core/locale/en.yml +1 -1
- data/lib/padrino-core/locale/it.yml +4 -4
- data/lib/padrino-core/logger.rb +24 -24
- data/lib/padrino-core/reloader.rb +6 -6
- data/lib/padrino-core/server.rb +5 -5
- data/lib/padrino-core/support_lite.rb +9 -9
- data/lib/padrino-core/tasks.rb +4 -4
- data/lib/padrino-core/version.rb +3 -3
- data/padrino-core.gemspec +3 -2
- data/test/fixtures/apps/simple.rb +3 -3
- data/test/test_application.rb +61 -26
- data/test/test_mounter.rb +5 -5
- data/test/test_reloader_simple.rb +4 -4
- data/test/test_routing.rb +44 -0
- data/test/test_server.rb +1 -1
- metadata +4 -3
@@ -36,7 +36,7 @@ module Padrino
|
|
36
36
|
##
|
37
37
|
# You can exclude some folders from reload its contents.
|
38
38
|
# Defaults excluded directories of Padrino.root are: test, spec, features, tmp, config, lib, db and public
|
39
|
-
#
|
39
|
+
#
|
40
40
|
def self.exclude
|
41
41
|
@_exclude ||= %w(test spec tmp features config lib public db).map { |path| Padrino.root(path) }
|
42
42
|
end
|
@@ -48,7 +48,7 @@ module Padrino
|
|
48
48
|
#
|
49
49
|
# Please note that this will not reload files in the background, it does so
|
50
50
|
# only when actively called.
|
51
|
-
#
|
51
|
+
#
|
52
52
|
module Stat
|
53
53
|
class << self
|
54
54
|
CACHE = {}
|
@@ -72,7 +72,7 @@ module Padrino
|
|
72
72
|
|
73
73
|
##
|
74
74
|
# A safe Kernel::load, issuing the hooks depending on the results
|
75
|
-
#
|
75
|
+
#
|
76
76
|
def safe_load(file, mtime)
|
77
77
|
logger.debug "Reloading #{file}"
|
78
78
|
load(file)
|
@@ -85,7 +85,7 @@ module Padrino
|
|
85
85
|
|
86
86
|
##
|
87
87
|
# Search Ruby files in your +Padrino.root+ and monitor them for changes.
|
88
|
-
#
|
88
|
+
#
|
89
89
|
def rotation
|
90
90
|
paths = Dir[Padrino.root("*")].reject { |path| Padrino::Reloader.exclude.include?(path) || !File.directory?(path) }
|
91
91
|
files = paths.map { |path| Dir["#{path}/**/*.rb"] }.flatten
|
@@ -104,7 +104,7 @@ module Padrino
|
|
104
104
|
# Takes a relative or absolute +file+ name, a couple possible +paths+ that
|
105
105
|
# the +file+ might reside in. Returns the full path and File::Stat for the
|
106
106
|
# path.
|
107
|
-
#
|
107
|
+
#
|
108
108
|
def figure_path(file, paths)
|
109
109
|
found = CACHE[file]
|
110
110
|
found = file if !found and Pathname.new(file).absolute?
|
@@ -130,4 +130,4 @@ module Padrino
|
|
130
130
|
end # self
|
131
131
|
end # Stat
|
132
132
|
end # Reloader
|
133
|
-
end # Padrino
|
133
|
+
end # Padrino
|
data/lib/padrino-core/server.rb
CHANGED
@@ -3,12 +3,12 @@ module Padrino
|
|
3
3
|
##
|
4
4
|
# Run the Padrino apps as a self-hosted server using:
|
5
5
|
# thin, mongrel, webrick in that order.
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# ==== Examples
|
8
|
-
#
|
8
|
+
#
|
9
9
|
# Padrino.run! # with these defaults => host: "localhost", port: "3000", adapter: the first found
|
10
10
|
# Padrino.run!("localhost", "4000", "mongrel") # use => host: "localhost", port: "3000", adapter: "mongrel"
|
11
|
-
#
|
11
|
+
#
|
12
12
|
def self.run!(*args)
|
13
13
|
Padrino.load! unless Padrino.loaded?
|
14
14
|
Server.build(*args)
|
@@ -16,7 +16,7 @@ module Padrino
|
|
16
16
|
|
17
17
|
##
|
18
18
|
# This module build a Padrino server
|
19
|
-
#
|
19
|
+
#
|
20
20
|
module Server
|
21
21
|
|
22
22
|
class LoadError < RuntimeError; end
|
@@ -61,4 +61,4 @@ module Padrino
|
|
61
61
|
raise LoadError, "Server handler (#{servers.join(',')}) not found."
|
62
62
|
end
|
63
63
|
end # Server
|
64
|
-
end # Padrino
|
64
|
+
end # Padrino
|
@@ -1,14 +1,14 @@
|
|
1
1
|
##
|
2
2
|
# This file loads certain extensions required by Padrino from ActiveSupport.
|
3
|
-
#
|
4
|
-
# Why use ActiveSupport and not our own library or extlib?
|
3
|
+
#
|
4
|
+
# Why use ActiveSupport and not our own library or extlib?
|
5
5
|
#
|
6
6
|
# 1) Writing custom method extensions needed (i.e string inflections) is not a good use of time.
|
7
7
|
# 2) Loading custom method extensions or separate gem would conflict when AR or MM has been loaded.
|
8
8
|
# 3) Datamapper is planning to move to ActiveSupport and away from extlib.
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# Extensions required for Padrino:
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# * Class#cattr_accessor
|
13
13
|
# * Module#alias_method_chain
|
14
14
|
# * String#inflectors (classify, underscore, camelize, pluralize, etc)
|
@@ -20,7 +20,7 @@
|
|
20
20
|
# * Hash#symbolize_keys, Hash.symbolize_keys!
|
21
21
|
# * Hash#reverse_merge, Hash#reverse_merge!
|
22
22
|
# * SupportLite::OrderedHash
|
23
|
-
#
|
23
|
+
#
|
24
24
|
|
25
25
|
require 'i18n'
|
26
26
|
require 'active_support/core_ext/kernel'
|
@@ -37,7 +37,7 @@ require 'active_support/ordered_hash'
|
|
37
37
|
|
38
38
|
##
|
39
39
|
# Define our own OrderedHash based on AS::OrderedHash
|
40
|
-
#
|
40
|
+
#
|
41
41
|
unless defined?(SupportLite::OrderedHash)
|
42
42
|
module SupportLite
|
43
43
|
OrderedHash = ::ActiveSupport::OrderedHash
|
@@ -46,14 +46,14 @@ end
|
|
46
46
|
|
47
47
|
##
|
48
48
|
# Alias allowing for use of either method to get query parameters
|
49
|
-
#
|
49
|
+
#
|
50
50
|
unless Hash.method_defined?(:to_params)
|
51
|
-
class Hash
|
51
|
+
class Hash
|
52
52
|
alias :to_params :to_query
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
##
|
57
57
|
# Loads our locales configuration files
|
58
|
-
#
|
58
|
+
#
|
59
59
|
I18n.load_path += Dir["#{File.dirname(__FILE__)}/locale/*.yml"]
|
data/lib/padrino-core/tasks.rb
CHANGED
@@ -4,18 +4,18 @@ module Padrino
|
|
4
4
|
# This module it's used for bootstrap with padrino rake
|
5
5
|
# thirdy party tasks, in your gem/plugin/extension you
|
6
6
|
# need only do this:
|
7
|
-
#
|
7
|
+
#
|
8
8
|
# ==== Examples
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# Padrino::Tasks.files << yourtask.rb
|
11
11
|
# Padrino::Tasks.files.concat(Dir["/path/to/all/my/tasks/*.rb"])
|
12
12
|
# Padrino::Tasks.files.unshift("yourtask.rb")
|
13
|
-
#
|
13
|
+
#
|
14
14
|
module Tasks
|
15
15
|
|
16
16
|
##
|
17
17
|
# Returns a list of files to handle with padrino rake
|
18
|
-
#
|
18
|
+
#
|
19
19
|
def self.files
|
20
20
|
@files ||= []
|
21
21
|
end
|
data/lib/padrino-core/version.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
##
|
2
2
|
# Manages Padrino version from the VERSION file managed by Jeweler
|
3
|
-
# We put this in a separate file so you can get padrino version
|
3
|
+
# We put this in a separate file so you can get padrino version
|
4
4
|
# without include full padrino core.
|
5
5
|
#
|
6
6
|
module Padrino
|
7
7
|
##
|
8
8
|
# Return the current Padrino version
|
9
|
-
#
|
9
|
+
#
|
10
10
|
def self.version
|
11
11
|
@version ||= File.read(File.dirname(__FILE__) + '/../../VERSION').chomp
|
12
12
|
end
|
13
|
-
end # Padrino
|
13
|
+
end # Padrino
|
data/padrino-core.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{padrino-core}
|
8
|
-
s.version = "0.9.
|
8
|
+
s.version = "0.9.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Padrino Team", "Nathan Esquenazi", "Davide D'Agostino", "Arthur Chiu"]
|
12
|
-
s.date = %q{2010-03-
|
12
|
+
s.date = %q{2010-03-22}
|
13
13
|
s.default_executable = %q{padrino}
|
14
14
|
s.description = %q{The Padrino core gem required for use of this framework}
|
15
15
|
s.email = %q{padrinorb@gmail.com}
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
"lib/padrino-core/application/mounter.rb",
|
31
31
|
"lib/padrino-core/application/rendering.rb",
|
32
32
|
"lib/padrino-core/application/routing.rb",
|
33
|
+
"lib/padrino-core/application/showexceptions.rb",
|
33
34
|
"lib/padrino-core/caller.rb",
|
34
35
|
"lib/padrino-core/cli/adapter.rb",
|
35
36
|
"lib/padrino-core/cli/base.rb",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
PADRINO_ROOT = File.dirname(__FILE__) unless defined? PADRINO_ROOT
|
2
2
|
# Remove this comment if you want do some like this: ruby PADRINO_ENV=test app.rb
|
3
|
-
#
|
3
|
+
#
|
4
4
|
# require 'rubygems'
|
5
5
|
# require 'lib/padrino-core'
|
6
6
|
#
|
@@ -16,9 +16,9 @@ SimpleDemo.controllers do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
## If you want use this as a standalone app uncomment:
|
19
|
-
#
|
19
|
+
#
|
20
20
|
# Padrino.mount_core("SimpleDemo")
|
21
21
|
# Padrino.run! unless Padrino.loaded? # If you enable reloader prevent to re-run the app
|
22
|
-
#
|
22
|
+
#
|
23
23
|
|
24
24
|
Padrino.load!
|
data/test/test_application.rb
CHANGED
@@ -2,42 +2,35 @@ require File.dirname(__FILE__) + '/helper'
|
|
2
2
|
|
3
3
|
class TestApplication < Test::Unit::TestCase
|
4
4
|
|
5
|
-
def
|
6
|
-
# Build a temp layout
|
7
|
-
FileUtils.mkdir_p(File.dirname(__FILE__) + "/views/layouts")
|
8
|
-
layout = File.dirname(__FILE__) + "/views/layouts/#{name}.erb"
|
9
|
-
File.open(layout, 'wb') { |io| io.write "this is a <%= yield %>" }
|
10
|
-
yield
|
11
|
-
ensure
|
12
|
-
# Remove temp layout
|
13
|
-
File.unlink(layout) rescue nil
|
14
|
-
FileUtils.rm_rf(File.dirname(__FILE__) + "/views")
|
15
|
-
end
|
16
|
-
|
17
|
-
def create_view(name, content, options={})
|
5
|
+
def create_template(name, content, options={})
|
18
6
|
FileUtils.mkdir_p(File.dirname(__FILE__) + "/views")
|
19
|
-
|
20
|
-
path
|
21
|
-
path
|
22
|
-
path
|
23
|
-
|
24
|
-
File.
|
25
|
-
|
7
|
+
FileUtils.mkdir_p(File.dirname(__FILE__) + "/views/layouts")
|
8
|
+
path = "/views/#{name}"
|
9
|
+
path += ".#{options.delete(:locale)}" if options[:locale].present?
|
10
|
+
path += ".#{options.delete(:format)}" if options[:format].present?
|
11
|
+
path += ".erb"
|
12
|
+
file = File.dirname(__FILE__) + path
|
13
|
+
File.open(file, 'w') { |io| io.write content }
|
14
|
+
file
|
26
15
|
end
|
16
|
+
alias :create_view :create_template
|
17
|
+
alias :create_layout :create_template
|
27
18
|
|
28
19
|
def remove_views
|
29
20
|
FileUtils.rm_rf(File.dirname(__FILE__) + "/views")
|
30
21
|
end
|
31
22
|
|
32
|
-
def
|
23
|
+
def with_template(name, content, options={})
|
33
24
|
# Build a temp layout
|
34
|
-
|
25
|
+
template = create_template(name, content, options)
|
35
26
|
yield
|
36
27
|
ensure
|
37
28
|
# Remove temp layout
|
38
|
-
File.unlink(
|
29
|
+
File.unlink(template) rescue nil
|
39
30
|
remove_views
|
40
31
|
end
|
32
|
+
alias :with_view :with_template
|
33
|
+
alias :with_layout :with_template
|
41
34
|
|
42
35
|
def teardown
|
43
36
|
remove_views
|
@@ -96,7 +89,7 @@ class TestApplication < Test::Unit::TestCase
|
|
96
89
|
end
|
97
90
|
|
98
91
|
should 'use rails way layout' do
|
99
|
-
with_layout do
|
92
|
+
with_layout :application, "this is a <%= yield %>" do
|
100
93
|
mock_app do
|
101
94
|
get("/"){ render :erb, "rails way layout" }
|
102
95
|
end
|
@@ -107,7 +100,7 @@ class TestApplication < Test::Unit::TestCase
|
|
107
100
|
end
|
108
101
|
|
109
102
|
should 'use rails way for a custom layout' do
|
110
|
-
with_layout
|
103
|
+
with_layout "layouts/custom", "this is a <%= yield %>" do
|
111
104
|
mock_app do
|
112
105
|
layout :custom
|
113
106
|
get("/"){ render :erb, "rails way custom layout" }
|
@@ -119,7 +112,7 @@ class TestApplication < Test::Unit::TestCase
|
|
119
112
|
end
|
120
113
|
|
121
114
|
should 'not use layout' do
|
122
|
-
with_layout do
|
115
|
+
with_layout :application, "this is a <%= yield %>" do
|
123
116
|
with_view :index, "index" do
|
124
117
|
mock_app do
|
125
118
|
get("/with/layout"){ render :index }
|
@@ -239,6 +232,48 @@ class TestApplication < Test::Unit::TestCase
|
|
239
232
|
assert_equal 404, status
|
240
233
|
end
|
241
234
|
|
235
|
+
should 'resolve template content_type and locale with layout' do
|
236
|
+
create_layout :foo, "Hello <%= yield %> in a Js layout", :format => :js
|
237
|
+
create_layout :foo, "Hello <%= yield %> in a Js-En layout", :format => :js, :locale => :en
|
238
|
+
create_layout :foo, "Hello <%= yield %> in a Js-It layout", :format => :js, :locale => :it
|
239
|
+
create_layout :foo, "Hello <%= yield %> in a Erb-En layout", :locale => :en
|
240
|
+
create_layout :foo, "Hello <%= yield %> in a Erb-It layout", :locale => :it
|
241
|
+
create_layout :foo, "Hello <%= yield %> in a Erb layout"
|
242
|
+
create_view :bar, "Im Js", :format => :js
|
243
|
+
create_view :bar, "Im Erb"
|
244
|
+
create_view :bar, "Im English Erb", :locale => :en
|
245
|
+
create_view :bar, "Im Italian Erb", :locale => :it
|
246
|
+
create_view :bar, "Im English Js", :format => :js, :locale => :en
|
247
|
+
create_view :bar, "Im Italian Js", :format => :js, :locale => :it
|
248
|
+
create_view :bar, "Im a json", :format => :json
|
249
|
+
mock_app do
|
250
|
+
layout :foo
|
251
|
+
get("/bar", :respond_to => [:html, :js, :json]) { render :bar }
|
252
|
+
end
|
253
|
+
I18n.locale = :none
|
254
|
+
get "/bar.js"
|
255
|
+
assert_equal "Hello Im Js in a Js layout", body
|
256
|
+
get "/bar"
|
257
|
+
assert_equal "Hello Im Erb in a Erb layout", body
|
258
|
+
I18n.locale = :en
|
259
|
+
get "/bar"
|
260
|
+
assert_equal "Hello Im English Erb in a Erb-En layout", body
|
261
|
+
I18n.locale = :it
|
262
|
+
get "/bar"
|
263
|
+
assert_equal "Hello Im Italian Erb in a Erb-It layout", body
|
264
|
+
I18n.locale = :en
|
265
|
+
get "/bar.js"
|
266
|
+
assert_equal "Hello Im English Js in a Js-En layout", body
|
267
|
+
I18n.locale = :it
|
268
|
+
get "/bar.js"
|
269
|
+
assert_equal "Hello Im Italian Js in a Js-It layout", body
|
270
|
+
I18n.locale = :en
|
271
|
+
get "/bar.json"
|
272
|
+
assert_equal "Im a json", body
|
273
|
+
get "/bar.pk"
|
274
|
+
assert_equal 404, status
|
275
|
+
end
|
276
|
+
|
242
277
|
should 'renders erb with blocks' do
|
243
278
|
mock_app do
|
244
279
|
def container
|
data/test/test_mounter.rb
CHANGED
@@ -7,7 +7,7 @@ class TestMounter < Test::Unit::TestCase
|
|
7
7
|
end
|
8
8
|
|
9
9
|
context 'for mounter functionality' do
|
10
|
-
|
10
|
+
|
11
11
|
should 'check methods' do
|
12
12
|
mounter = Padrino::Mounter.new("test", :app_file => "/path/to/test.rb")
|
13
13
|
mounter.to("/test")
|
@@ -38,7 +38,7 @@ class TestMounter < Test::Unit::TestCase
|
|
38
38
|
assert_equal AnApp, Padrino.mounted_apps.first.app_obj
|
39
39
|
assert_equal ["core"], Padrino.mounted_apps.collect(&:name)
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
should 'mount a core' do
|
43
43
|
mounter = Padrino.mount_core("test")
|
44
44
|
assert_equal "core", mounter.name
|
@@ -52,7 +52,7 @@ class TestMounter < Test::Unit::TestCase
|
|
52
52
|
should 'mount multiple apps' do
|
53
53
|
class ::OneApp < Padrino::Application; end
|
54
54
|
class ::TwoApp < Padrino::Application; end
|
55
|
-
|
55
|
+
|
56
56
|
Padrino.mount("one_app").to("/one_app")
|
57
57
|
Padrino.mount("two_app").to("/two_app")
|
58
58
|
# And testing no duplicates
|
@@ -64,7 +64,7 @@ class TestMounter < Test::Unit::TestCase
|
|
64
64
|
assert_equal 2, Padrino.mounted_apps.size, "should not mount duplicate apps"
|
65
65
|
assert_equal ["one_app", "two_app"], Padrino.mounted_apps.collect(&:name)
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
should 'change mounted_root' do
|
69
69
|
Padrino.mounted_root = "fixtures"
|
70
70
|
assert_equal Padrino.root("fixtures", "test", "app.rb"), Padrino.mounted_root("test", "app.rb")
|
@@ -79,7 +79,7 @@ class TestMounter < Test::Unit::TestCase
|
|
79
79
|
get("/demo_1"){ "Im Demo 1" }
|
80
80
|
get("/demo_2"){ "Im Demo 2" }
|
81
81
|
end
|
82
|
-
|
82
|
+
|
83
83
|
get '/demo_1'
|
84
84
|
assert_equal "Im Demo 1", body
|
85
85
|
get '/demo_2'
|
@@ -39,9 +39,9 @@ class TestSimpleReloader < Test::Unit::TestCase
|
|
39
39
|
assert_equal "image/png", response["Content-Type"]
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
context 'for simple reload functionality' do
|
44
|
-
|
44
|
+
|
45
45
|
should 'correctly instantiate SimpleDemo fixture' do
|
46
46
|
Padrino.mounted_apps.clear
|
47
47
|
Padrino.mount_core("simple_demo")
|
@@ -49,7 +49,7 @@ class TestSimpleReloader < Test::Unit::TestCase
|
|
49
49
|
assert SimpleDemo.reload?
|
50
50
|
assert_match %r{fixtures/apps/simple.rb}, SimpleDemo.app_file
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
should 'correctly reload SimpleDemo fixture' do
|
54
54
|
@app = SimpleDemo
|
55
55
|
get "/"
|
@@ -61,7 +61,7 @@ class TestSimpleReloader < Test::Unit::TestCase
|
|
61
61
|
sleep 1.2 # We need at least a cooldown of 1 sec.
|
62
62
|
get "/"
|
63
63
|
assert_equal new_phrase, body
|
64
|
-
|
64
|
+
|
65
65
|
# Now we need to prevent to commit a new changed file so we revert it
|
66
66
|
File.open(SimpleDemo.app_file, "w") { |f| f.write(buffer) }
|
67
67
|
end
|
data/test/test_routing.rb
CHANGED
@@ -12,6 +12,17 @@ class TestRouting < Test::Unit::TestCase
|
|
12
12
|
assert_equal "okey", body
|
13
13
|
end
|
14
14
|
|
15
|
+
should 'fail with unrecognized route exception when not found' do
|
16
|
+
unrecognized_app = mock_app do
|
17
|
+
get(:index){ "okey" }
|
18
|
+
end
|
19
|
+
assert_nothing_raised { get unrecognized_app.url_for(:index) }
|
20
|
+
assert_equal "okey", body
|
21
|
+
assert_raises(Padrino::Routing::UnrecognizedException) {
|
22
|
+
get unrecognized_app.url_for(:fake)
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
15
26
|
should "parse routes with question marks" do
|
16
27
|
mock_app do
|
17
28
|
get("/foo/?"){ "okey" }
|
@@ -85,6 +96,39 @@ class TestRouting < Test::Unit::TestCase
|
|
85
96
|
assert_equal "/d.js?foo=bar", body
|
86
97
|
end
|
87
98
|
|
99
|
+
should "generate routes for format simple" do
|
100
|
+
mock_app do
|
101
|
+
get(:foo, :respond_to => [:html, :rss]) { render :haml, "Test" }
|
102
|
+
end
|
103
|
+
get "/foo"
|
104
|
+
assert_equal "Test\n", body
|
105
|
+
get "/foo.rss"
|
106
|
+
assert_equal "Test\n", body
|
107
|
+
end
|
108
|
+
|
109
|
+
should "generate routes for format with controller" do
|
110
|
+
mock_app do
|
111
|
+
controller :posts do
|
112
|
+
get(:index, :respond_to => [:html, :rss, :atom, :js]) { render :haml, "Index.#{content_type}" }
|
113
|
+
get(:show, :with => :id, :respond_to => [:html, :rss, :atom]) { render :haml, "Show.#{content_type}" }
|
114
|
+
end
|
115
|
+
end
|
116
|
+
get "/posts"
|
117
|
+
assert_equal "Index.html\n", body
|
118
|
+
get "/posts.rss"
|
119
|
+
assert_equal "Index.rss\n", body
|
120
|
+
get "/posts.atom"
|
121
|
+
assert_equal "Index.atom\n", body
|
122
|
+
get "/posts.js"
|
123
|
+
assert_equal "Index.js\n", body
|
124
|
+
get "/posts/show/5"
|
125
|
+
assert_equal "Show.html\n", body
|
126
|
+
get "/posts/show/5.rss"
|
127
|
+
assert_equal "Show.rss\n", body
|
128
|
+
get "/posts/show/10.atom"
|
129
|
+
assert_equal "Show.atom\n", body
|
130
|
+
end
|
131
|
+
|
88
132
|
should 'map routes' do
|
89
133
|
mock_app do
|
90
134
|
get(:bar){ "bar" }
|