manveru-innate 2009.02.25 → 2009.03.24
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +383 -0
- data/MANIFEST +17 -8
- data/README.md +222 -136
- data/Rakefile +7 -2
- data/example/provides.rb +28 -0
- data/innate.gemspec +19 -10
- data/lib/innate/action.rb +21 -47
- data/lib/innate/adapter.rb +65 -56
- data/lib/innate/cache.rb +16 -8
- data/lib/innate/dynamap.rb +39 -29
- data/lib/innate/helper/aspect.rb +60 -0
- data/lib/innate/helper/cgi.rb +2 -0
- data/lib/innate/helper/link.rb +43 -11
- data/lib/innate/helper/partial.rb +6 -5
- data/lib/innate/helper.rb +10 -13
- data/lib/innate/log/hub.rb +1 -0
- data/lib/innate/log.rb +3 -6
- data/lib/{rack → innate}/middleware_compiler.rb +19 -12
- data/lib/innate/mock.rb +3 -2
- data/lib/innate/node.rb +573 -179
- data/lib/innate/options/dsl.rb +46 -6
- data/lib/innate/options/stub.rb +7 -0
- data/lib/innate/options.rb +14 -93
- data/lib/innate/request.rb +21 -7
- data/lib/innate/response.rb +12 -0
- data/lib/innate/route.rb +2 -3
- data/lib/innate/session.rb +37 -20
- data/lib/innate/spec.rb +4 -0
- data/lib/innate/state/fiber.rb +14 -7
- data/lib/innate/state/thread.rb +10 -2
- data/lib/innate/state.rb +8 -11
- data/lib/innate/traited.rb +14 -6
- data/lib/innate/trinity.rb +0 -4
- data/lib/innate/version.rb +1 -1
- data/lib/innate/view/erb.rb +4 -2
- data/lib/innate/view/none.rb +2 -2
- data/lib/innate/view.rb +14 -21
- data/lib/innate.rb +49 -30
- data/spec/helper.rb +8 -0
- data/spec/innate/action/layout.rb +9 -6
- data/spec/innate/cache/common.rb +3 -3
- data/spec/innate/helper/aspect.rb +3 -5
- data/spec/innate/helper/flash.rb +1 -1
- data/spec/innate/helper/link.rb +45 -2
- data/spec/innate/helper/partial.rb +34 -10
- data/spec/innate/helper/view/loop.erb +1 -1
- data/spec/innate/helper/view/recursive.erb +1 -1
- data/spec/innate/node/mapping.rb +37 -0
- data/spec/innate/node/node.rb +142 -0
- data/spec/innate/node/resolve.rb +82 -0
- data/spec/innate/node/{another_layout → view/another_layout}/another_layout.erb +0 -0
- data/spec/innate/node/{bar.html → view/bar.erb} +0 -0
- data/spec/innate/node/{foo.html.erb → view/foo.html.erb} +0 -0
- data/spec/innate/node/{only_view.html → view/only_view.erb} +0 -0
- data/spec/innate/node/view/with_layout.erb +1 -0
- data/spec/innate/node/wrap_action_call.rb +83 -0
- data/spec/innate/options.rb +28 -6
- data/spec/innate/provides/list.html.erb +1 -0
- data/spec/innate/provides/list.txt.erb +1 -0
- data/spec/innate/provides.rb +99 -0
- data/spec/innate/request.rb +23 -10
- data/spec/innate/route.rb +2 -4
- data/spec/innate/session.rb +1 -1
- data/spec/innate/state/fiber.rb +57 -0
- data/spec/innate/state/thread.rb +40 -0
- metadata +20 -11
- data/lib/rack/reloader.rb +0 -192
- data/spec/innate/node/with_layout.erb +0 -3
- data/spec/innate/node.rb +0 -224
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: manveru-innate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2009.
|
4
|
+
version: 2009.03.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael 'manveru' Fellinger
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-03-21 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.
|
23
|
+
version: 0.9.1
|
24
24
|
version:
|
25
25
|
description: Simple, straight-forward, base for web-frameworks.
|
26
26
|
email: m.fellinger@gmail.com
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- example/hello.rb
|
51
51
|
- example/howto_spec.rb
|
52
52
|
- example/link.rb
|
53
|
+
- example/provides.rb
|
53
54
|
- example/session.rb
|
54
55
|
- innate.gemspec
|
55
56
|
- lib/innate.rb
|
@@ -77,10 +78,12 @@ files:
|
|
77
78
|
- lib/innate/log.rb
|
78
79
|
- lib/innate/log/color_formatter.rb
|
79
80
|
- lib/innate/log/hub.rb
|
81
|
+
- lib/innate/middleware_compiler.rb
|
80
82
|
- lib/innate/mock.rb
|
81
83
|
- lib/innate/node.rb
|
82
84
|
- lib/innate/options.rb
|
83
85
|
- lib/innate/options/dsl.rb
|
86
|
+
- lib/innate/options/stub.rb
|
84
87
|
- lib/innate/request.rb
|
85
88
|
- lib/innate/response.rb
|
86
89
|
- lib/innate/route.rb
|
@@ -97,8 +100,6 @@ files:
|
|
97
100
|
- lib/innate/view.rb
|
98
101
|
- lib/innate/view/erb.rb
|
99
102
|
- lib/innate/view/none.rb
|
100
|
-
- lib/rack/middleware_compiler.rb
|
101
|
-
- lib/rack/reloader.rb
|
102
103
|
- spec/example/hello.rb
|
103
104
|
- spec/example/link.rb
|
104
105
|
- spec/example/session.rb
|
@@ -125,17 +126,25 @@ files:
|
|
125
126
|
- spec/innate/helper/view/partial.erb
|
126
127
|
- spec/innate/helper/view/recursive.erb
|
127
128
|
- spec/innate/mock.rb
|
128
|
-
- spec/innate/node.rb
|
129
|
-
- spec/innate/node/
|
130
|
-
- spec/innate/node/
|
131
|
-
- spec/innate/node/
|
132
|
-
- spec/innate/node/
|
133
|
-
- spec/innate/node/
|
129
|
+
- spec/innate/node/mapping.rb
|
130
|
+
- spec/innate/node/node.rb
|
131
|
+
- spec/innate/node/resolve.rb
|
132
|
+
- spec/innate/node/view/another_layout/another_layout.erb
|
133
|
+
- spec/innate/node/view/bar.erb
|
134
|
+
- spec/innate/node/view/foo.html.erb
|
135
|
+
- spec/innate/node/view/only_view.erb
|
136
|
+
- spec/innate/node/view/with_layout.erb
|
137
|
+
- spec/innate/node/wrap_action_call.rb
|
134
138
|
- spec/innate/options.rb
|
135
139
|
- spec/innate/parameter.rb
|
140
|
+
- spec/innate/provides.rb
|
141
|
+
- spec/innate/provides/list.html.erb
|
142
|
+
- spec/innate/provides/list.txt.erb
|
136
143
|
- spec/innate/request.rb
|
137
144
|
- spec/innate/route.rb
|
138
145
|
- spec/innate/session.rb
|
146
|
+
- spec/innate/state/fiber.rb
|
147
|
+
- spec/innate/state/thread.rb
|
139
148
|
- spec/innate/traited.rb
|
140
149
|
has_rdoc: true
|
141
150
|
homepage: http://github.com/manveru/innate
|
data/lib/rack/reloader.rb
DELETED
@@ -1,192 +0,0 @@
|
|
1
|
-
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
-
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
-
|
4
|
-
require 'pathname'
|
5
|
-
|
6
|
-
module Rack
|
7
|
-
|
8
|
-
# High performant source reloader
|
9
|
-
#
|
10
|
-
# This class acts as Rack middleware.
|
11
|
-
#
|
12
|
-
# It does not depend on Ramaze itself, but you might have to adjust the
|
13
|
-
# Reloader::Hooks module or include your own module to override the hooks.
|
14
|
-
# You also might have to set the Log constant.
|
15
|
-
#
|
16
|
-
# What makes it especially suited for use in a production environment is that
|
17
|
-
# any file will only be checked once and there will only be made one system
|
18
|
-
# call stat(2).
|
19
|
-
#
|
20
|
-
# Please note that this will not reload files in the background, it does so
|
21
|
-
# only when actively called
|
22
|
-
# In case of Ramaze it is performing a check/reload cycle at the start of
|
23
|
-
# every request, but also respects a cool down time, during which nothing will
|
24
|
-
# be done.
|
25
|
-
#
|
26
|
-
# After every reload the OPTIONS hash will be checked for changed options and
|
27
|
-
# assigned to the instance, so you may change options during the lifetime of
|
28
|
-
# your application.
|
29
|
-
#
|
30
|
-
# A number of hooks will be executed during the reload cycle, see
|
31
|
-
# Ramaze::ReloaderHooks for more information.
|
32
|
-
|
33
|
-
class Reloader
|
34
|
-
OPTIONS = {
|
35
|
-
# At most check every n seconds
|
36
|
-
# nil/false will never trigger the reload cycle
|
37
|
-
# 0 will cycle on every call
|
38
|
-
:cooldown => 2,
|
39
|
-
|
40
|
-
# Compiled files cannot be reloaded during runtime
|
41
|
-
:ignore => /\.so$/,
|
42
|
-
|
43
|
-
# Run cycle in a Thread.exclusive, by default no threads are used.
|
44
|
-
:thread => false,
|
45
|
-
|
46
|
-
# If you assign a block here it will be instance_evaled instead of
|
47
|
-
# calling cycle. This allows you to use for example EventMachine for
|
48
|
-
# well performing asynchronous cycling.
|
49
|
-
:control => nil, # lambda{ cycle },
|
50
|
-
}
|
51
|
-
|
52
|
-
|
53
|
-
# Dirty! keep track of this in an instance :(
|
54
|
-
# Find out how to reasonably cache racks builder
|
55
|
-
@@last ||= Time.now
|
56
|
-
@@cache ||= {}
|
57
|
-
@@mtimes ||= {}
|
58
|
-
|
59
|
-
def initialize(app)
|
60
|
-
@app = app
|
61
|
-
options_reload
|
62
|
-
end
|
63
|
-
|
64
|
-
def options_reload
|
65
|
-
@cooldown, @ignore, @control, @thread =
|
66
|
-
OPTIONS.values_at(:cooldown, :ignore, :control, :thread)
|
67
|
-
end
|
68
|
-
|
69
|
-
def call(env)
|
70
|
-
options_reload
|
71
|
-
|
72
|
-
if @cooldown and Time.now > @@last + @cooldown
|
73
|
-
if @control
|
74
|
-
instance_eval(&@control)
|
75
|
-
elsif @thread
|
76
|
-
Thread.exclusive{ cycle }
|
77
|
-
else
|
78
|
-
cycle
|
79
|
-
end
|
80
|
-
|
81
|
-
@@last = Time.now
|
82
|
-
end
|
83
|
-
|
84
|
-
@app.call(env)
|
85
|
-
end
|
86
|
-
|
87
|
-
def cycle
|
88
|
-
before_cycle
|
89
|
-
|
90
|
-
rotation do |file, stat|
|
91
|
-
if mtime = stat.mtime
|
92
|
-
if mtime > (@@mtimes[file] ||= mtime)
|
93
|
-
safe_load(file, mtime)
|
94
|
-
end
|
95
|
-
else
|
96
|
-
@@cache.delete(file)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
after_cycle
|
101
|
-
end
|
102
|
-
|
103
|
-
# A safe Kernel::load, issuing the hooks depending on the results
|
104
|
-
def safe_load(file, mtime)
|
105
|
-
before_safe_load(file)
|
106
|
-
load(file)
|
107
|
-
after_safe_load_succeed(file)
|
108
|
-
rescue Object => ex
|
109
|
-
puts ex
|
110
|
-
after_safe_load_failed(file, ex)
|
111
|
-
ensure
|
112
|
-
@@mtimes[file] = mtime
|
113
|
-
end
|
114
|
-
|
115
|
-
def rotation
|
116
|
-
files = [$0, *$LOADED_FEATURES].uniq
|
117
|
-
paths = ['./', *$LOAD_PATH].uniq
|
118
|
-
|
119
|
-
files.each do |file|
|
120
|
-
next if file =~ @ignore
|
121
|
-
path, stat = figure_path(file, paths)
|
122
|
-
|
123
|
-
if path and stat
|
124
|
-
@@cache[file] = path
|
125
|
-
yield(path, stat)
|
126
|
-
else
|
127
|
-
# Mostly harmless
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
def figure_path(file, paths)
|
133
|
-
if cached = @@cache[file]
|
134
|
-
stat = ::File.stat(cached)
|
135
|
-
return cached, stat if stat.file?
|
136
|
-
elsif Pathname.new(file).absolute?
|
137
|
-
stat = ::File.stat(file)
|
138
|
-
return file, stat if stat.file? # do directories really end up in $" ?
|
139
|
-
end
|
140
|
-
|
141
|
-
paths.each do |possible_path|
|
142
|
-
path = ::File.join(possible_path, file)
|
143
|
-
|
144
|
-
begin
|
145
|
-
stat = ::File.stat(path)
|
146
|
-
return path, stat if stat.file?
|
147
|
-
rescue Errno::ENOENT, Errno::ENOTDIR
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
return nil
|
152
|
-
rescue Errno::ENOENT => ex
|
153
|
-
@@cache.delete(file)
|
154
|
-
retry
|
155
|
-
end
|
156
|
-
|
157
|
-
# Holds hooks that are called before and after #cycle and #safe_load
|
158
|
-
module Hooks
|
159
|
-
# Overwrite to add actions before the reload rotation is started.
|
160
|
-
def before_cycle
|
161
|
-
end
|
162
|
-
|
163
|
-
# Overwrite to add actions after the reload rotation has ended.
|
164
|
-
def after_cycle
|
165
|
-
end
|
166
|
-
|
167
|
-
# Overwrite to add actions before a file is Kernel::load-ed
|
168
|
-
def before_safe_load(file)
|
169
|
-
puts "reload #{file}" # Log.debug("reload #{file}")
|
170
|
-
end
|
171
|
-
|
172
|
-
# Overwrite to add actions after a file is Kernel::load-ed successfully,
|
173
|
-
# by default we clean the Cache for compiled templates and resolved actions.
|
174
|
-
def after_safe_load_succeed(file)
|
175
|
-
after_safe_load(file)
|
176
|
-
end
|
177
|
-
|
178
|
-
# Overwrite to add custom hook in addition to default Cache cleaning
|
179
|
-
def after_safe_load(file)
|
180
|
-
end
|
181
|
-
|
182
|
-
# Overwrite to add actions after a file is Kernel::load-ed unsuccessfully,
|
183
|
-
# by default we output an error-message with the exception.
|
184
|
-
def after_safe_load_failed(file, error)
|
185
|
-
puts error # Log.error(error)
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
include Hooks
|
190
|
-
|
191
|
-
end
|
192
|
-
end
|
data/spec/innate/node.rb
DELETED
@@ -1,224 +0,0 @@
|
|
1
|
-
require 'spec/helper'
|
2
|
-
|
3
|
-
Innate.options.app.root = File.dirname(__FILE__)
|
4
|
-
Innate.options.app.view = ''
|
5
|
-
Innate.options.app.layout = 'node'
|
6
|
-
|
7
|
-
class SpecNode
|
8
|
-
Innate.node('/').provide(:html => :erb, :erb => :none)
|
9
|
-
|
10
|
-
def foo; end
|
11
|
-
def bar; end
|
12
|
-
def one(arg) end
|
13
|
-
def two(arg1, arg2) end
|
14
|
-
def more(*args) end
|
15
|
-
def default(arg = nil) end
|
16
|
-
end
|
17
|
-
|
18
|
-
class SpecNodeProvide
|
19
|
-
Innate.node('/provide').provide(:html => :erb, :erb => :none)
|
20
|
-
|
21
|
-
def foo
|
22
|
-
'<%= 21 * 2 %>'
|
23
|
-
end
|
24
|
-
|
25
|
-
def bar
|
26
|
-
'<%= 84 / 2 %>'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class SpecNodeProvideTemplate
|
31
|
-
Innate.node('/provide_template')
|
32
|
-
provide(:html => :erb, :erb => :none, :yaml => :yaml, :json => :json)
|
33
|
-
|
34
|
-
view_root 'node'
|
35
|
-
end
|
36
|
-
|
37
|
-
class SpecNodeSub < SpecNode
|
38
|
-
map '/sub'
|
39
|
-
|
40
|
-
def bar(arg) end
|
41
|
-
end
|
42
|
-
|
43
|
-
class SpecNodeWithLayout < SpecNodeProvide
|
44
|
-
layout 'with_layout'
|
45
|
-
map '/layout'
|
46
|
-
end
|
47
|
-
|
48
|
-
class SpecNodeWithLayoutView < SpecNodeProvide
|
49
|
-
view_root 'node/another_layout'
|
50
|
-
layout 'another_layout'
|
51
|
-
map '/another_layout'
|
52
|
-
end
|
53
|
-
|
54
|
-
class SpecNodeWithLayoutMethod < SpecNodeProvide
|
55
|
-
map '/layout_method'
|
56
|
-
layout 'layout_method'
|
57
|
-
|
58
|
-
def layout_method
|
59
|
-
'<div class="content"><%= @content %></div>'
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
class SpecNodeIndex
|
64
|
-
Innate.node('/spec_index')
|
65
|
-
|
66
|
-
def index
|
67
|
-
"I have no parameters"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
class SpecNodeAliasView < SpecNodeProvideTemplate
|
72
|
-
map '/alias_view'
|
73
|
-
view_root 'node'
|
74
|
-
|
75
|
-
alias_view :aliased, :bar
|
76
|
-
end
|
77
|
-
|
78
|
-
describe 'Innate::Node' do
|
79
|
-
behaves_like :mock
|
80
|
-
|
81
|
-
def compare(url, hash)
|
82
|
-
result = SpecNode.resolve(url)
|
83
|
-
result.should.not.be.nil
|
84
|
-
hash.each do |key, value|
|
85
|
-
result[key.to_s].should == value
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def assert_wish(url, body, content_type)
|
90
|
-
got = get(url)
|
91
|
-
got.body.strip.should == body
|
92
|
-
got.headers['Content-Type'].should == content_type
|
93
|
-
end
|
94
|
-
|
95
|
-
should 'resolve actions with methods' do
|
96
|
-
SpecNode.resolve('/').should.be.nil
|
97
|
-
SpecNode.resolve('/index').should.be.nil
|
98
|
-
|
99
|
-
compare '/foo', :method => 'foo', :params => []
|
100
|
-
SpecNode.resolve('/foo/one/two').should.be.nil
|
101
|
-
|
102
|
-
compare '/bar', :method => 'bar', :params => []
|
103
|
-
SpecNode.resolve('/bar/one').should.be.nil
|
104
|
-
|
105
|
-
SpecNode.resolve('/one').should.be.nil
|
106
|
-
compare '/one/1', :method => 'one', :params => ['1']
|
107
|
-
SpecNode.resolve('/one/1/2').should.be.nil
|
108
|
-
SpecNode.resolve('/one/1/2/3').should.be.nil
|
109
|
-
|
110
|
-
SpecNode.resolve('/two').should.be.nil
|
111
|
-
SpecNode.resolve('/two/1').should.be.nil
|
112
|
-
compare '/two/1/2', :method => 'two', :params => %w[1 2]
|
113
|
-
SpecNode.resolve('/two/1/2/3').should.be.nil
|
114
|
-
|
115
|
-
compare '/more', :method => 'more', :params => []
|
116
|
-
compare '/more/1', :method => 'more', :params => %w[1]
|
117
|
-
compare '/more/1/2', :method => 'more', :params => %w[1 2]
|
118
|
-
compare '/more/1/2/3', :method => 'more', :params => %w[1 2 3]
|
119
|
-
|
120
|
-
compare '/default', :method => 'default', :params => []
|
121
|
-
compare '/default/1', :method => 'default', :params => %w[1]
|
122
|
-
|
123
|
-
# NOTE: these are actually bound to fail when called, but we cannot
|
124
|
-
# introspect enough to anticipate this failure
|
125
|
-
compare '/default/1/2', :method => 'default', :params => %w[1 2]
|
126
|
-
compare '/default/1/2/3', :method => 'default', :params => %w[1 2 3]
|
127
|
-
end
|
128
|
-
|
129
|
-
should 'inherit action methods from superclasses' do
|
130
|
-
SpecNodeSub.resolve('/foo').should.not.be.nil
|
131
|
-
SpecNodeSub.resolve('/foo/one/two').should.be.nil
|
132
|
-
end
|
133
|
-
|
134
|
-
should 'select correct method from subclasses' do
|
135
|
-
SpecNodeSub.resolve('/bar/one').should.not.be.nil
|
136
|
-
SpecNodeSub.resolve('/bar').should.be.nil
|
137
|
-
end
|
138
|
-
|
139
|
-
should 'provide html if no wish given' do
|
140
|
-
assert_wish('/provide/foo', '42', 'text/html')
|
141
|
-
assert_wish('/provide/bar', '42', 'text/html')
|
142
|
-
end
|
143
|
-
|
144
|
-
should 'provide html as wished' do
|
145
|
-
assert_wish('/provide/foo.html', '42', 'text/html')
|
146
|
-
assert_wish('/provide/bar.html', '42', 'text/html')
|
147
|
-
end
|
148
|
-
|
149
|
-
should 'provide erb as wished' do
|
150
|
-
assert_wish('/provide/foo.erb', "<%= 21 * 2 %>", 'text/html')
|
151
|
-
assert_wish('/provide/bar.erb', "<%= 84 / 2 %>", 'text/html')
|
152
|
-
end
|
153
|
-
|
154
|
-
should 'fulfill wish with templates' do
|
155
|
-
assert_wish('/provide_template/bar.html', "<h1>Hello, World!</h1>",
|
156
|
-
'text/html')
|
157
|
-
assert_wish('/provide_template/bar.erb', "<h1>Hello, World!</h1>",
|
158
|
-
'text/html')
|
159
|
-
|
160
|
-
expected = '0123456789'
|
161
|
-
assert_wish('/provide_template/foo.html', expected, 'text/html')
|
162
|
-
# assert_wish('/provide_template/foo.erb', expected, 'text/plain')
|
163
|
-
end
|
164
|
-
|
165
|
-
should 'respond with 404 if no action was found' do
|
166
|
-
got = Innate::Mock.get('/does_not_exist')
|
167
|
-
got.status.should == 404
|
168
|
-
got.body.should == 'No action found at: "/does_not_exist"'
|
169
|
-
got['Content-Type'].should == 'text/plain'
|
170
|
-
end
|
171
|
-
|
172
|
-
should 'respond with yaml' do
|
173
|
-
assert_wish('/provide_template/bar.yaml', "--- |\n<h1>Hello, World!</h1>",
|
174
|
-
'text/yaml')
|
175
|
-
end
|
176
|
-
|
177
|
-
should 'respond with json' do
|
178
|
-
assert_wish('/provide_template/bar.json', '"<h1>Hello, World!<\\/h1>\\n"',
|
179
|
-
'application/json')
|
180
|
-
end
|
181
|
-
|
182
|
-
should 'wrap with layout' do
|
183
|
-
got = Innate::Mock.get('/layout/bar')
|
184
|
-
got.status.should == 200
|
185
|
-
got.body.should == %(<div class="content">\n 42\n</div>\n)
|
186
|
-
got['Content-Type'].should == 'text/html'
|
187
|
-
end
|
188
|
-
|
189
|
-
should 'find layout with view_root' do
|
190
|
-
got = Innate::Mock.get('/another_layout/bar')
|
191
|
-
got.status.should == 200
|
192
|
-
got.body.should == %(<div class="content">\n 42\n</div>\n)
|
193
|
-
got['Content-Type'].should == 'text/html'
|
194
|
-
end
|
195
|
-
|
196
|
-
should 'find layout from method' do
|
197
|
-
got = Innate::Mock.get('/layout_method/bar')
|
198
|
-
got.status.should == 200
|
199
|
-
got.body.should == %(<div class="content">42</div>)
|
200
|
-
got['Content-Type'].should == 'text/html'
|
201
|
-
end
|
202
|
-
|
203
|
-
should 'not get an action with wrong parameters' do
|
204
|
-
got = Innate::Mock.get('/spec_index/bar')
|
205
|
-
got.status.should == 404
|
206
|
-
got.body.should == 'No action found at: "/bar"'
|
207
|
-
end
|
208
|
-
|
209
|
-
should 'get an action view if there is no method' do
|
210
|
-
got = Innate::Mock.get('/provide_template/only_view')
|
211
|
-
got.status.should == 200
|
212
|
-
got.body.strip.should == "Only template"
|
213
|
-
end
|
214
|
-
|
215
|
-
should 'not get an action view with params if there is no method' do
|
216
|
-
got = Innate::Mock.get('/provide_template/only_view/param')
|
217
|
-
got.status.should == 404
|
218
|
-
got.body.strip.should == 'No action found at: "/only_view/param"'
|
219
|
-
end
|
220
|
-
|
221
|
-
should 'use alias_view' do
|
222
|
-
assert_wish('/alias_view/aliased', "<h1>Hello, World!</h1>", 'text/html')
|
223
|
-
end
|
224
|
-
end
|