zorglub 0.0.9 → 0.1.0
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.
- checksums.yaml +5 -5
- data/Gemfile.lock +49 -34
- data/lib/zorglub.rb +4 -4
- data/lib/zorglub/app.rb +27 -31
- data/lib/zorglub/engines/file.rb +3 -3
- data/lib/zorglub/engines/haml.rb +3 -3
- data/lib/zorglub/engines/sass.rb +3 -3
- data/lib/zorglub/node.rb +75 -77
- data/lib/zorglub/rack_session.rb +1 -5
- data/lib/zorglub/session.rb +27 -31
- data/spec/app_spec.rb +21 -21
- data/spec/node_spec.rb +162 -154
- data/spec/spec_helper.rb +30 -25
- data/zorglub.gemspec +4 -4
- metadata +3 -4
data/lib/zorglub/rack_session.rb
CHANGED
data/lib/zorglub/session.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
# -*- coding: UTF-8 -*-
|
2
|
-
|
2
|
+
|
3
3
|
require 'securerandom'
|
4
|
-
|
4
|
+
|
5
5
|
module Zorglub
|
6
|
-
|
6
|
+
|
7
7
|
class Node
|
8
|
-
|
8
|
+
|
9
9
|
@sessions = {}
|
10
|
-
|
10
|
+
|
11
11
|
class << self
|
12
12
|
attr_reader :sessions
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def session
|
16
16
|
@session ||= SessionHash.new @request, @response, Node.sessions, app.opt(:session_options)
|
17
17
|
end
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
class SessionHash < Hash
|
21
|
-
|
21
|
+
|
22
22
|
def initialize req, resp, sessions, options
|
23
23
|
@request = req
|
24
24
|
@response = resp
|
@@ -27,49 +27,49 @@ module Zorglub
|
|
27
27
|
@options = options
|
28
28
|
super()
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def [] key
|
32
32
|
load_data!
|
33
33
|
super key
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def has_key? key
|
37
37
|
load_data!
|
38
38
|
super key
|
39
39
|
end
|
40
40
|
alias :key? :has_key?
|
41
41
|
alias :include? :has_key?
|
42
|
-
|
42
|
+
|
43
43
|
def []= key, value
|
44
44
|
load_data!
|
45
45
|
super key, value
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
def clear
|
49
49
|
load_data!
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
50
|
+
# @response.delete_cookie @options[:key]
|
51
|
+
# @sessions.delete @sid
|
52
|
+
# @sid = nil
|
53
53
|
super
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
def to_hash
|
57
57
|
load_data!
|
58
58
|
h = {}.replace(self)
|
59
59
|
h.delete_if { |k,v| v.nil? }
|
60
60
|
h
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
def update hash
|
64
64
|
load_data!
|
65
65
|
super stringify_keys(hash)
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
def delete key
|
69
69
|
load_data!
|
70
70
|
super key
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
def inspect
|
74
74
|
if loaded?
|
75
75
|
super
|
@@ -77,22 +77,22 @@ module Zorglub
|
|
77
77
|
"#<#{self.class}:0x#{self.object_id.to_s(16)} not yet loaded>"
|
78
78
|
end
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
def exists?
|
82
82
|
( loaded? ? @sessions.has_key?(@sid) : false )
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
85
|
def loaded?
|
86
86
|
not @sid.nil?
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
89
|
def empty?
|
90
90
|
load_data!
|
91
91
|
super
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
94
|
private
|
95
|
-
|
95
|
+
|
96
96
|
def load_data!
|
97
97
|
return if loaded?
|
98
98
|
if @options[:enabled]
|
@@ -106,7 +106,7 @@ module Zorglub
|
|
106
106
|
@sid = sid
|
107
107
|
end
|
108
108
|
end
|
109
|
-
|
109
|
+
|
110
110
|
def stringify_keys other
|
111
111
|
hash = {}
|
112
112
|
other.each do |key, value|
|
@@ -114,12 +114,12 @@ module Zorglub
|
|
114
114
|
end
|
115
115
|
hash
|
116
116
|
end
|
117
|
-
|
117
|
+
|
118
118
|
def generate_sid!
|
119
119
|
begin sid = sid_algorithm end while @sessions.has_key? sid
|
120
120
|
sid
|
121
121
|
end
|
122
|
-
|
122
|
+
|
123
123
|
begin
|
124
124
|
require 'securerandom'
|
125
125
|
# Using SecureRandom, optional length.
|
@@ -148,9 +148,5 @@ module Zorglub
|
|
148
148
|
Digest::SHA2.hexdigest(entropy.join)
|
149
149
|
end
|
150
150
|
end
|
151
|
-
#
|
152
151
|
end
|
153
|
-
#
|
154
152
|
end
|
155
|
-
#
|
156
|
-
# EOF
|
data/spec/app_spec.rb
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
# -*- coding: UTF-8 -*-
|
2
|
-
|
2
|
+
|
3
3
|
require 'spec_helper'
|
4
|
-
|
4
|
+
|
5
5
|
describe Zorglub do
|
6
|
-
|
6
|
+
|
7
7
|
describe Zorglub::App do
|
8
|
-
|
8
|
+
|
9
9
|
it "map should add a mapped node" do
|
10
|
-
APP.at("/temp").
|
10
|
+
expect(APP.at("/temp")).to be_nil
|
11
11
|
APP.map "/temp", Temp
|
12
|
-
APP.at("/temp").
|
12
|
+
expect(APP.at("/temp")).to be Temp
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
it "delete should delete a mapped node" do
|
16
|
-
APP.at("/temp").
|
16
|
+
expect(APP.at("/temp")).to be Temp
|
17
17
|
APP.delete "/temp"
|
18
|
-
APP.at("/temp").
|
18
|
+
expect(APP.at("/temp")).to be_nil
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
it "at should return mapped node" do
|
22
|
-
APP.at("/node1").
|
22
|
+
expect(APP.at("/node1")).to be Node1
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
it "at should return nil if no Node mapped" do
|
26
|
-
APP.at("/none").
|
26
|
+
expect(APP.at("/none")).to be_nil
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
it "to should return path to node" do
|
30
|
-
APP.to(Node1).
|
30
|
+
expect(APP.to(Node1)).to eq "/node1"
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
it "to should return nil if not an existing Node" do
|
34
|
-
APP.to(nil).
|
34
|
+
expect(APP.to(nil)).to be_nil
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
it "to_hash should return a correct hash" do
|
38
|
-
APP.to_hash["/node1"].
|
38
|
+
expect(APP.to_hash["/node1"]).to be Node1
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
end
|
data/spec/node_spec.rb
CHANGED
@@ -1,307 +1,315 @@
|
|
1
1
|
# -*- coding: UTF-8 -*-
|
2
|
-
|
2
|
+
|
3
3
|
require 'spec_helper'
|
4
|
-
|
4
|
+
|
5
5
|
def clean_static_path
|
6
6
|
static_base_path = Node0.app.static_base_path
|
7
7
|
Dir.glob( File.join(static_base_path,'**','*') ).each do |f| File.unlink f if File.file? f end
|
8
8
|
Dir.glob( File.join(static_base_path,'*') ).each do |d| Dir.rmdir d end
|
9
9
|
Dir.rmdir static_base_path if File.directory? static_base_path
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
describe Zorglub do
|
13
|
-
|
13
|
+
|
14
14
|
describe Zorglub::Node do
|
15
|
-
|
15
|
+
|
16
16
|
before(:all) do
|
17
17
|
clean_static_path
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
after(:all) do
|
21
21
|
clean_static_path
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
it "engine should return default Node's engine" do
|
25
|
-
Node0.engine.
|
25
|
+
expect(Node0.engine).to eq Node0.app.opt(:engine)
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
it "layout should return default Node's layout" do
|
29
|
-
Node0.layout.
|
29
|
+
expect(Node0.layout).to eq Node0.app.opt(:layout)
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
it "engine should return class defined Node's engine" do
|
33
|
-
Node1.engine.
|
34
|
-
Node3.engine.
|
33
|
+
expect(Node1.engine).to eq "engine-1"
|
34
|
+
expect(Node3.engine).to eq "engine-2"
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
it "layout should return class defined Node's layout" do
|
38
|
-
Node1.layout.
|
39
|
-
Node3.layout.
|
38
|
+
expect(Node1.layout).to eq "layout-1"
|
39
|
+
expect(Node3.layout).to eq "layout-2"
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
it "engine should return engine inherited from Node2" do
|
43
|
-
Node2.engine.
|
43
|
+
expect(Node2.engine).to eq "engine-1"
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
it "layout should return layout inherited from Node2" do
|
47
|
-
Node2.layout.
|
47
|
+
expect(Node2.layout).to eq "layout-1"
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
it "r should build a well formed path" do
|
51
|
-
Node1.r(1,'arg2',"some").
|
51
|
+
expect(Node1.r(1,'arg2',"some")).to eq "/node1/1/arg2/some"
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
it "instance level map should work" do
|
55
55
|
r = Node0.my_call '/with_2args/1/2'
|
56
56
|
h = YAML.load r.body[0]
|
57
|
-
h[:map].
|
57
|
+
expect(h[:map]).to eq '/node0'
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
it "should return err404 response when no method found" do
|
61
|
-
Node0.respond_to?('noresponse').
|
61
|
+
expect(Node0.respond_to?('noresponse')).to be_falsey
|
62
62
|
r = Node0.my_call '/noresponse'
|
63
|
-
r.status.
|
63
|
+
expect(r.status).to eq 404
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
it "simple method should respond" do
|
67
67
|
r = Node0.my_call '/hello'
|
68
|
-
r.status.
|
69
|
-
r.body[0].
|
68
|
+
expect(r.status).to eq 200
|
69
|
+
expect(r.body[0]).to eq 'world'
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
it "instance level args should work" do
|
73
73
|
r = Node0.my_call '/with_2args/1/2'
|
74
74
|
h = YAML.load r.body[0]
|
75
|
-
h[:args][0].
|
76
|
-
h[:args][1].
|
75
|
+
expect(h[:args][0]).to eq '1'
|
76
|
+
expect(h[:args][1]).to eq '2'
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
it "should raise error when too much arguments" do
|
80
|
-
lambda{ r = Node0.my_call '/with_2args/1/2/3' }.
|
80
|
+
expect(lambda{ r = Node0.my_call '/with_2args/1/2/3' }).to raise_error ArgumentError
|
81
81
|
end
|
82
|
-
|
82
|
+
|
83
83
|
it "layout proc, method level layout and engine definitions should work" do
|
84
84
|
r = Node0.my_call '/index'
|
85
|
-
r.status.
|
85
|
+
expect(r.status).to eq 200
|
86
86
|
h = YAML.load r.body[0]
|
87
87
|
ly = File.join Node0.app.layout_base_path, Node0.layout
|
88
88
|
vu = File.join Node0.app.view_base_path, Node0.r, 'index'
|
89
|
-
h[:path].
|
90
|
-
h[:layout].
|
91
|
-
h[:view].
|
89
|
+
expect(h[:path]).to eq ly
|
90
|
+
expect(h[:layout]).to eq ly
|
91
|
+
expect(h[:view]).to eq vu
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
94
|
it "layout proc, method level layout and engine definitions should work" do
|
95
95
|
r = Node1.my_call '/index'
|
96
|
-
r.status.
|
96
|
+
expect(r.status).to eq 200
|
97
97
|
h = YAML.load r.body[0]
|
98
98
|
ly = File.join Node1.app.layout_base_path, 'main.spec'
|
99
99
|
vu = File.join Node1.app.view_base_path, Node1.r, 'index.spec'
|
100
|
-
h[:path].
|
101
|
-
h[:layout].
|
102
|
-
h[:view].
|
100
|
+
expect(h[:path]).to eq ly
|
101
|
+
expect(h[:layout]).to eq ly
|
102
|
+
expect(h[:view]).to eq vu
|
103
103
|
end
|
104
|
-
|
104
|
+
|
105
105
|
it "before_all hook should work" do
|
106
106
|
Node3.before = 0
|
107
107
|
Node3.after = 0
|
108
|
-
Node3.before.
|
109
|
-
Node3.
|
110
|
-
Node3.before.
|
111
|
-
Node3.
|
112
|
-
Node3.before.
|
113
|
-
Node3.
|
114
|
-
Node3.before.
|
115
|
-
end
|
116
|
-
|
108
|
+
expect(Node3.before).to eq 0
|
109
|
+
expect(Node3.my_call_i('/index')).to eq 1
|
110
|
+
expect(Node3.before).to eq 1
|
111
|
+
expect(Node3.my_call_i('/index')).to eq 1
|
112
|
+
expect(Node3.before).to eq 2
|
113
|
+
expect(Node3.my_call_i('/index')).to eq 1
|
114
|
+
expect(Node3.before).to eq 3
|
115
|
+
end
|
116
|
+
|
117
117
|
it "after_all hook should work" do
|
118
118
|
Node3.before = 0
|
119
119
|
Node3.after = 0
|
120
|
-
Node3.after.
|
121
|
-
Node3.
|
122
|
-
Node3.after.
|
123
|
-
Node3.
|
124
|
-
Node3.after.
|
125
|
-
Node3.
|
126
|
-
Node3.after.
|
127
|
-
end
|
128
|
-
|
120
|
+
expect(Node3.after).to eq 0
|
121
|
+
expect(Node3.my_call_i('/index')).to eq 1
|
122
|
+
expect(Node3.after).to eq 1
|
123
|
+
expect(Node3.my_call_i('/index')).to eq 1
|
124
|
+
expect(Node3.after).to eq 2
|
125
|
+
expect(Node3.my_call_i('/index')).to eq 1
|
126
|
+
expect(Node3.after).to eq 3
|
127
|
+
end
|
128
|
+
|
129
129
|
it "inherited before_all hook should work" do
|
130
130
|
Node3.before = 0
|
131
131
|
Node3.after = 0
|
132
|
-
Node3.before.
|
133
|
-
Node8.
|
134
|
-
Node3.before.
|
135
|
-
Node8.
|
136
|
-
Node3.before.
|
137
|
-
Node8.
|
138
|
-
Node3.before.
|
139
|
-
end
|
140
|
-
|
132
|
+
expect(Node3.before).to eq 0
|
133
|
+
expect(Node8.my_call_i('/index')).to eq 1
|
134
|
+
expect(Node3.before).to eq 1
|
135
|
+
expect(Node8.my_call_i('/index')).to eq 1
|
136
|
+
expect(Node3.before).to eq 2
|
137
|
+
expect(Node8.my_call_i('/index')).to eq 1
|
138
|
+
expect(Node3.before).to eq 3
|
139
|
+
end
|
140
|
+
|
141
141
|
it "inherited after_all hook should work" do
|
142
142
|
Node3.before = 0
|
143
143
|
Node3.after = 0
|
144
|
-
Node3.after.
|
145
|
-
Node8.
|
146
|
-
Node3.after.
|
147
|
-
Node8.
|
148
|
-
Node3.after.
|
149
|
-
Node8.
|
150
|
-
Node3.after.
|
151
|
-
end
|
152
|
-
|
144
|
+
expect(Node3.after).to eq 0
|
145
|
+
expect(Node8.my_call_i('/index')).to eq 1
|
146
|
+
expect(Node3.after).to eq 1
|
147
|
+
expect(Node8.my_call_i('/index')).to eq 1
|
148
|
+
expect(Node3.after).to eq 2
|
149
|
+
expect(Node8.my_call_i('/index')).to eq 1
|
150
|
+
expect(Node3.after).to eq 3
|
151
|
+
end
|
152
|
+
|
153
153
|
it "should find view and layout and render them" do
|
154
154
|
r = Node0.my_call '/do_render'
|
155
|
-
r.status.
|
156
|
-
r.body[0].
|
155
|
+
expect(r.status).to eq 200
|
156
|
+
expect(r.body[0]).to eq "layout_start view_content layout_end"
|
157
157
|
end
|
158
|
-
|
158
|
+
|
159
159
|
it "default mime-type should be text/html" do
|
160
160
|
r = Node0.my_call '/index'
|
161
|
-
r.header['Content-type'].
|
161
|
+
expect(r.header['Content-type']).to eq 'text/html'
|
162
162
|
end
|
163
|
-
|
163
|
+
|
164
164
|
it "should be able to override mime-type" do
|
165
165
|
r = Node0.my_call '/do_render'
|
166
|
-
r.header['Content-type'].
|
166
|
+
expect(r.header['Content-type']).to eq 'text/view'
|
167
167
|
end
|
168
|
-
|
168
|
+
|
169
169
|
it "should be able to override through rack response mime-type" do
|
170
170
|
r = Node0.my_call '/do_content_type'
|
171
|
-
r.header['Content-type'].
|
171
|
+
expect(r.header['Content-type']).to eq 'text/mine'
|
172
172
|
end
|
173
|
-
|
173
|
+
|
174
174
|
it "partial should render correctly" do
|
175
|
-
Node0.partial({},:do_partial, 1, 2).
|
175
|
+
expect(Node0.partial({},:do_partial, 1, 2)).to eq 'partial_content'
|
176
176
|
end
|
177
|
-
|
177
|
+
|
178
178
|
it "method level view should work" do
|
179
|
-
Node0.partial({},:other_view).
|
179
|
+
expect(Node0.partial({},:other_view)).to eq 'partial_content'
|
180
180
|
end
|
181
|
-
|
181
|
+
|
182
182
|
it "partial with hooks should be default" do
|
183
183
|
Node3.before = 0
|
184
184
|
Node3.after = 0
|
185
|
-
Node3.partial({},:do_partial,1,2).
|
186
|
-
Node3.before.
|
187
|
-
Node3.after.
|
185
|
+
expect(Node3.partial({},:do_partial,1,2)).to eq 'partial_content'
|
186
|
+
expect(Node3.before).to eq 1
|
187
|
+
expect(Node3.after).to eq 1
|
188
188
|
end
|
189
|
-
|
189
|
+
|
190
190
|
it "partial without hooks should work" do
|
191
191
|
Node3.before = 0
|
192
192
|
Node3.after = 0
|
193
|
-
Node3.partial({:no_hooks=>true},:do_partial,1,2).
|
194
|
-
Node3.before.
|
195
|
-
Node3.after.
|
193
|
+
expect(Node3.partial({:no_hooks=>true},:do_partial,1,2)).to eq 'partial_content'
|
194
|
+
expect(Node3.before).to eq 0
|
195
|
+
expect(Node3.after).to eq 0
|
196
196
|
end
|
197
|
-
|
197
|
+
|
198
198
|
it "static pages should be generated" do
|
199
199
|
r = Node6.my_call '/do_static'
|
200
|
-
r.body[0].
|
201
|
-
r.header['Content-type'].
|
200
|
+
expect(r.body[0]).to eq 'VAL 1'
|
201
|
+
expect(r.header['Content-type']).to eq 'text/static'
|
202
202
|
r = Node6.my_call '/do_static'
|
203
|
-
r.body[0].
|
204
|
-
r.header['Content-type'].
|
203
|
+
expect(r.body[0]).to eq 'VAL 1'
|
204
|
+
expect(r.header['Content-type']).to eq 'text/static'
|
205
205
|
r = Node6.my_call '/do_static'
|
206
|
-
r.body[0].
|
207
|
-
r.header['Content-type'].
|
206
|
+
expect(r.body[0]).to eq 'VAL 1'
|
207
|
+
expect(r.header['Content-type']).to eq 'text/static'
|
208
208
|
r = Node6.my_call '/no_static'
|
209
|
-
r.body[0].
|
210
|
-
r.header['Content-type'].
|
209
|
+
expect(r.body[0]).to eq 'VAL 4'
|
210
|
+
expect(r.header['Content-type']).to eq 'text/static'
|
211
211
|
r = Node6.my_call '/do_static'
|
212
|
-
r.body[0].
|
213
|
-
r.header['Content-type'].
|
212
|
+
expect(r.body[0]).to eq 'VAL 1'
|
213
|
+
expect(r.header['Content-type']).to eq 'text/static'
|
214
214
|
Node6.static! true, 0.000001
|
215
215
|
sleep 0.0001
|
216
216
|
r = Node6.my_call '/do_static'
|
217
|
-
r.body[0].
|
218
|
-
r.header['Content-type'].
|
217
|
+
expect(r.body[0]).to eq 'VAL 6'
|
218
|
+
expect(r.header['Content-type']).to eq 'text/static'
|
219
219
|
end
|
220
|
-
|
220
|
+
|
221
221
|
it "redirect should work" do
|
222
222
|
r = Node0.my_call '/do_redirect'
|
223
|
-
r.status.
|
224
|
-
r.header['location'].
|
223
|
+
expect(r.status).to eq 302
|
224
|
+
expect(r.header['location']).to eq Node0.r(:do_partial,1,2,3)
|
225
225
|
end
|
226
|
-
|
226
|
+
|
227
227
|
it "no_layout! should be inherited" do
|
228
|
-
Node5.layout.
|
228
|
+
expect(Node5.layout).to be_nil
|
229
229
|
end
|
230
|
-
|
230
|
+
|
231
231
|
it "cli_vals should be inherited and extended" do
|
232
232
|
r = Node5.my_call '/index'
|
233
233
|
vars = YAML.load r.body[0]
|
234
|
-
vars.
|
235
|
-
vars[7].
|
234
|
+
expect(vars).to eq ['js0','js1','js3','jsx','css0','css1','css2']
|
235
|
+
expect(vars[7]).to be_nil
|
236
236
|
end
|
237
|
-
|
237
|
+
|
238
238
|
it "cli_vals should be extended at method level" do
|
239
239
|
r = Node4.my_call '/more'
|
240
240
|
vars = YAML.load r.body[0]
|
241
|
-
vars.
|
242
|
-
vars[3].
|
241
|
+
expect(vars).to eq ['js0','js1','js2']
|
242
|
+
expect(vars[3]).to be_nil
|
243
243
|
end
|
244
|
-
|
244
|
+
|
245
245
|
it "cli_vals should be untouched" do
|
246
246
|
r = Node4.my_call '/index'
|
247
247
|
vars = YAML.load r.body[0]
|
248
|
-
vars.
|
249
|
-
vars[2].
|
248
|
+
expect(vars).to eq ['js0','js1']
|
249
|
+
expect(vars[2]).to be_nil
|
250
250
|
r = Node5.my_call '/index'
|
251
251
|
vars = YAML.load r.body[0]
|
252
|
-
vars.
|
253
|
-
vars[7].
|
252
|
+
expect(vars).to eq ['js0','js1','js3','jsx','css0','css1','css2']
|
253
|
+
expect(vars[7]).to be_nil
|
254
254
|
end
|
255
|
-
|
255
|
+
|
256
256
|
it "ext definition and file engine should work" do
|
257
257
|
r = Node0.my_call '/xml_file'
|
258
|
-
r.body[0].
|
259
|
-
r.header['Content-type'].
|
258
|
+
expect(r.body[0]).to eq "<xml>file<\/xml>\n"
|
259
|
+
expect(r.header['Content-type']).to eq 'application/xml'
|
260
260
|
r = Node0.my_call '/plain_file'
|
261
|
-
r.body[0].
|
262
|
-
r.header['Content-type'].
|
261
|
+
expect(r.body[0]).to eq "plain file\n"
|
262
|
+
expect(r.header['Content-type']).to eq 'text/plain'
|
263
263
|
end
|
264
|
-
|
264
|
+
|
265
265
|
it "no view no layout should work as well" do
|
266
266
|
r = Node0.my_call '/no_view_no_layout'
|
267
|
-
r.body[0].
|
267
|
+
expect(r.body[0]).to eq "hello world"
|
268
268
|
end
|
269
|
-
|
269
|
+
|
270
270
|
it "haml engine should work" do
|
271
271
|
Node0.app.opt! :engines_cache_enabled, false
|
272
272
|
r = Node0.my_call '/engines/haml'
|
273
|
-
r.body[0].
|
273
|
+
expect(r.body[0]).to eq "<h1>Hello world</h1>\n"
|
274
274
|
Node0.app.opt! :engines_cache_enabled, true
|
275
275
|
r = Node0.my_call '/engines/haml'
|
276
|
-
r.body[0].
|
276
|
+
expect(r.body[0]).to eq "<h1>Hello world</h1>\n"
|
277
277
|
end
|
278
|
-
|
278
|
+
|
279
279
|
it "sass engine should work" do
|
280
280
|
Node0.app.opt! :engines_cache_enabled, true
|
281
281
|
r = Node0.my_call '/engines/sass'
|
282
|
-
r.body[0].
|
282
|
+
expect(r.body[0]).to eq "vbar{width:80%;height:23px}vbar ul{list-style-type:none}vbar li{float:left}vbar li a{font-weight:bold}\n"
|
283
283
|
Node0.app.opt! :engines_cache_enabled, false
|
284
284
|
r = Node0.my_call '/engines/sass'
|
285
|
-
r.body[0].
|
285
|
+
expect(r.body[0]).to eq "vbar{width:80%;height:23px}vbar ul{list-style-type:none}vbar li{float:left}vbar li a{font-weight:bold}\n"
|
286
286
|
end
|
287
|
-
|
287
|
+
|
288
288
|
it "view_base_path! should work" do
|
289
289
|
r = Node7.my_call '/view_path'
|
290
290
|
h = YAML.load r.body[0]
|
291
|
-
h[:view].
|
291
|
+
expect(h[:view]).to eq File.join(Node7.app.opt(:root), 'alt','do_render')
|
292
292
|
end
|
293
|
-
|
293
|
+
|
294
294
|
it "layout_base_path! should work" do
|
295
295
|
r = Node7.my_call '/view_path'
|
296
296
|
h = YAML.load r.body[0]
|
297
|
-
h[:layout].
|
297
|
+
expect(h[:layout]).to eq File.join(Node7.app.opt(:root), 'alt','layout','default')
|
298
298
|
end
|
299
|
-
|
299
|
+
|
300
300
|
it "debug out should work" do
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
301
|
+
stderr0= $stderr.dup
|
302
|
+
stderrs = StringIO.new
|
303
|
+
$stderr = stderrs
|
304
|
+
begin
|
305
|
+
APP.opt! :debug, true
|
306
|
+
Node0.my_call '/hello'
|
307
|
+
ensure
|
308
|
+
$stderr = stderr0
|
309
|
+
end
|
310
|
+
expect(stderrs.string.include?('spec/data/view/node0/hello')).to be true
|
311
|
+
end
|
312
|
+
|
305
313
|
end
|
306
|
-
|
314
|
+
|
307
315
|
end
|