devcenter 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTING.md +14 -0
- data/Gemfile +0 -4
- data/devcenter.gemspec +2 -1
- data/lib/devcenter.rb +0 -1
- data/lib/devcenter/previewer/web_app.rb +3 -2
- data/lib/devcenter/version.rb +1 -1
- metadata +19 -124
- data/vendor/sinatra/.gitignore +0 -6
- data/vendor/sinatra/.travis.yml +0 -16
- data/vendor/sinatra/.yardopts +0 -4
- data/vendor/sinatra/AUTHORS +0 -61
- data/vendor/sinatra/Gemfile +0 -91
- data/vendor/sinatra/LICENSE +0 -22
- data/vendor/sinatra/README.de.rdoc +0 -2116
- data/vendor/sinatra/README.es.rdoc +0 -2106
- data/vendor/sinatra/README.fr.rdoc +0 -2133
- data/vendor/sinatra/README.hu.rdoc +0 -608
- data/vendor/sinatra/README.jp.rdoc +0 -1056
- data/vendor/sinatra/README.ko.rdoc +0 -1932
- data/vendor/sinatra/README.pt-br.rdoc +0 -778
- data/vendor/sinatra/README.pt-pt.rdoc +0 -647
- data/vendor/sinatra/README.rdoc +0 -2049
- data/vendor/sinatra/README.ru.rdoc +0 -2033
- data/vendor/sinatra/README.zh.rdoc +0 -1816
- data/vendor/sinatra/Rakefile +0 -182
- data/vendor/sinatra/examples/chat.rb +0 -61
- data/vendor/sinatra/examples/simple.rb +0 -3
- data/vendor/sinatra/examples/stream.ru +0 -26
- data/vendor/sinatra/lib/sinatra.rb +0 -5
- data/vendor/sinatra/lib/sinatra/base.rb +0 -1820
- data/vendor/sinatra/lib/sinatra/images/404.png +0 -0
- data/vendor/sinatra/lib/sinatra/images/500.png +0 -0
- data/vendor/sinatra/lib/sinatra/main.rb +0 -30
- data/vendor/sinatra/lib/sinatra/showexceptions.rb +0 -345
- data/vendor/sinatra/lib/sinatra/version.rb +0 -3
- data/vendor/sinatra/sinatra.gemspec +0 -18
- data/vendor/sinatra/test/base_test.rb +0 -172
- data/vendor/sinatra/test/builder_test.rb +0 -91
- data/vendor/sinatra/test/coffee_test.rb +0 -90
- data/vendor/sinatra/test/compile_test.rb +0 -139
- data/vendor/sinatra/test/contest.rb +0 -98
- data/vendor/sinatra/test/creole_test.rb +0 -65
- data/vendor/sinatra/test/delegator_test.rb +0 -160
- data/vendor/sinatra/test/encoding_test.rb +0 -20
- data/vendor/sinatra/test/erb_test.rb +0 -98
- data/vendor/sinatra/test/extensions_test.rb +0 -98
- data/vendor/sinatra/test/filter_test.rb +0 -437
- data/vendor/sinatra/test/haml_test.rb +0 -91
- data/vendor/sinatra/test/helper.rb +0 -123
- data/vendor/sinatra/test/helpers_test.rb +0 -1768
- data/vendor/sinatra/test/integration/app.rb +0 -62
- data/vendor/sinatra/test/integration_helper.rb +0 -222
- data/vendor/sinatra/test/integration_test.rb +0 -87
- data/vendor/sinatra/test/less_test.rb +0 -69
- data/vendor/sinatra/test/liquid_test.rb +0 -59
- data/vendor/sinatra/test/mapped_error_test.rb +0 -305
- data/vendor/sinatra/test/markaby_test.rb +0 -80
- data/vendor/sinatra/test/markdown_test.rb +0 -82
- data/vendor/sinatra/test/middleware_test.rb +0 -68
- data/vendor/sinatra/test/nokogiri_test.rb +0 -67
- data/vendor/sinatra/test/public/favicon.ico +0 -0
- data/vendor/sinatra/test/rabl_test.rb +0 -89
- data/vendor/sinatra/test/rack_test.rb +0 -45
- data/vendor/sinatra/test/radius_test.rb +0 -59
- data/vendor/sinatra/test/rdoc_test.rb +0 -66
- data/vendor/sinatra/test/readme_test.rb +0 -120
- data/vendor/sinatra/test/request_test.rb +0 -45
- data/vendor/sinatra/test/response_test.rb +0 -64
- data/vendor/sinatra/test/result_test.rb +0 -76
- data/vendor/sinatra/test/route_added_hook_test.rb +0 -59
- data/vendor/sinatra/test/routing_test.rb +0 -1175
- data/vendor/sinatra/test/sass_test.rb +0 -116
- data/vendor/sinatra/test/scss_test.rb +0 -89
- data/vendor/sinatra/test/server_test.rb +0 -48
- data/vendor/sinatra/test/settings_test.rb +0 -561
- data/vendor/sinatra/test/sinatra_test.rb +0 -12
- data/vendor/sinatra/test/slim_test.rb +0 -84
- data/vendor/sinatra/test/static_test.rb +0 -219
- data/vendor/sinatra/test/streaming_test.rb +0 -149
- data/vendor/sinatra/test/templates_test.rb +0 -333
- data/vendor/sinatra/test/textile_test.rb +0 -65
- data/vendor/sinatra/test/views/a/in_a.str +0 -1
- data/vendor/sinatra/test/views/ascii.erb +0 -2
- data/vendor/sinatra/test/views/b/in_b.str +0 -1
- data/vendor/sinatra/test/views/calc.html.erb +0 -1
- data/vendor/sinatra/test/views/error.builder +0 -3
- data/vendor/sinatra/test/views/error.erb +0 -3
- data/vendor/sinatra/test/views/error.haml +0 -3
- data/vendor/sinatra/test/views/error.sass +0 -2
- data/vendor/sinatra/test/views/explicitly_nested.str +0 -1
- data/vendor/sinatra/test/views/foo/hello.test +0 -1
- data/vendor/sinatra/test/views/hello.builder +0 -1
- data/vendor/sinatra/test/views/hello.coffee +0 -1
- data/vendor/sinatra/test/views/hello.creole +0 -1
- data/vendor/sinatra/test/views/hello.erb +0 -1
- data/vendor/sinatra/test/views/hello.haml +0 -1
- data/vendor/sinatra/test/views/hello.less +0 -5
- data/vendor/sinatra/test/views/hello.liquid +0 -1
- data/vendor/sinatra/test/views/hello.mab +0 -1
- data/vendor/sinatra/test/views/hello.md +0 -1
- data/vendor/sinatra/test/views/hello.nokogiri +0 -1
- data/vendor/sinatra/test/views/hello.rabl +0 -2
- data/vendor/sinatra/test/views/hello.radius +0 -1
- data/vendor/sinatra/test/views/hello.rdoc +0 -1
- data/vendor/sinatra/test/views/hello.sass +0 -2
- data/vendor/sinatra/test/views/hello.scss +0 -3
- data/vendor/sinatra/test/views/hello.slim +0 -1
- data/vendor/sinatra/test/views/hello.str +0 -1
- data/vendor/sinatra/test/views/hello.test +0 -1
- data/vendor/sinatra/test/views/hello.textile +0 -1
- data/vendor/sinatra/test/views/hello.wlang +0 -1
- data/vendor/sinatra/test/views/hello.yajl +0 -1
- data/vendor/sinatra/test/views/layout2.builder +0 -3
- data/vendor/sinatra/test/views/layout2.erb +0 -2
- data/vendor/sinatra/test/views/layout2.haml +0 -2
- data/vendor/sinatra/test/views/layout2.liquid +0 -2
- data/vendor/sinatra/test/views/layout2.mab +0 -2
- data/vendor/sinatra/test/views/layout2.nokogiri +0 -3
- data/vendor/sinatra/test/views/layout2.rabl +0 -3
- data/vendor/sinatra/test/views/layout2.radius +0 -2
- data/vendor/sinatra/test/views/layout2.slim +0 -3
- data/vendor/sinatra/test/views/layout2.str +0 -2
- data/vendor/sinatra/test/views/layout2.test +0 -1
- data/vendor/sinatra/test/views/layout2.wlang +0 -2
- data/vendor/sinatra/test/views/nested.str +0 -1
- data/vendor/sinatra/test/views/utf8.erb +0 -2
- data/vendor/sinatra/test/wlang_test.rb +0 -70
- data/vendor/sinatra/test/yajl_test.rb +0 -86
@@ -1,68 +0,0 @@
|
|
1
|
-
require File.expand_path('../helper', __FILE__)
|
2
|
-
|
3
|
-
class MiddlewareTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@app = mock_app(Sinatra::Application) do
|
6
|
-
get('/*')do
|
7
|
-
response.headers['X-Tests'] = env['test.ran'].
|
8
|
-
map { |n| n.split('::').last }.
|
9
|
-
join(', ')
|
10
|
-
env['PATH_INFO']
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
class MockMiddleware < Struct.new(:app)
|
16
|
-
def call(env)
|
17
|
-
(env['test.ran'] ||= []) << self.class.to_s
|
18
|
-
app.call(env)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class UpcaseMiddleware < MockMiddleware
|
23
|
-
def call(env)
|
24
|
-
env['PATH_INFO'] = env['PATH_INFO'].upcase
|
25
|
-
super
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
it "is added with Sinatra::Application.use" do
|
30
|
-
@app.use UpcaseMiddleware
|
31
|
-
get '/hello-world'
|
32
|
-
assert ok?
|
33
|
-
assert_equal '/HELLO-WORLD', body
|
34
|
-
end
|
35
|
-
|
36
|
-
class DowncaseMiddleware < MockMiddleware
|
37
|
-
def call(env)
|
38
|
-
env['PATH_INFO'] = env['PATH_INFO'].downcase
|
39
|
-
super
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
it "runs in the order defined" do
|
44
|
-
@app.use UpcaseMiddleware
|
45
|
-
@app.use DowncaseMiddleware
|
46
|
-
get '/Foo'
|
47
|
-
assert_equal "/foo", body
|
48
|
-
assert_equal "UpcaseMiddleware, DowncaseMiddleware", response['X-Tests']
|
49
|
-
end
|
50
|
-
|
51
|
-
it "resets the prebuilt pipeline when new middleware is added" do
|
52
|
-
@app.use UpcaseMiddleware
|
53
|
-
get '/Foo'
|
54
|
-
assert_equal "/FOO", body
|
55
|
-
@app.use DowncaseMiddleware
|
56
|
-
get '/Foo'
|
57
|
-
assert_equal '/foo', body
|
58
|
-
assert_equal "UpcaseMiddleware, DowncaseMiddleware", response['X-Tests']
|
59
|
-
end
|
60
|
-
|
61
|
-
it "works when app is used as middleware" do
|
62
|
-
@app.use UpcaseMiddleware
|
63
|
-
@app = @app.new
|
64
|
-
get '/Foo'
|
65
|
-
assert_equal "/FOO", body
|
66
|
-
assert_equal "UpcaseMiddleware", response['X-Tests']
|
67
|
-
end
|
68
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require File.expand_path('../helper', __FILE__)
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'nokogiri'
|
5
|
-
|
6
|
-
class NokogiriTest < Test::Unit::TestCase
|
7
|
-
def nokogiri_app(&block)
|
8
|
-
mock_app do
|
9
|
-
set :views, File.dirname(__FILE__) + '/views'
|
10
|
-
get('/', &block)
|
11
|
-
end
|
12
|
-
get '/'
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'renders inline Nokogiri strings' do
|
16
|
-
nokogiri_app { nokogiri 'xml' }
|
17
|
-
assert ok?
|
18
|
-
assert_body %(<?xml version="1.0"?>\n)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'renders inline blocks' do
|
22
|
-
nokogiri_app do
|
23
|
-
@name = "Frank & Mary"
|
24
|
-
nokogiri { |xml| xml.couple @name }
|
25
|
-
end
|
26
|
-
assert ok?
|
27
|
-
assert_body %(<?xml version="1.0"?>\n<couple>Frank & Mary</couple>\n)
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'renders .nokogiri files in views path' do
|
31
|
-
nokogiri_app do
|
32
|
-
@name = "Blue"
|
33
|
-
nokogiri :hello
|
34
|
-
end
|
35
|
-
assert ok?
|
36
|
-
assert_body "<?xml version=\"1.0\"?>\n<exclaim>You're my boy, Blue!</exclaim>\n"
|
37
|
-
end
|
38
|
-
|
39
|
-
it "renders with inline layouts" do
|
40
|
-
next if Tilt::VERSION <= "1.1"
|
41
|
-
mock_app do
|
42
|
-
layout { %(xml.layout { xml << yield }) }
|
43
|
-
get('/') { nokogiri %(xml.em 'Hello World') }
|
44
|
-
end
|
45
|
-
get '/'
|
46
|
-
assert ok?
|
47
|
-
assert_body %(<?xml version="1.0"?>\n<layout>\n <em>Hello World</em>\n</layout>\n)
|
48
|
-
end
|
49
|
-
|
50
|
-
it "renders with file layouts" do
|
51
|
-
next if Tilt::VERSION <= "1.1"
|
52
|
-
nokogiri_app {
|
53
|
-
nokogiri %(xml.em 'Hello World'), :layout => :layout2
|
54
|
-
}
|
55
|
-
assert ok?
|
56
|
-
assert_body %(<?xml version="1.0"?>\n<layout>\n <em>Hello World</em>\n</layout>\n)
|
57
|
-
end
|
58
|
-
|
59
|
-
it "raises error if template not found" do
|
60
|
-
mock_app { get('/') { nokogiri :no_such_template } }
|
61
|
-
assert_raise(Errno::ENOENT) { get('/') }
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
rescue LoadError
|
66
|
-
warn "#{$!.to_s}: skipping nokogiri tests"
|
67
|
-
end
|
File without changes
|
@@ -1,89 +0,0 @@
|
|
1
|
-
require File.expand_path('../helper', __FILE__)
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'rabl'
|
5
|
-
require 'ostruct'
|
6
|
-
require 'json'
|
7
|
-
require 'active_support/core_ext/hash/conversions'
|
8
|
-
|
9
|
-
class RablTest < Test::Unit::TestCase
|
10
|
-
def rabl_app(&block)
|
11
|
-
mock_app {
|
12
|
-
set :views, File.dirname(__FILE__) + '/views'
|
13
|
-
get '/', &block
|
14
|
-
}
|
15
|
-
get '/'
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'renders inline rabl strings' do
|
19
|
-
rabl_app do
|
20
|
-
@foo = OpenStruct.new(:baz => 'w00t')
|
21
|
-
rabl %q{
|
22
|
-
object @foo
|
23
|
-
attributes :baz
|
24
|
-
}
|
25
|
-
end
|
26
|
-
assert ok?
|
27
|
-
assert_equal '{"openstruct":{"baz":"w00t"}}', body
|
28
|
-
end
|
29
|
-
it 'renders .rabl files in views path' do
|
30
|
-
rabl_app do
|
31
|
-
@foo = OpenStruct.new(:bar => 'baz')
|
32
|
-
rabl :hello
|
33
|
-
end
|
34
|
-
assert ok?
|
35
|
-
assert_equal '{"openstruct":{"bar":"baz"}}', body
|
36
|
-
end
|
37
|
-
|
38
|
-
it "renders with file layouts" do
|
39
|
-
rabl_app {
|
40
|
-
@foo = OpenStruct.new(:bar => 'baz')
|
41
|
-
rabl :hello, :layout => :layout2
|
42
|
-
}
|
43
|
-
assert ok?
|
44
|
-
assert_equal '{"qux":{"openstruct":{"bar":"baz"}}}', body
|
45
|
-
end
|
46
|
-
|
47
|
-
it "raises error if template not found" do
|
48
|
-
mock_app {
|
49
|
-
get('/') { rabl :no_such_template }
|
50
|
-
}
|
51
|
-
assert_raise(Errno::ENOENT) { get('/') }
|
52
|
-
end
|
53
|
-
|
54
|
-
it "passes rabl options to the rabl engine" do
|
55
|
-
mock_app do
|
56
|
-
get('/') do
|
57
|
-
@foo = OpenStruct.new(:bar => 'baz')
|
58
|
-
rabl %q{
|
59
|
-
object @foo
|
60
|
-
attributes :bar
|
61
|
-
}, :format => 'xml'
|
62
|
-
end
|
63
|
-
end
|
64
|
-
get '/'
|
65
|
-
assert ok?
|
66
|
-
assert_body '<?xml version="1.0" encoding="UTF-8"?><openstruct><bar>baz</bar></openstruct>'
|
67
|
-
end
|
68
|
-
|
69
|
-
it "passes default rabl options to the rabl engine" do
|
70
|
-
mock_app do
|
71
|
-
set :rabl, :format => 'xml'
|
72
|
-
get('/') do
|
73
|
-
@foo = OpenStruct.new(:bar => 'baz')
|
74
|
-
rabl %q{
|
75
|
-
object @foo
|
76
|
-
attributes :bar
|
77
|
-
}
|
78
|
-
end
|
79
|
-
end
|
80
|
-
get '/'
|
81
|
-
assert ok?
|
82
|
-
assert_body '<?xml version="1.0" encoding="UTF-8"?><openstruct><bar>baz</bar></openstruct>'
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
rescue LoadError
|
88
|
-
warn "#{$!.to_s}: skipping rabl tests"
|
89
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require File.expand_path('../helper', __FILE__)
|
2
|
-
require 'rack'
|
3
|
-
|
4
|
-
class RackTest < Test::Unit::TestCase
|
5
|
-
setup do
|
6
|
-
@foo = Sinatra.new { get('/foo') { 'foo' }}
|
7
|
-
@bar = Sinatra.new { get('/bar') { 'bar' }}
|
8
|
-
end
|
9
|
-
|
10
|
-
def build(*middleware)
|
11
|
-
endpoint = middleware.pop
|
12
|
-
@app = Rack::Builder.app do
|
13
|
-
middleware.each { |m| use m }
|
14
|
-
run endpoint
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def check(*middleware)
|
19
|
-
build(*middleware)
|
20
|
-
assert get('/foo').ok?
|
21
|
-
assert_body 'foo'
|
22
|
-
assert get('/bar').ok?
|
23
|
-
assert_body 'bar'
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'works as middleware in front of Rack::Lock, with lock enabled' do
|
27
|
-
@foo.enable :lock
|
28
|
-
check(@foo, Rack::Lock, @bar)
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'works as middleware behind Rack::Lock, with lock enabled' do
|
32
|
-
@foo.enable :lock
|
33
|
-
check(Rack::Lock, @foo, @bar)
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'works as middleware in front of Rack::Lock, with lock disabled' do
|
37
|
-
@foo.disable :lock
|
38
|
-
check(@foo, Rack::Lock, @bar)
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'works as middleware behind Rack::Lock, with lock disabled' do
|
42
|
-
@foo.disable :lock
|
43
|
-
check(Rack::Lock, @foo, @bar)
|
44
|
-
end
|
45
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require File.expand_path('../helper', __FILE__)
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'radius'
|
5
|
-
|
6
|
-
class RadiusTest < Test::Unit::TestCase
|
7
|
-
def radius_app(&block)
|
8
|
-
mock_app do
|
9
|
-
set :views, File.dirname(__FILE__) + '/views'
|
10
|
-
get('/', &block)
|
11
|
-
end
|
12
|
-
get '/'
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'renders inline radius strings' do
|
16
|
-
radius_app { radius '<h1>Hiya</h1>' }
|
17
|
-
assert ok?
|
18
|
-
assert_equal "<h1>Hiya</h1>", body
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'renders .radius files in views path' do
|
22
|
-
radius_app { radius :hello }
|
23
|
-
assert ok?
|
24
|
-
assert_equal "<h1>Hello From Radius</h1>\n", body
|
25
|
-
end
|
26
|
-
|
27
|
-
it "renders with inline layouts" do
|
28
|
-
mock_app do
|
29
|
-
layout { "<h1>THIS. IS. <r:yield /></h1>" }
|
30
|
-
get('/') { radius '<EM>SPARTA</EM>' }
|
31
|
-
end
|
32
|
-
get '/'
|
33
|
-
assert ok?
|
34
|
-
assert_equal "<h1>THIS. IS. <EM>SPARTA</EM></h1>", body
|
35
|
-
end
|
36
|
-
|
37
|
-
it "renders with file layouts" do
|
38
|
-
radius_app { radius 'Hello World', :layout => :layout2 }
|
39
|
-
assert ok?
|
40
|
-
assert_equal "<h1>Radius Layout!</h1>\n<p>Hello World</p>\n", body
|
41
|
-
end
|
42
|
-
|
43
|
-
it "raises error if template not found" do
|
44
|
-
mock_app { get('/') { radius :no_such_template } }
|
45
|
-
assert_raise(Errno::ENOENT) { get('/') }
|
46
|
-
end
|
47
|
-
|
48
|
-
it "allows passing locals" do
|
49
|
-
radius_app {
|
50
|
-
radius '<r:value />', :locals => { :value => 'foo' }
|
51
|
-
}
|
52
|
-
assert ok?
|
53
|
-
assert_equal 'foo', body
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
rescue LoadError
|
58
|
-
warn "#{$!.to_s}: skipping radius tests"
|
59
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
require File.expand_path('../helper', __FILE__)
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'rdoc'
|
5
|
-
require 'rdoc/markup/to_html'
|
6
|
-
|
7
|
-
class RdocTest < Test::Unit::TestCase
|
8
|
-
def rdoc_app(&block)
|
9
|
-
mock_app do
|
10
|
-
set :views, File.dirname(__FILE__) + '/views'
|
11
|
-
get('/', &block)
|
12
|
-
end
|
13
|
-
get '/'
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'renders inline rdoc strings' do
|
17
|
-
rdoc_app { rdoc '= Hiya' }
|
18
|
-
assert ok?
|
19
|
-
assert_body /<h1[^>]*>Hiya<\/h1>/
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'renders .rdoc files in views path' do
|
23
|
-
rdoc_app { rdoc :hello }
|
24
|
-
assert ok?
|
25
|
-
assert_body /<h1[^>]*>Hello From RDoc<\/h1>/
|
26
|
-
end
|
27
|
-
|
28
|
-
it "raises error if template not found" do
|
29
|
-
mock_app { get('/') { rdoc :no_such_template } }
|
30
|
-
assert_raise(Errno::ENOENT) { get('/') }
|
31
|
-
end
|
32
|
-
|
33
|
-
it "renders with inline layouts" do
|
34
|
-
mock_app do
|
35
|
-
layout { 'THIS. IS. #{yield.upcase}!' }
|
36
|
-
get('/') { rdoc 'Sparta', :layout_engine => :str }
|
37
|
-
end
|
38
|
-
get '/'
|
39
|
-
assert ok?
|
40
|
-
assert_like 'THIS. IS. <P>SPARTA</P>!', body
|
41
|
-
end
|
42
|
-
|
43
|
-
it "renders with file layouts" do
|
44
|
-
rdoc_app {
|
45
|
-
rdoc 'Hello World', :layout => :layout2, :layout_engine => :erb
|
46
|
-
}
|
47
|
-
assert ok?
|
48
|
-
assert_body "ERB Layout!\n<p>Hello World</p>"
|
49
|
-
end
|
50
|
-
|
51
|
-
it "can be used in a nested fashion for partials and whatnot" do
|
52
|
-
mock_app do
|
53
|
-
template(:inner) { "hi" }
|
54
|
-
template(:outer) { "<outer><%= rdoc :inner %></outer>" }
|
55
|
-
get('/') { erb :outer }
|
56
|
-
end
|
57
|
-
|
58
|
-
get '/'
|
59
|
-
assert ok?
|
60
|
-
assert_like '<outer><p>hi</p></outer>', body
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
rescue LoadError
|
65
|
-
warn "#{$!.to_s}: skipping rdoc tests"
|
66
|
-
end
|
@@ -1,120 +0,0 @@
|
|
1
|
-
# Tests to check if all the README examples work.
|
2
|
-
require File.expand_path('../helper', __FILE__)
|
3
|
-
|
4
|
-
class ReadmeTest < Test::Unit::TestCase
|
5
|
-
example do
|
6
|
-
mock_app { get('/') { 'Hello world!' } }
|
7
|
-
get '/'
|
8
|
-
assert_body 'Hello world!'
|
9
|
-
end
|
10
|
-
|
11
|
-
section "Routes" do
|
12
|
-
example do
|
13
|
-
mock_app do
|
14
|
-
get('/') { ".. show something .." }
|
15
|
-
|
16
|
-
post('/') { ".. create something .." }
|
17
|
-
|
18
|
-
put('/') { ".. replace something .." }
|
19
|
-
|
20
|
-
patch('/') { ".. modify something .." }
|
21
|
-
|
22
|
-
delete('/') { ".. annihilate something .." }
|
23
|
-
|
24
|
-
options('/') { ".. appease something .." }
|
25
|
-
end
|
26
|
-
|
27
|
-
get '/'
|
28
|
-
assert_body '.. show something ..'
|
29
|
-
|
30
|
-
post '/'
|
31
|
-
assert_body '.. create something ..'
|
32
|
-
|
33
|
-
put '/'
|
34
|
-
assert_body '.. replace something ..'
|
35
|
-
|
36
|
-
patch '/'
|
37
|
-
assert_body '.. modify something ..'
|
38
|
-
|
39
|
-
delete '/'
|
40
|
-
assert_body '.. annihilate something ..'
|
41
|
-
|
42
|
-
options '/'
|
43
|
-
assert_body '.. appease something ..'
|
44
|
-
end
|
45
|
-
|
46
|
-
example do
|
47
|
-
mock_app do
|
48
|
-
get('/hello/:name') do
|
49
|
-
# matches "GET /hello/foo" and "GET /hello/bar"
|
50
|
-
# params[:name] is 'foo' or 'bar'
|
51
|
-
"Hello #{params[:name]}!"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
get '/hello/foo'
|
56
|
-
assert_body 'Hello foo!'
|
57
|
-
|
58
|
-
get '/hello/bar'
|
59
|
-
assert_body 'Hello bar!'
|
60
|
-
end
|
61
|
-
|
62
|
-
example do
|
63
|
-
mock_app { get('/hello/:name') { |n| "Hello #{n}!" } }
|
64
|
-
|
65
|
-
get '/hello/foo'
|
66
|
-
assert_body 'Hello foo!'
|
67
|
-
|
68
|
-
get '/hello/bar'
|
69
|
-
assert_body 'Hello bar!'
|
70
|
-
end
|
71
|
-
|
72
|
-
example do
|
73
|
-
mock_app do
|
74
|
-
get('/say/*/to/*') do
|
75
|
-
# matches /say/hello/to/world
|
76
|
-
params[:splat].inspect # => ["hello", "world"]
|
77
|
-
end
|
78
|
-
|
79
|
-
get('/download/*.*') do
|
80
|
-
# matches /download/path/to/file.xml
|
81
|
-
params[:splat].inspect # => ["path/to/file", "xml"]
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
get "/say/hello/to/world"
|
86
|
-
assert_body '["hello", "world"]'
|
87
|
-
|
88
|
-
get "/download/path/to/file.xml"
|
89
|
-
assert_body '["path/to/file", "xml"]'
|
90
|
-
end
|
91
|
-
|
92
|
-
example do
|
93
|
-
mock_app do
|
94
|
-
get(%r{/hello/([\w]+)}) {
|
95
|
-
"Hello, #{params[:captures].first}!"
|
96
|
-
}
|
97
|
-
end
|
98
|
-
|
99
|
-
get '/hello/foo'
|
100
|
-
assert_body 'Hello, foo!'
|
101
|
-
|
102
|
-
get '/hello/bar'
|
103
|
-
assert_body 'Hello, bar!'
|
104
|
-
end
|
105
|
-
|
106
|
-
example do
|
107
|
-
mock_app do
|
108
|
-
get( %r{/hello/([\w]+)}) { |c|
|
109
|
-
"Hello, #{c}!"
|
110
|
-
}
|
111
|
-
end
|
112
|
-
|
113
|
-
get '/hello/foo'
|
114
|
-
assert_body 'Hello, foo!'
|
115
|
-
|
116
|
-
get '/hello/bar'
|
117
|
-
assert_body 'Hello, bar!'
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|