nyny 3.0.1 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1377196ade715ab3d114440cf120a5596c81f67
4
- data.tar.gz: 186f4d5433cb0171a41c07a0b686e40382622f95
3
+ metadata.gz: ae38227835876ef5e85282b236b5349049e15116
4
+ data.tar.gz: 70836d65922b92ac174fee44b9c0c1dc8a2525b9
5
5
  SHA512:
6
- metadata.gz: 4d7cf903b0dfda2ea397680ac6cb8326e9e1a042733629452d9cb9576312da507eb10a54696afebf7b3c473337a88638eaafef60e15b72b92b90256db3f4ed25
7
- data.tar.gz: 03ca191d2113dfc7bae9d674db8f75889127911df2ec38c1d3fedca30bb242739f6c16e7549e1b5e3c1c01ecb1c8d4d3d074161fba49b8dc1b7b4cd0a884489d
6
+ metadata.gz: 99cfbc9eabad3173837d1acba68236b4eb7ba01dee114691d12a8266bb6c4970acea3a586c7be8b1699f08938abaea8f5ef1e25931b47dc78b6d2c10a6d5907b
7
+ data.tar.gz: 5443fdcb5d69b8771f35153ca8c7bbec47eb71f6db4221fd831f2f733da4b62576f99ac723491f9778d7e2fa0659a472ff21d378bbb9fd46054948067127fe8b
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.1
data/CHANGELOG CHANGED
@@ -1,3 +1,13 @@
1
+ 3.1.0
2
+ - use latest Tilt (2.0.0)
3
+ - get rid of silly Rack::Response hacks, write to body properly
4
+ - Response#rewrite (body= aliases it for backward compatibility)
5
+ - Refactor .run! implementation, prefer thin, webrik.
6
+ - NYNY now ships with better_errors, which is only enabled in development
7
+ - Fixed builder instanciation logic
8
+ - removed benchmark script, since tilt dep version is not compatible with
9
+ Sinatra
10
+
1
11
  3.0.1
2
12
  - File SystemStackError when accessing missing param (@holies)
3
13
 
data/Performance.md CHANGED
@@ -1,4 +1,8 @@
1
- This output was generated by running benchmark.rb in repo root
1
+
2
+ Note: this bench may be a bit obsolete, I removed the profiling
3
+ script due to the fact that NYNY's and Sintara's deps are
4
+ incompatible. For a more complete list of of microframework
5
+ benchmarks, see [https://github.com/luislavena/bench-micro]()
2
6
  ```
3
7
  Comparing NYNY 3.0.0 with Sinatra 1.4.4
4
8
 
data/README.md CHANGED
@@ -213,6 +213,7 @@ class App < NYNY::App
213
213
  end
214
214
  end
215
215
  ```
216
+
216
217
  There are 2 ways to pass data to the template:
217
218
 
218
219
  Via a instance variable:
@@ -239,7 +240,7 @@ to create a helper for that:
239
240
  ```ruby
240
241
  class App < NYNY::App
241
242
  helpers do
242
- def render_with_layout *args
243
+ def template *args
243
244
  render 'layout.erb' do
244
245
  render *args
245
246
  end
@@ -247,7 +248,7 @@ class App < NYNY::App
247
248
  end
248
249
 
249
250
  get '/' do
250
- render_with_layout 'index.erb'
251
+ template 'index.erb'
251
252
  end
252
253
  end
253
254
  ```
data/lib/nyny/app.rb CHANGED
@@ -27,15 +27,16 @@ module NYNY
27
27
  def initialize app=nil
28
28
  self.class.builder.run Router.new({
29
29
  :routes => self.class.routes,
30
- :fallback => (app || lambda {|env| Response.new '', 404 }),
30
+ :fallback => (app || lambda {|env| Response.new [], 404 }),
31
31
  :before_hooks => self.class.before_hooks,
32
32
  :after_hooks => self.class.after_hooks,
33
33
  :scope_class => self.class.scope_class
34
34
  })
35
+ @app = self.class.builder.to_app
35
36
  end
36
37
 
37
38
  def call env
38
- self.class.builder.call env
39
+ @app.call env
39
40
  end
40
41
 
41
42
  #class methods
@@ -1,19 +1,11 @@
1
+ require 'better_errors'
2
+
1
3
  module NYNY
2
4
  module Runner
3
- def optimal_runner
4
- return Rack::Handler::WEBrick if RUBY_PLATFORM == 'java'
5
-
6
- begin
7
- Rack::Handler::Thin
8
- rescue LoadError
9
- Rack::Handler::WEBrick
10
- end
11
- end
12
-
13
5
  def run! port=9292
14
6
  use Rack::CommonLogger
15
- use Rack::ShowExceptions unless NYNY.env.production?
16
- optimal_runner.run new, :Port => port
7
+ use BetterErrors::Middleware unless NYNY.env.production?
8
+ Rack::Handler.pick(['thin', 'webrick']).run new, :Port => port
17
9
  end
18
10
  end
19
11
  end
@@ -3,23 +3,13 @@ module NYNY
3
3
  end
4
4
 
5
5
  class Response < Rack::Response
6
- attr_reader :raw_body
7
-
8
- def initialize body=[], status=200, header={}
9
- @raw_body = body
10
- super body.to_s, status, header
11
- end
12
-
13
- def body= value
14
- @raw_body = value
15
- @body = []
6
+ def rewrite str
7
+ @body = []
16
8
  @length = 0
17
-
18
- if value.respond_to? :to_str
19
- write value.to_str
20
- elsif value.respond_to?(:each)
21
- value.each {|part| write part.to_s }
22
- end
9
+ header.delete "Content-Type"
10
+ header.delete "Content-Length"
11
+ write str
23
12
  end
13
+ alias_method :body=, :rewrite
24
14
  end
25
15
  end
@@ -11,7 +11,7 @@ module NYNY
11
11
 
12
12
  def initialize request
13
13
  @request = request
14
- @response = Response.new '', 200, {'Content-Type' => 'text/html'}
14
+ @response = Response.new
15
15
  end
16
16
 
17
17
  def cookies
@@ -25,7 +25,8 @@ module NYNY
25
25
  def halt status, headers={}, body=''
26
26
  response.status = status
27
27
  response.headers.merge! headers
28
- response.body = body
28
+ response.rewrite body
29
+ cookies.finish!(response) if @cookies
29
30
  throw :halt, response.finish
30
31
  end
31
32
 
@@ -35,8 +36,8 @@ module NYNY
35
36
  alias_method :redirect, :redirect_to
36
37
 
37
38
  def apply_to &handler
38
- response.body = instance_eval(&handler)
39
- cookies.finish!(response)
39
+ response.write instance_eval(&handler)
40
+ cookies.finish!(response) if @cookies
40
41
  response.finish
41
42
  end
42
43
  end
data/lib/nyny/router.rb CHANGED
@@ -23,9 +23,9 @@ module NYNY
23
23
  def process route, env
24
24
  request = Request.new(env)
25
25
  request.params.merge! route.url_params(env)
26
- request.params.default_proc = proc { |h, k|
26
+ request.params.default_proc = lambda do |h, k|
27
27
  h.fetch(k.to_s, nil) || h.fetch(k.to_sym, nil)
28
- }
28
+ end
29
29
 
30
30
  eval_response scope_class.new(request), route.handler
31
31
  end
data/lib/nyny/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module NYNY
2
- VERSION = "3.0.1"
2
+ VERSION = "3.1.0"
3
3
  end
data/nyny.gemspec CHANGED
@@ -20,9 +20,10 @@ Gem::Specification.new do |spec|
20
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_dependency "rack", "~> 1.5.2"
24
- spec.add_dependency "rack-contrib", "~> 1.1.0"
25
- spec.add_dependency "tilt", "~> 1.4.1"
23
+ spec.add_dependency "rack", "~> 1.5.2"
24
+ spec.add_dependency "rack-contrib", "~> 1.1.0"
25
+ spec.add_dependency "tilt", "~> 2.0.0"
26
+ spec.add_dependency "better_errors", "~> 1.1.0"
26
27
  spec.add_development_dependency "bundler", "~> 1.3"
27
28
  spec.add_development_dependency "rake"
28
29
  spec.add_development_dependency "rspec"
data/spec/app_spec.rb CHANGED
@@ -167,31 +167,6 @@ describe App do
167
167
  app.get '/'
168
168
  end
169
169
 
170
- describe 'cookies' do
171
- let (:app) do
172
- mock_app do
173
- post '/cookie' do
174
- cookies['foo'] = 'bar'
175
- end
176
-
177
- delete '/cookie' do
178
- cookies.delete 'foo'
179
- end
180
- end
181
- end
182
-
183
- it 'sets a cookie' do
184
- res = app.post '/cookie'
185
- res.headers['Set-Cookie'].should == 'foo=bar; path=/'
186
- end
187
-
188
- it 'deletes a cookie' do
189
- app.post '/cookie'
190
- res = app.delete '/cookie'
191
- res.headers['Set-Cookie'].should_not include('foo=bar')
192
- end
193
- end
194
-
195
170
  it 'works with empty path' do
196
171
  kls = mock_app_class do
197
172
  get '/' do
@@ -201,7 +176,7 @@ describe App do
201
176
 
202
177
  env = Rack::MockRequest.env_for '/'
203
178
  env['PATH_INFO'] = ''
204
- kls.new.call(env)[2].body.first.should == 'Hello'
179
+ kls.new.call(env)[2].body.last.should == 'Hello'
205
180
  end
206
181
 
207
182
  describe 'Class level api' do
@@ -1,33 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Request do
4
- let (:subject) { Request.new double }
5
-
6
- it { should be_a(Rack::Request) }
7
- end
8
-
9
- describe Response do
10
- it { should be_a(Rack::Response) }
11
-
12
- describe '#raw_body' do
13
- it 'should be accesible when the response was initialized' do
14
- raw_body = double
15
- res = Response.new raw_body
16
- res.raw_body.should == raw_body
17
- end
18
-
19
- it 'should accesible after body was set' do
20
- res = Response.new
21
- raw_body = double
22
- res.body = raw_body
23
- res.raw_body.should == raw_body
24
- end
25
-
26
- it 'should set the iterable as the raw body as well' do
27
- res = Response.new
28
- raw_body = ['one', 'two']
29
- res.body = raw_body
30
- res.raw_body.should == raw_body
3
+ describe 'NYNY primitives' do
4
+ describe NYNY::Response do
5
+ it 'allows to rewrite the response' do
6
+ resp = NYNY::Response.new
7
+ resp.write 'foo'
8
+ resp.rewrite 'banana'
9
+ resp.headers['Content-Length'].should == "6"
10
+ resp.body.first.should == 'banana'
31
11
  end
32
12
  end
33
- end
13
+ end
@@ -23,6 +23,56 @@ describe RequestScope do
23
23
  app.get '/?foo=bar'
24
24
  end
25
25
 
26
+ describe 'cookies' do
27
+ let (:app) do
28
+ mock_app do
29
+ post '/cookie' do
30
+ cookies['foo'] = 'bar'
31
+ end
32
+
33
+ post '/cookie_halt' do
34
+ cookies['foo'] = 'bar'
35
+ halt 200, {}, 'blah'
36
+ cookies['foo'] = 'moo'
37
+ end
38
+
39
+ delete '/cookie' do
40
+ cookies.delete 'foo'
41
+ end
42
+
43
+ delete '/cookie_halt' do
44
+ cookies.delete 'foo'
45
+ halt 200, {}, 'blah'
46
+ 'blah'
47
+ end
48
+ end
49
+ end
50
+
51
+ it 'sets a cookie' do
52
+ res = app.post '/cookie'
53
+ res.headers['Set-Cookie'].should == 'foo=bar; path=/'
54
+ end
55
+
56
+ it 'deletes a cookie' do
57
+ app.post '/cookie'
58
+ res = app.delete '/cookie'
59
+ res.headers['Set-Cookie'].should_not include('foo=bar')
60
+ end
61
+
62
+ describe 'when response was halted' do
63
+ it 'sets a cookie' do
64
+ res = app.post '/cookie_halt'
65
+ res.headers['Set-Cookie'].should == 'foo=bar; path=/'
66
+ end
67
+
68
+ it 'deletes a cookie' do
69
+ app.post '/cookie'
70
+ res = app.delete '/cookie_halt'
71
+ res.headers['Set-Cookie'].should_not include('foo=bar')
72
+ end
73
+ end
74
+ end
75
+
26
76
  it '#headers should set the header values' do
27
77
  subject.headers['Head'] = 'Tail'
28
78
  response = subject.apply_to &handler
@@ -76,13 +126,13 @@ describe RequestScope do
76
126
  it 'return prematurely with pass' do
77
127
  app = mock_app do
78
128
  get '/' do
79
- next 'hui'
129
+ next 'blah'
80
130
  'shouldnt be returned'
81
131
  end
82
132
  end
83
133
  res = app.get '/'
84
134
  res.status.should == 200
85
- res.body.should == 'hui'
135
+ res.body.should == 'blah'
86
136
  end
87
137
 
88
138
  it '#redirect_to should redirect' do
data/spec/router_spec.rb CHANGED
@@ -13,7 +13,7 @@ describe Router do
13
13
  end
14
14
 
15
15
  after do
16
- response.body = "Zaz"
16
+ response.rewrite "Zaz"
17
17
  end
18
18
  end
19
19
  end
@@ -24,6 +24,6 @@ describe Router do
24
24
  end
25
25
 
26
26
  it "should not raise SystemStackError if any absent param is accessed" do
27
- expect { response = app.post('/') }.not_to raise_error SystemStackError
27
+ expect { response = app.post('/') }.not_to raise_error
28
28
  end
29
29
  end
data/spec/runner_spec.rb CHANGED
@@ -4,19 +4,19 @@ describe Runner do
4
4
  let (:kls) { mock_app_class {} }
5
5
 
6
6
  before do
7
- kls.optimal_runner.stub :run
7
+ Rack::Handler.stub :pick => double(:run => nil)
8
8
  end
9
9
 
10
10
  it 'should include the default middleware on top' do
11
11
  kls.should_receive(:use).with(Rack::CommonLogger)
12
- kls.should_receive(:use).with(Rack::ShowExceptions)
12
+ kls.should_receive(:use).with(BetterErrors::Middleware)
13
13
  kls.run!
14
14
  end
15
15
 
16
16
  it 'should not include show exceptions middleware in production' do
17
17
  NYNY.env.stub :production? => true
18
18
  kls.should_receive(:use).with(Rack::CommonLogger)
19
- kls.should_not_receive(:use).with(Rack::ShowExceptions)
19
+ kls.should_not_receive(:use).with(BetterErrors::Middleware)
20
20
  kls.run!
21
21
  end
22
22
 
data/spec/spec_helper.rb CHANGED
@@ -55,7 +55,3 @@ end
55
55
 
56
56
  module NullHelper
57
57
  end
58
-
59
- RSpec.configure do |c|
60
- c.filter_run_excluding :broken => true
61
- end
@@ -1,8 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Templates do
4
- let (:app) do
5
- mock_app do
4
+ let (:app_class) do
5
+ mock_app_class do
6
+ helpers do
7
+ def template_root
8
+ File.join(__dir__, "views")
9
+ end
10
+ end
11
+
6
12
  get '/without_layout' do
7
13
  render template('index.erb')
8
14
  end
@@ -18,12 +24,18 @@ describe Templates do
18
24
  render template('instance.erb')
19
25
  end
20
26
 
27
+ get '/via_helper' do
28
+ erb :index
29
+ end
30
+
21
31
  get '/local_var' do
22
32
  render template('local.erb'), :foo => 'bar'
23
33
  end
24
34
  end
25
35
  end
26
36
 
37
+ let (:app) { Rack::MockRequest.new(app_class.new)}
38
+
27
39
  it 'renders correctly without layout' do
28
40
  response = app.get('/without_layout')
29
41
  response.body.should == '<p>Hello!</p>'
@@ -48,5 +60,4 @@ describe Templates do
48
60
 
49
61
  response.body.should == rendered
50
62
  end
51
-
52
63
  end
metadata CHANGED
@@ -1,97 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nyny
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Lisnic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-16 00:00:00.000000000 Z
11
+ date: 2014-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.5.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.5.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rack-contrib
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.1.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: tilt
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.4.1
47
+ version: 2.0.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.4.1
54
+ version: 2.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: better_errors
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.1.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.1.0
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - ~>
73
+ - - "~>"
60
74
  - !ruby/object:Gem::Version
61
75
  version: '1.3'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - ~>
80
+ - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: '1.3'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rake
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - '>='
87
+ - - ">="
74
88
  - !ruby/object:Gem::Version
75
89
  version: '0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - '>='
94
+ - - ">="
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rspec
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - '>='
101
+ - - ">="
88
102
  - !ruby/object:Gem::Version
89
103
  version: '0'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - '>='
108
+ - - ">="
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  description: New York, New York - (very) small Sinatra clone.
@@ -101,17 +115,16 @@ executables: []
101
115
  extensions: []
102
116
  extra_rdoc_files: []
103
117
  files:
104
- - .gitignore
105
- - .rspec
106
- - .ruby-version
107
- - .travis.yml
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".ruby-version"
121
+ - ".travis.yml"
108
122
  - CHANGELOG
109
123
  - Gemfile
110
124
  - LICENSE.txt
111
125
  - Performance.md
112
126
  - README.md
113
127
  - Rakefile
114
- - benchmark.rb
115
128
  - lib/nyny.rb
116
129
  - lib/nyny/app.rb
117
130
  - lib/nyny/core-ext/runner.rb
@@ -145,17 +158,17 @@ require_paths:
145
158
  - lib
146
159
  required_ruby_version: !ruby/object:Gem::Requirement
147
160
  requirements:
148
- - - '>='
161
+ - - ">="
149
162
  - !ruby/object:Gem::Version
150
163
  version: 1.9.2
151
164
  required_rubygems_version: !ruby/object:Gem::Requirement
152
165
  requirements:
153
- - - '>='
166
+ - - ">="
154
167
  - !ruby/object:Gem::Version
155
168
  version: '0'
156
169
  requirements: []
157
170
  rubyforge_project:
158
- rubygems_version: 2.0.14
171
+ rubygems_version: 2.2.0
159
172
  signing_key:
160
173
  specification_version: 4
161
174
  summary: New York, New York.
data/benchmark.rb DELETED
@@ -1,116 +0,0 @@
1
- #!ruby -I ./lib -I lib
2
- require 'nyny'
3
- require 'ruby-prof'
4
- require 'benchmark'
5
- require 'sinatra'
6
- include Benchmark
7
-
8
- set :run, false #do not run sinatra's builtin web server
9
-
10
- def build_apps &block
11
- sinatra = Class.new(Sinatra::Base, &block).new
12
- nyny = Class.new(NYNY::App, &block).new
13
- return [nyny, sinatra].map {|app| Rack::MockRequest.new(app) }
14
- end
15
-
16
- def run_test name, apps, &block
17
- nyny, sinatra = apps
18
- prc = Proc.new(&block)
19
-
20
- puts "\nTest: #{name}"
21
- Benchmark.benchmark(CAPTION, 7, FORMAT, "> NYNY/Sinatra:") do |x|
22
- nyny_time = x.report("nyny: ") { 1000.times { prc.call(nyny) } }
23
- sinatra_time = x.report("sinatra:") { 1000.times { prc.call(sinatra) } }
24
- puts "NYNY is #{"%.2f" % [sinatra_time.real/nyny_time.real]}x faster than Sinatra in this test"
25
- end
26
- end
27
-
28
- puts "Comparing NYNY #{NYNY::VERSION} with Sinatra #{Sinatra::VERSION}"
29
-
30
- #
31
- # Hello World
32
- apps = build_apps do
33
- get '/' do
34
- 'Hello World'
35
- end
36
- end
37
- run_test 'hello world', apps do |app|
38
- app.get '/'
39
- end
40
-
41
- #
42
- # Filters
43
- apps = build_apps do
44
- before do
45
- request
46
- end
47
-
48
- after do
49
- response
50
- end
51
-
52
- get '/' do
53
- 'Hello World!'
54
- end
55
- end
56
- run_test 'filters', apps do |app|
57
- app.get '/'
58
- end
59
-
60
- #
61
- # Helpers
62
- apps = build_apps do
63
- helpers do
64
- def da_request
65
- request
66
- end
67
- end
68
-
69
- get '/' do
70
- da_request
71
- end
72
- end
73
- run_test 'helpers', apps do |app|
74
- app.get '/'
75
- end
76
-
77
- #
78
- # Url patterns
79
- apps = build_apps do
80
- get '/:name' do
81
- params[:name]
82
- end
83
- end
84
- run_test 'Url patterns', apps do |app|
85
- app.get '/foo'
86
- end
87
-
88
- # Plain routes
89
- apps = build_apps do
90
- [:get, :post, :put].each do |method|
91
- 10.times do |i|
92
- send(method, "/foo/#{i}") do
93
- i
94
- end
95
- end
96
- end
97
- end
98
- run_test 'A lot o Plain routes', apps do |app|
99
- app.get '/foo/5'
100
- end
101
-
102
- #
103
- # Pattern routes
104
- apps = build_apps do
105
- [:get, :post, :put].each do |method|
106
- 10.times do |i|
107
- send(method, "/foo/#{i}/:action") do
108
- params[:action]
109
- end
110
- end
111
- end
112
- end
113
- run_test 'A lot of Pattern routes', apps do |app|
114
- app.get '/foo/5/edit'
115
- end
116
-