utopia 0.12.6 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -2
- data/Gemfile +6 -0
- data/README.md +48 -14
- data/Rakefile +5 -0
- data/bin/utopia +132 -15
- data/lib/utopia.rb +13 -10
- data/lib/utopia/content.rb +140 -0
- data/lib/utopia/content/link.rb +124 -0
- data/lib/utopia/content/links.rb +228 -0
- data/lib/utopia/content/node.rb +387 -0
- data/lib/utopia/content/processor.rb +128 -0
- data/lib/utopia/content/tag.rb +102 -0
- data/lib/utopia/controller.rb +137 -0
- data/lib/utopia/controller/action.rb +112 -0
- data/lib/utopia/controller/base.rb +174 -0
- data/lib/utopia/{middleware/controller → controller}/variables.rb +36 -38
- data/lib/utopia/exception_handler.rb +79 -0
- data/lib/utopia/extensions/array.rb +2 -2
- data/lib/utopia/localization.rb +143 -0
- data/lib/utopia/mail_exceptions.rb +136 -0
- data/lib/utopia/middleware.rb +7 -22
- data/lib/utopia/path.rb +150 -60
- data/lib/utopia/redirector.rb +152 -0
- data/lib/utopia/{extensions/hash.rb → session.rb} +4 -6
- data/lib/utopia/session/encrypted_cookie.rb +46 -48
- data/lib/utopia/{middleware/directory_index.rb → session/lazy_hash.rb} +44 -27
- data/lib/utopia/static.rb +255 -0
- data/lib/utopia/tags/deferred.rb +12 -8
- data/lib/utopia/tags/environment.rb +18 -6
- data/lib/utopia/tags/node.rb +12 -8
- data/lib/utopia/tags/override.rb +12 -12
- data/lib/utopia/version.rb +1 -1
- data/setup/.bowerrc +3 -0
- data/{lib/utopia/setup → setup}/Gemfile +1 -1
- data/setup/Rakefile +4 -0
- data/{lib/utopia/setup → setup}/cache/head/readme.txt +0 -0
- data/{lib/utopia/setup → setup}/cache/meta/readme.txt +0 -0
- data/setup/config.ru +64 -0
- data/{lib/utopia/setup → setup}/lib/readme.txt +0 -0
- data/{lib/utopia/setup → setup}/pages/_heading.xnode +0 -0
- data/{lib/utopia/setup → setup}/pages/_page.xnode +1 -1
- data/{lib/utopia/setup → setup}/pages/_static/icon.png +0 -0
- data/setup/pages/_static/site.css +70 -0
- data/{lib/utopia/setup → setup}/pages/errors/exception.xnode +0 -0
- data/{lib/utopia/setup → setup}/pages/errors/file-not-found.xnode +0 -0
- data/{lib/utopia/setup → setup}/pages/links.yaml +0 -0
- data/setup/pages/welcome/index.xnode +17 -0
- data/{lib/utopia/setup → setup}/public/readme.txt +0 -0
- data/spec/utopia/content/link_spec.rb +108 -0
- data/spec/utopia/content/links/foo/index.xnode +0 -0
- data/spec/utopia/content/links/foo/links.yaml +2 -0
- data/spec/utopia/content/links/foo/test.de.xnode +0 -0
- data/spec/utopia/content/links/foo/test.en.xnode +0 -0
- data/spec/utopia/content/links/links.yaml +9 -0
- data/spec/utopia/content/links/welcome.xnode +0 -0
- data/spec/utopia/content/localized/five/index.en.xnode +0 -0
- data/spec/utopia/content/localized/four/index.en.xnode +0 -0
- data/spec/utopia/content/localized/four/index.zh.xnode +0 -0
- data/spec/utopia/content/localized/four/links.yaml +4 -0
- data/spec/utopia/content/localized/links.yaml +16 -0
- data/spec/utopia/content/localized/one.xnode +0 -0
- data/spec/utopia/content/localized/three/index.xnode +0 -0
- data/spec/utopia/content/localized/two.en.xnode +0 -0
- data/spec/utopia/content/localized/two.zh.xnode +0 -0
- data/spec/utopia/content/node/ordered/first.xnode +0 -0
- data/spec/utopia/content/node/ordered/index.xnode +0 -0
- data/spec/utopia/content/node/ordered/links.yaml +4 -0
- data/spec/utopia/content/node/ordered/second.xnode +0 -0
- data/spec/utopia/content/node/related/foo.en.xnode +0 -0
- data/spec/utopia/content/node/related/foo.ja.xnode +0 -0
- data/spec/utopia/content/node/related/links.yaml +4 -0
- data/spec/utopia/content/node_spec.rb +63 -0
- data/spec/utopia/{middleware/content_spec.rb → content/processor_spec.rb} +34 -23
- data/spec/utopia/content_spec.rb +87 -0
- data/spec/utopia/content_spec.ru +10 -0
- data/spec/utopia/{middleware/controller_spec.rb → controller_spec.rb} +61 -16
- data/spec/utopia/controller_spec.ru +4 -0
- data/spec/utopia/extensions_spec.rb +6 -17
- data/spec/utopia/localization_spec.rb +60 -0
- data/spec/utopia/localization_spec.ru +11 -0
- data/{lib/utopia/tags.rb → spec/utopia/middleware_spec.rb} +8 -14
- data/spec/utopia/{middleware/content_root → pages}/_heading.xnode +0 -0
- data/spec/utopia/pages/content/_show-value.xnode +1 -0
- data/spec/utopia/pages/content/test-partial.xnode +1 -0
- data/spec/utopia/pages/controller/controller.rb +28 -0
- data/spec/utopia/pages/controller/index.xnode +1 -0
- data/spec/utopia/pages/controller/nested/controller.rb +4 -0
- data/spec/utopia/{middleware/content_root → pages}/index.xnode +0 -0
- data/spec/utopia/pages/localized.de.txt +1 -0
- data/spec/utopia/pages/localized.en.txt +1 -0
- data/spec/utopia/pages/localized.jp.txt +1 -0
- data/spec/utopia/pages/node/index.xnode +1 -0
- data/spec/utopia/pages/test.txt +1 -0
- data/spec/utopia/path_spec.rb +109 -0
- data/spec/utopia/rack_spec.rb +2 -0
- data/spec/utopia/session_spec.rb +82 -0
- data/spec/utopia/session_spec.ru +20 -0
- data/spec/utopia/spec_helper.rb +16 -0
- data/{lib/utopia/extensions/string.rb → spec/utopia/static_spec.rb} +24 -15
- data/spec/utopia/static_spec.ru +4 -0
- data/utopia.gemspec +3 -3
- metadata +138 -54
- data/lib/utopia/extensions/regexp.rb +0 -33
- data/lib/utopia/link.rb +0 -288
- data/lib/utopia/middleware/all.rb +0 -33
- data/lib/utopia/middleware/content.rb +0 -157
- data/lib/utopia/middleware/content/node.rb +0 -386
- data/lib/utopia/middleware/content/processor.rb +0 -123
- data/lib/utopia/middleware/controller.rb +0 -130
- data/lib/utopia/middleware/controller/action.rb +0 -121
- data/lib/utopia/middleware/controller/base.rb +0 -184
- data/lib/utopia/middleware/exception_handler.rb +0 -80
- data/lib/utopia/middleware/localization.rb +0 -147
- data/lib/utopia/middleware/localization/name.rb +0 -69
- data/lib/utopia/middleware/mail_exceptions.rb +0 -138
- data/lib/utopia/middleware/redirector.rb +0 -146
- data/lib/utopia/middleware/requester.rb +0 -126
- data/lib/utopia/middleware/static.rb +0 -295
- data/lib/utopia/setup.rb +0 -60
- data/lib/utopia/setup/config.ru +0 -47
- data/lib/utopia/setup/pages/_static/background.png +0 -0
- data/lib/utopia/setup/pages/_static/site.css +0 -48
- data/lib/utopia/setup/pages/welcome/index.xnode +0 -7
- data/lib/utopia/tag.rb +0 -105
- data/lib/utopia/tags/all.rb +0 -34
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Copyright, 2014, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require_relative '../spec_helper'
|
22
|
+
|
23
|
+
require 'utopia/content'
|
24
|
+
|
25
|
+
module Utopia::ContentSpec
|
26
|
+
describe Utopia::Content::Node do
|
27
|
+
let(:root) {File.expand_path("../node", __FILE__)}
|
28
|
+
let(:content) {Utopia::Content.new(lambda{}, root: root)}
|
29
|
+
|
30
|
+
it "should list siblings in correct order" do
|
31
|
+
node = content.lookup_node(Utopia::Path['/ordered/first'])
|
32
|
+
|
33
|
+
links = node.sibling_links
|
34
|
+
|
35
|
+
expect(links.size).to be == 2
|
36
|
+
expect(links[0].name).to be == 'first'
|
37
|
+
expect(links[1].name).to be == 'second'
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should list all links in correct order" do
|
41
|
+
node = content.lookup_node(Utopia::Path['/ordered/index'])
|
42
|
+
|
43
|
+
links = node.links
|
44
|
+
|
45
|
+
expect(links.size).to be == 2
|
46
|
+
expect(links[0].name).to be == 'first'
|
47
|
+
expect(links[1].name).to be == 'second'
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should list related links" do
|
51
|
+
node = content.lookup_node(Utopia::Path['/related/foo.en'])
|
52
|
+
|
53
|
+
links = node.related_links
|
54
|
+
|
55
|
+
expect(links.size).to be == 2
|
56
|
+
expect(links[0].name).to be == 'foo'
|
57
|
+
expect(links[0].variant).to be == 'en'
|
58
|
+
|
59
|
+
expect(links[1].name).to be == 'foo'
|
60
|
+
expect(links[1].variant).to be == 'ja'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
|
3
|
+
# Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
4
|
#
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -18,12 +20,11 @@
|
|
18
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
21
|
# THE SOFTWARE.
|
20
22
|
|
21
|
-
|
22
|
-
require 'utopia/middleware/content'
|
23
|
+
require_relative '../spec_helper'
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
require 'utopia/content/link'
|
26
|
+
|
27
|
+
module Utopia::Content::ProcessorSpec
|
27
28
|
class TestDelegate
|
28
29
|
def initialize
|
29
30
|
@events = []
|
@@ -36,29 +37,40 @@ module Utopia::Middleware::ContentSpec
|
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
39
|
-
describe Utopia::
|
40
|
+
describe Utopia::Content::Processor do
|
41
|
+
it "should format open tags correctly" do
|
42
|
+
foo_tag = Utopia::Content::Tag.new("foo", bar: nil, baz: 'bob')
|
43
|
+
|
44
|
+
expect(foo_tag[:bar]).to be nil
|
45
|
+
expect(foo_tag[:baz]).to be == 'bob'
|
46
|
+
|
47
|
+
expect(foo_tag.to_s('content')).to be == '<foo bar baz="bob">content</foo>'
|
48
|
+
end
|
49
|
+
|
40
50
|
it "should parse single tag" do
|
41
51
|
delegate = TestDelegate.new
|
42
|
-
processor = Utopia::
|
52
|
+
processor = Utopia::Content::Processor.new(delegate)
|
43
53
|
|
44
54
|
processor.parse %Q{<foo></foo>}
|
45
55
|
|
46
|
-
foo_tag = Utopia::Tag.new("foo")
|
56
|
+
foo_tag = Utopia::Content::Tag.new("foo")
|
47
57
|
expected_events = [
|
48
58
|
[:tag_begin, foo_tag],
|
49
59
|
[:tag_end, foo_tag],
|
50
60
|
]
|
51
61
|
|
52
62
|
expect(delegate.events).to be == expected_events
|
63
|
+
|
64
|
+
expect(foo_tag.to_s)
|
53
65
|
end
|
54
66
|
|
55
67
|
it "should parse and escape text" do
|
56
68
|
delegate = TestDelegate.new
|
57
|
-
processor = Utopia::
|
69
|
+
processor = Utopia::Content::Processor.new(delegate)
|
58
70
|
|
59
71
|
processor.parse %Q{<foo>Bob & Barley<!-- Comment --><![CDATA[Hello & World]]></foo>}
|
60
72
|
|
61
|
-
foo_tag = Utopia::Tag.new("foo")
|
73
|
+
foo_tag = Utopia::Content::Tag.new("foo")
|
62
74
|
expected_events = [
|
63
75
|
[:tag_begin, foo_tag],
|
64
76
|
[:cdata, "Bob & Barley"],
|
@@ -69,20 +81,19 @@ module Utopia::Middleware::ContentSpec
|
|
69
81
|
|
70
82
|
expect(delegate.events).to be == expected_events
|
71
83
|
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe Utopia::Middleware::Content do
|
75
|
-
it "Should parse file and expand variables" do
|
76
|
-
root = File.expand_path("../content_root", __FILE__)
|
77
|
-
content = Utopia::Middleware::Content.new(APP, :root => root)
|
78
84
|
|
79
|
-
|
80
|
-
|
81
|
-
|
85
|
+
it "should fail with incorrect closing tag" do
|
86
|
+
delegate = TestDelegate.new
|
87
|
+
processor = Utopia::Content::Processor.new(delegate)
|
88
|
+
|
89
|
+
expect{processor.parse %Q{<p>Foobar</dl>}}.to raise_exception(Utopia::Content::Processor::UnbalancedTagError)
|
90
|
+
end
|
82
91
|
|
83
|
-
|
84
|
-
|
85
|
-
|
92
|
+
it "should fail with unclosed tag" do
|
93
|
+
delegate = TestDelegate.new
|
94
|
+
processor = Utopia::Content::Processor.new(delegate)
|
95
|
+
|
96
|
+
expect{processor.parse %Q{<p>Foobar}}.to raise_exception(Utopia::Content::Processor::UnbalancedTagError)
|
86
97
|
end
|
87
98
|
end
|
88
99
|
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require_relative 'spec_helper'
|
22
|
+
|
23
|
+
require 'utopia/content'
|
24
|
+
|
25
|
+
module Utopia::ContentSpec
|
26
|
+
describe Utopia::Content do
|
27
|
+
include Rack::Test::Methods
|
28
|
+
|
29
|
+
let(:app) {Rack::Builder.parse_file(File.expand_path('../content_spec.ru', __FILE__)).first}
|
30
|
+
|
31
|
+
it "should get a local path" do
|
32
|
+
get '/node/index'
|
33
|
+
|
34
|
+
expect(last_response.body).to be == File.expand_path('../pages/node', __FILE__)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should successfully redirect to the index page" do
|
38
|
+
get '/'
|
39
|
+
|
40
|
+
expect(last_response.status).to be == 307
|
41
|
+
expect(last_response.headers['Location']).to be == '/index'
|
42
|
+
|
43
|
+
get '/content'
|
44
|
+
|
45
|
+
expect(last_response.status).to be == 307
|
46
|
+
expect(last_response.headers['Location']).to be == '/content/index'
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should successfully render the index page" do
|
50
|
+
get "/index"
|
51
|
+
|
52
|
+
expect(last_response.body).to be == '<h1>Hello World</h1>'
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should render partials correctly" do
|
56
|
+
get "/content/test-partial"
|
57
|
+
|
58
|
+
expect(last_response.body).to be == '10'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe Utopia::Content do
|
63
|
+
let(:root) {File.expand_path("../pages", __FILE__)}
|
64
|
+
let(:content) {Utopia::Content.new(lambda{}, root: root, cache_templates: true)}
|
65
|
+
|
66
|
+
it "should parse file and expand variables" do
|
67
|
+
path = Utopia::Path.create('/index')
|
68
|
+
node = content.lookup_node(path)
|
69
|
+
expect(node).to be_kind_of Utopia::Content::Node
|
70
|
+
|
71
|
+
output = StringIO.new
|
72
|
+
node.process!({}, output, {})
|
73
|
+
expect(output.string).to be == '<h1>Hello World</h1>'
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should fetch xml and use cache" do
|
77
|
+
node_path = File.expand_path('../pages/index.xnode', __FILE__)
|
78
|
+
|
79
|
+
template = content.fetch_xml(node_path)
|
80
|
+
|
81
|
+
expect(template).to be_kind_of Trenni::Template
|
82
|
+
|
83
|
+
# Check that the same object is returned:
|
84
|
+
expect(template).to be content.fetch_xml(node_path)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
|
1
3
|
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
4
|
#
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
@@ -18,13 +20,16 @@
|
|
18
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
21
|
# THE SOFTWARE.
|
20
22
|
|
23
|
+
require_relative 'spec_helper'
|
24
|
+
|
21
25
|
require 'rack/mock'
|
22
|
-
require '
|
26
|
+
require 'rack/test'
|
27
|
+
require 'utopia/controller'
|
23
28
|
|
24
|
-
module Utopia::
|
25
|
-
describe Utopia::
|
29
|
+
module Utopia::ControllerSpec
|
30
|
+
describe Utopia::Controller::Action do
|
26
31
|
it "should resolve callbacks" do
|
27
|
-
actions = Utopia::
|
32
|
+
actions = Utopia::Controller::Action.new
|
28
33
|
|
29
34
|
specific_action = actions.define(['a', 'b', 'c']) {puts 'specific_action'}
|
30
35
|
indirect_action = actions.define(['**']) {puts 'indirect_action'}
|
@@ -41,7 +46,7 @@ module Utopia::Middleware::ControllerSpec
|
|
41
46
|
end
|
42
47
|
|
43
48
|
it "should be greedy matching" do
|
44
|
-
actions = Utopia::
|
49
|
+
actions = Utopia::Controller::Action.new
|
45
50
|
|
46
51
|
greedy_action = actions.define(['**', 'r']) {puts 'greedy_action'}
|
47
52
|
|
@@ -49,10 +54,8 @@ module Utopia::Middleware::ControllerSpec
|
|
49
54
|
expect(actions.select(['r'])).to be_include greedy_action
|
50
55
|
end
|
51
56
|
end
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
class TestController < Utopia::Middleware::Controller::Base
|
57
|
+
|
58
|
+
class TestController < Utopia::Controller::Base
|
56
59
|
on 'success' do
|
57
60
|
success!
|
58
61
|
end
|
@@ -70,7 +73,7 @@ module Utopia::Middleware::ControllerSpec
|
|
70
73
|
end
|
71
74
|
end
|
72
75
|
|
73
|
-
class TestIndirectController < Utopia::
|
76
|
+
class TestIndirectController < Utopia::Controller::Base
|
74
77
|
def initialize
|
75
78
|
@sequence = ""
|
76
79
|
end
|
@@ -104,16 +107,58 @@ module Utopia::Middleware::ControllerSpec
|
|
104
107
|
end
|
105
108
|
end
|
106
109
|
|
107
|
-
|
108
|
-
|
110
|
+
describe Utopia::Controller do
|
111
|
+
include Rack::Test::Methods
|
112
|
+
|
113
|
+
let(:app) {Rack::Builder.parse_file(File.expand_path('../controller_spec.ru', __FILE__)).first}
|
114
|
+
|
115
|
+
it "should successfully call the controller method" do
|
116
|
+
get "/controller/hello-world"
|
117
|
+
|
118
|
+
expect(last_response.status).to be == 200
|
119
|
+
expect(last_response.body).to be == 'Hello World'
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should successfully call the recursive controller method" do
|
123
|
+
get "/controller/recursive/hello-world"
|
124
|
+
|
125
|
+
expect(last_response.status).to be == 200
|
126
|
+
expect(last_response.body).to be == 'Hello World'
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should successfully call the controller method" do
|
130
|
+
get "/controller/flat"
|
131
|
+
|
132
|
+
expect(last_response.status).to be == 200
|
133
|
+
expect(last_response.body).to be == 'flat'
|
134
|
+
end
|
135
|
+
|
136
|
+
it "should successfully call the recursive controller method" do
|
137
|
+
get "/controller/recursive/flat"
|
138
|
+
|
139
|
+
expect(last_response.status).to be == 404
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should perform ignore the request" do
|
143
|
+
get '/controller/ignore'
|
144
|
+
expect(last_response.status).to be == 404
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should redirect the request" do
|
148
|
+
get '/controller/redirect'
|
149
|
+
expect(last_response.status).to be == 302
|
150
|
+
expect(last_response.headers['Location']).to be == 'bar'
|
151
|
+
end
|
109
152
|
|
110
|
-
|
111
|
-
|
153
|
+
it "should rewrite the request" do
|
154
|
+
get '/controller/rewrite'
|
155
|
+
expect(last_response.status).to be == 200
|
156
|
+
expect(last_response.body).to be == 'Hello World'
|
112
157
|
end
|
113
158
|
end
|
114
159
|
|
115
|
-
describe Utopia::
|
116
|
-
let(:variables) {Utopia::
|
160
|
+
describe Utopia::Controller do
|
161
|
+
let(:variables) {Utopia::Controller::Variables.new}
|
117
162
|
|
118
163
|
it "should call controller methods" do
|
119
164
|
request = Rack::Request.new("utopia.controller" => variables)
|