mojito 0.1.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/mojito.rb +21 -44
- data/lib/mojito/base.rb +29 -58
- data/lib/mojito/controllers.rb +10 -0
- data/lib/mojito/controllers/method.rb +65 -0
- data/lib/mojito/controllers/runtime.rb +80 -0
- data/lib/mojito/{matchers → controllers/runtime}/environment.rb +1 -3
- data/lib/mojito/{matchers → controllers/runtime}/methods.rb +1 -3
- data/lib/mojito/{matchers → controllers/runtime}/path.rb +4 -5
- data/lib/mojito/{matchers → controllers/runtime}/session.rb +1 -3
- data/lib/mojito/{matchers → controllers/runtime}/url_scheme.rb +1 -3
- data/lib/mojito/{matchers → controllers/runtime}/virtual_host.rb +1 -3
- data/lib/mojito/controllers/sinatra.rb +11 -0
- data/lib/mojito/helpers/exception_handling.rb +3 -5
- data/lib/mojito/helpers/shortcuts.rb +0 -2
- data/lib/mojito/rendering.rb +10 -6
- data/lib/mojito/rendering/content.rb +0 -2
- data/lib/mojito/rendering/content_types.rb +0 -2
- data/lib/mojito/rendering/delegation.rb +0 -2
- data/lib/mojito/rendering/file.rb +0 -2
- data/lib/mojito/rendering/status_codes.rb +0 -2
- data/lib/mojito/rendering/templates.rb +2 -4
- data/lib/mojito/request_extensions.rb +4 -0
- data/lib/mojito/utils/rspec.rb +26 -0
- data/spec/mojito/base_spec.rb +18 -2
- data/spec/mojito/controllers/method_spec.rb +56 -0
- data/spec/mojito/{matchers → controllers/runtime}/methods_spec.rb +4 -2
- data/spec/mojito/{matchers → controllers/runtime}/path_spec.rb +11 -10
- data/spec/mojito/{matchers → controllers/runtime}/session_spec.rb +2 -0
- data/spec/mojito/controllers/runtime/url_scheme_spec.rb +24 -0
- data/spec/mojito/controllers/runtime/virtual_host_spec.rb +24 -0
- data/spec/mojito/helpers_spec.rb +2 -0
- data/spec/mojito/rendering/content_spec.rb +4 -2
- data/spec/mojito/rendering/delegation_spec.rb +9 -9
- data/spec/mojito/rendering/file_spec.rb +9 -9
- data/spec/mojito/rendering/status_codes_spec.rb +6 -3
- data/spec/mojito/rendering/templates_spec.rb +18 -8
- data/spec/mojito/rendering_spec.rb +2 -0
- data/spec/mojito/request_extensions_spec.rb +3 -1
- data/spec/mojito_spec.rb +5 -3
- metadata +39 -35
- data/lib/mojito/matchers.rb +0 -23
- data/spec/mojito/matchers/url_scheme_spec.rb +0 -22
- data/spec/mojito/matchers/virtual_host_spec.rb +0 -22
- data/spec/mojito/matchers_spec.rb +0 -5
@@ -1,38 +1,38 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
require 'simplecov' and SimpleCov.start do
|
3
3
|
add_filter "spec/"
|
4
|
+
add_filter "lib/mojito/utils/rspec.rb"
|
4
5
|
end
|
5
6
|
require 'mojito'
|
7
|
+
require 'mojito/utils/rspec'
|
6
8
|
|
7
9
|
describe Mojito::Rendering::Delegation do
|
8
10
|
|
9
11
|
subject do
|
10
|
-
sub_app = Mojito.
|
12
|
+
sub_app = Mojito::C.runtime_controller Mojito::H::Shortcuts, Mojito::R::Content do
|
11
13
|
on PATH('this/is/the/sub-application') do write request.context_path ; halt! end
|
12
14
|
on true do write 'sub-application' ; halt! end
|
13
15
|
end
|
14
|
-
Mojito.
|
16
|
+
Mojito::C.runtime_controller Mojito::R::Content, Mojito::R::Delegation do
|
15
17
|
on 'to/sub/app' do run! sub_app end
|
16
18
|
end.mock_request
|
17
19
|
end
|
18
20
|
|
19
|
-
it { subject.get('/to/sub/app').
|
20
|
-
it { subject.get('/to/sub/app').
|
21
|
-
it { subject.get('/to/sub/app/this/is/the/sub-application').body.should == '/to/sub/app' }
|
21
|
+
it { subject.get('/to/sub/app').should respond_with(200, 'sub-application') }
|
22
|
+
it { subject.get('/to/sub/app/this/is/the/sub-application').should respond_with(200, '/to/sub/app') }
|
22
23
|
|
23
24
|
context do
|
24
25
|
|
25
26
|
subject do
|
26
|
-
sub_app = Mojito.
|
27
|
+
sub_app = Mojito::C.runtime_controller Mojito::R::Content, Mojito::H::Shortcuts do
|
27
28
|
on true do write("#{path_info} #{captures.first}") ; halt! end
|
28
29
|
end
|
29
|
-
Mojito.
|
30
|
+
Mojito::C.runtime_controller Mojito::R::Content, Mojito::R::Delegation do
|
30
31
|
on PATH('hello/:name') do run! sub_app end
|
31
32
|
end.mock_request
|
32
33
|
end
|
33
34
|
|
34
|
-
it { subject.get('/hello/world/rest').
|
35
|
-
it { subject.get('/hello/world/rest').body.should == '/rest world' }
|
35
|
+
it { subject.get('/hello/world/rest').should respond_with(200, '/rest world') }
|
36
36
|
|
37
37
|
end
|
38
38
|
|
@@ -1,24 +1,24 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
require 'simplecov' and SimpleCov.start do
|
3
3
|
add_filter "spec/"
|
4
|
+
add_filter "lib/mojito/utils/rspec.rb"
|
4
5
|
end
|
5
6
|
require 'mojito'
|
7
|
+
require 'mojito/utils/rspec'
|
6
8
|
|
7
9
|
describe Mojito::Rendering::File do
|
8
10
|
|
9
11
|
subject do
|
10
|
-
Mojito.
|
12
|
+
Mojito::C.runtime_controller Mojito::R::File do
|
11
13
|
file! __FILE__
|
12
14
|
end.mock_request
|
13
15
|
end
|
14
16
|
|
15
|
-
it
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
it { subject.get('/').headers['Last-Modified'].should == ::File.mtime(__FILE__).rfc2822 }
|
22
|
-
it { subject.get('/').body.should == ::File.read(__FILE__) }
|
17
|
+
it do
|
18
|
+
subject.get('/').should respond_with(200, ::File.read(__FILE__),
|
19
|
+
'Content-Type' => 'application/x-ruby',
|
20
|
+
'Content-Length' => ::File.size(__FILE__).to_s,
|
21
|
+
'Last-Modified' => ::File.mtime(__FILE__).rfc2822)
|
22
|
+
end
|
23
23
|
|
24
24
|
end
|
@@ -1,13 +1,15 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
require 'simplecov' and SimpleCov.start do
|
3
3
|
add_filter "spec/"
|
4
|
+
add_filter "lib/mojito/utils/rspec.rb"
|
4
5
|
end
|
5
6
|
require 'mojito'
|
7
|
+
require 'mojito/utils/rspec'
|
6
8
|
|
7
9
|
describe Mojito::Rendering::StatusCodes do
|
8
10
|
|
9
11
|
subject do
|
10
|
-
Mojito.
|
12
|
+
Mojito::C.runtime_controller Mojito::R::StatusCodes do
|
11
13
|
on 'ok' do ok! end
|
12
14
|
on 'not_found' do not_found! end
|
13
15
|
on 'internal_server_error' do internal_server_error! end
|
@@ -20,7 +22,8 @@ describe Mojito::Rendering::StatusCodes do
|
|
20
22
|
it { subject.get('/not_found').status.should == 404 }
|
21
23
|
it { subject.get('/internal_server_error').status.should == 500 }
|
22
24
|
it { subject.get('/unavailable').status.should == 503 }
|
23
|
-
it { subject.get('/redirect').
|
24
|
-
it { subject.get('/redirect').
|
25
|
+
it { subject.get('/redirect').should respond_with(302, 'Location' => '/test') }
|
26
|
+
# it { subject.get('/redirect').status.should == 302 }
|
27
|
+
# it { subject.get('/redirect').headers['Location'].should == '/test' }
|
25
28
|
|
26
29
|
end
|
@@ -1,37 +1,47 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
require 'simplecov' and SimpleCov.start do
|
3
3
|
add_filter "spec/"
|
4
|
+
add_filter "lib/mojito/utils/rspec.rb"
|
4
5
|
end
|
5
6
|
require 'mojito'
|
7
|
+
require 'mojito/utils/rspec'
|
6
8
|
|
7
9
|
describe Mojito::Rendering::Templates do
|
8
10
|
|
9
11
|
context 'inline templates' do
|
10
12
|
subject do
|
11
|
-
Mojito.
|
13
|
+
Mojito::C.runtime_controller Mojito::Rendering::Templates do
|
12
14
|
template :erb, 'before <%= var %> <%= yield %> after', :var => 'middle' do 'inside the block' end
|
13
15
|
halt!
|
14
16
|
end.mock_request
|
15
17
|
end
|
16
18
|
|
17
|
-
it { subject.get('/').
|
18
|
-
it { subject.get('/').body.should == 'before middle inside the block after' }
|
19
|
+
it { subject.get('/').should respond_with(200, 'before middle inside the block after') }
|
19
20
|
|
20
21
|
end
|
21
22
|
|
22
23
|
context 'file templates' do
|
23
24
|
subject do
|
24
|
-
Mojito.
|
25
|
+
Mojito::C.runtime_controller Mojito::R::Templates do
|
25
26
|
template 'test.html.erb', :var => 'middle' do 'inside the block' end
|
26
27
|
halt!
|
27
28
|
end.mock_request
|
28
29
|
end
|
29
30
|
|
30
|
-
it { subject.get('/').
|
31
|
-
it { subject.get('/').body.should == 'HTML file with a variable middle and a yield inside the block' }
|
32
|
-
it { subject.get('/').headers.should include('Content-Type') }
|
33
|
-
it { subject.get('/').headers['Content-Type'].should == 'text/html' }
|
31
|
+
it { subject.get('/').should respond_with(200, 'HTML file with a variable middle and a yield inside the block', 'Content-Type' => 'text/html') }
|
34
32
|
|
33
|
+
context 'text template' do
|
34
|
+
subject do
|
35
|
+
Mojito::C.runtime_controller Mojito::R::Templates do
|
36
|
+
template 'test.txt.erb', :var => 'middle' do 'inside the block' end
|
37
|
+
halt!
|
38
|
+
end.mock_request
|
39
|
+
end
|
40
|
+
|
41
|
+
it { subject.get('/').should respond_with(200, 'Text file with a variable middle and a yield inside the block', 'Content-Type' => 'text/plain') }
|
42
|
+
|
43
|
+
end
|
44
|
+
|
35
45
|
end
|
36
46
|
|
37
47
|
end
|
@@ -1,13 +1,15 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
require 'simplecov' and SimpleCov.start do
|
3
3
|
add_filter "spec/"
|
4
|
+
add_filter "lib/mojito/utils/rspec.rb"
|
4
5
|
end
|
5
6
|
require 'mojito'
|
7
|
+
require 'mojito/utils/rspec'
|
6
8
|
|
7
9
|
describe ::Rack::Request do
|
8
10
|
|
9
11
|
subject do
|
10
|
-
Mojito.
|
12
|
+
Mojito::C.runtime_controller Mojito::Rendering::Content do
|
11
13
|
write request.GET[:hello]
|
12
14
|
halt!
|
13
15
|
end.mock_request
|
data/spec/mojito_spec.rb
CHANGED
@@ -1,19 +1,21 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
require 'simplecov' and SimpleCov.start do
|
3
3
|
add_filter "spec/"
|
4
|
+
add_filter "lib/mojito/utils/rspec.rb"
|
4
5
|
end
|
5
6
|
require 'mojito'
|
7
|
+
require 'mojito/utils/rspec'
|
6
8
|
|
7
9
|
describe Mojito do
|
8
10
|
|
9
11
|
context do
|
10
|
-
subject { Mojito.
|
12
|
+
subject { Mojito::C.runtime_controller {} }
|
11
13
|
it { subject.ancestors.should include(Mojito::Base) }
|
12
14
|
it { subject.should respond_to(:call) }
|
13
15
|
end
|
14
16
|
|
15
17
|
context do
|
16
|
-
subject { Mojito.
|
18
|
+
subject { Mojito::C.runtime_controller(Mojito::H::Shortcuts).new Rack::MockRequest.env_for('http://localhost/hello/world/rest') }
|
17
19
|
it { subject.env.should_not be_nil }
|
18
20
|
it { subject.request.should be_kind_of(Rack::Request) }
|
19
21
|
it { subject.captures.should be_empty }
|
@@ -28,7 +30,7 @@ describe Mojito do
|
|
28
30
|
|
29
31
|
context do
|
30
32
|
subject do
|
31
|
-
Mojito.
|
33
|
+
Mojito::C.runtime_controller do
|
32
34
|
|
33
35
|
end
|
34
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mojito
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
16
|
-
requirement: &
|
16
|
+
requirement: &22721340 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.4.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *22721340
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: mime-types
|
27
|
-
requirement: &
|
27
|
+
requirement: &22737160 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '1.18'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *22737160
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: tilt
|
38
|
-
requirement: &
|
38
|
+
requirement: &22736600 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.3.3
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *22736600
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: extlib
|
49
|
-
requirement: &
|
49
|
+
requirement: &22736120 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.9.15
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *22736120
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: where-am-i
|
60
|
-
requirement: &
|
60
|
+
requirement: &22735620 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.0.0
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *22735620
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
|
-
requirement: &
|
71
|
+
requirement: &22735140 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 2.8.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *22735140
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rdoc
|
82
|
-
requirement: &
|
82
|
+
requirement: &22734640 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '3.12'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *22734640
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: bundler
|
93
|
-
requirement: &
|
93
|
+
requirement: &22733920 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: 1.0.0
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *22733920
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: jeweler
|
104
|
-
requirement: &
|
104
|
+
requirement: &22732500 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: 1.8.3
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *22732500
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: rcov
|
115
|
-
requirement: &
|
115
|
+
requirement: &22731980 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,7 +120,7 @@ dependencies:
|
|
120
120
|
version: '0'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *22731980
|
124
124
|
description: A simple yet powerful webframework largely inspired by Rum and Cuba
|
125
125
|
email: dev@trense.info
|
126
126
|
executables: []
|
@@ -133,16 +133,19 @@ files:
|
|
133
133
|
- VERSION
|
134
134
|
- lib/mojito.rb
|
135
135
|
- lib/mojito/base.rb
|
136
|
+
- lib/mojito/controllers.rb
|
137
|
+
- lib/mojito/controllers/method.rb
|
138
|
+
- lib/mojito/controllers/runtime.rb
|
139
|
+
- lib/mojito/controllers/runtime/environment.rb
|
140
|
+
- lib/mojito/controllers/runtime/methods.rb
|
141
|
+
- lib/mojito/controllers/runtime/path.rb
|
142
|
+
- lib/mojito/controllers/runtime/session.rb
|
143
|
+
- lib/mojito/controllers/runtime/url_scheme.rb
|
144
|
+
- lib/mojito/controllers/runtime/virtual_host.rb
|
145
|
+
- lib/mojito/controllers/sinatra.rb
|
136
146
|
- lib/mojito/helpers.rb
|
137
147
|
- lib/mojito/helpers/exception_handling.rb
|
138
148
|
- lib/mojito/helpers/shortcuts.rb
|
139
|
-
- lib/mojito/matchers.rb
|
140
|
-
- lib/mojito/matchers/environment.rb
|
141
|
-
- lib/mojito/matchers/methods.rb
|
142
|
-
- lib/mojito/matchers/path.rb
|
143
|
-
- lib/mojito/matchers/session.rb
|
144
|
-
- lib/mojito/matchers/url_scheme.rb
|
145
|
-
- lib/mojito/matchers/virtual_host.rb
|
146
149
|
- lib/mojito/rendering.rb
|
147
150
|
- lib/mojito/rendering/content.rb
|
148
151
|
- lib/mojito/rendering/content_types.rb
|
@@ -151,15 +154,16 @@ files:
|
|
151
154
|
- lib/mojito/rendering/status_codes.rb
|
152
155
|
- lib/mojito/rendering/templates.rb
|
153
156
|
- lib/mojito/request_extensions.rb
|
157
|
+
- lib/mojito/utils/rspec.rb
|
154
158
|
- lib/mojito/utils/status_codes.rb
|
155
159
|
- spec/mojito/base_spec.rb
|
160
|
+
- spec/mojito/controllers/method_spec.rb
|
161
|
+
- spec/mojito/controllers/runtime/methods_spec.rb
|
162
|
+
- spec/mojito/controllers/runtime/path_spec.rb
|
163
|
+
- spec/mojito/controllers/runtime/session_spec.rb
|
164
|
+
- spec/mojito/controllers/runtime/url_scheme_spec.rb
|
165
|
+
- spec/mojito/controllers/runtime/virtual_host_spec.rb
|
156
166
|
- spec/mojito/helpers_spec.rb
|
157
|
-
- spec/mojito/matchers/methods_spec.rb
|
158
|
-
- spec/mojito/matchers/path_spec.rb
|
159
|
-
- spec/mojito/matchers/session_spec.rb
|
160
|
-
- spec/mojito/matchers/url_scheme_spec.rb
|
161
|
-
- spec/mojito/matchers/virtual_host_spec.rb
|
162
|
-
- spec/mojito/matchers_spec.rb
|
163
167
|
- spec/mojito/rendering/content_spec.rb
|
164
168
|
- spec/mojito/rendering/delegation_spec.rb
|
165
169
|
- spec/mojito/rendering/file_spec.rb
|
data/lib/mojito/matchers.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module Mojito::Matchers
|
4
|
-
|
5
|
-
require 'mojito/matchers/environment'
|
6
|
-
require 'mojito/matchers/methods'
|
7
|
-
require 'mojito/matchers/path'
|
8
|
-
require 'mojito/matchers/url_scheme'
|
9
|
-
require 'mojito/matchers/virtual_host'
|
10
|
-
|
11
|
-
include Environment
|
12
|
-
include Methods
|
13
|
-
include Path
|
14
|
-
include UrlScheme
|
15
|
-
include VirtualHost
|
16
|
-
|
17
|
-
extend Environment
|
18
|
-
extend Methods
|
19
|
-
extend Path
|
20
|
-
extend UrlScheme
|
21
|
-
extend VirtualHost
|
22
|
-
|
23
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'simplecov' and SimpleCov.start do
|
3
|
-
add_filter "spec/"
|
4
|
-
end
|
5
|
-
require 'mojito'
|
6
|
-
|
7
|
-
describe Mojito::Matchers::UrlScheme do
|
8
|
-
|
9
|
-
subject do
|
10
|
-
Mojito.application Mojito::Matchers::UrlScheme do
|
11
|
-
on SCHEME(:http) do write 'insecure' ; halt! end
|
12
|
-
on SCHEME(:https) do write 'secure' ; halt! end
|
13
|
-
end.mock_request
|
14
|
-
end
|
15
|
-
|
16
|
-
it { subject.get('http://localhost/').body.should == 'insecure' }
|
17
|
-
it { subject.get('http://localhost:7777/').body.should == 'insecure' }
|
18
|
-
it { subject.get('https://localhost:80/').body.should == 'secure' }
|
19
|
-
it { subject.get('https://localhost/').body.should == 'secure' }
|
20
|
-
it { subject.get('otherprotocol://test/').status.should == 404 }
|
21
|
-
|
22
|
-
end
|