hobbit 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hobbit/base.rb +2 -1
- data/lib/hobbit/version.rb +1 -1
- data/spec/base_spec.rb +7 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 672fdf5ecb22bb543a996b77a3e9075a514ea07f
|
4
|
+
data.tar.gz: f6e93b013f31f18c4de763d10198f5c99fe7ec02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b67669025634a181383d1f3b01e6ddab23d90fccc1db1ff00c5c7fdae1dc8aa94c942adcf473e06463ad02fd68b0bd81b49c4d764c3f0b3ed81118b9354b2b1
|
7
|
+
data.tar.gz: fb0fe4d2c7e87d76f5adc8ab0dab1cdefd7d63b7fd987035d631a2c05fee99294c9294691eddaede31af0ccf1e0787cc63ea5b5b3bdb2440493bb6d411887b6b
|
data/lib/hobbit/base.rb
CHANGED
@@ -2,7 +2,7 @@ module Hobbit
|
|
2
2
|
class Base
|
3
3
|
class << self
|
4
4
|
%w(DELETE GET HEAD OPTIONS PATCH POST PUT).each do |verb|
|
5
|
-
define_method(verb.downcase) { |path
|
5
|
+
define_method(verb.downcase) { |path, &block| routes[verb] << compile_route(path, &block) }
|
6
6
|
end
|
7
7
|
|
8
8
|
def map(path, &block)
|
@@ -49,6 +49,7 @@ module Hobbit
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def _call(env)
|
52
|
+
env['PATH_INFO'] = '/' if env['PATH_INFO'].empty?
|
52
53
|
@env = env
|
53
54
|
@request = Rack::Request.new(@env)
|
54
55
|
@response = Hobbit::Response.new
|
data/lib/hobbit/version.rb
CHANGED
data/spec/base_spec.rb
CHANGED
@@ -11,7 +11,6 @@ describe Hobbit::Base do
|
|
11
11
|
before do
|
12
12
|
mock_app do
|
13
13
|
%w(DELETE GET HEAD OPTIONS PATCH POST PUT).each do |verb|
|
14
|
-
class_eval "#{verb.downcase} { '#{verb}' }"
|
15
14
|
class_eval "#{verb.downcase}('/') { '#{verb}' }"
|
16
15
|
class_eval "#{verb.downcase}('/route.json') { '#{verb} /route.json' }"
|
17
16
|
class_eval "#{verb.downcase}('/route/:id.json') { request.params[:id] }"
|
@@ -25,7 +24,7 @@ describe Hobbit::Base do
|
|
25
24
|
describe "::#{verb.downcase}" do
|
26
25
|
it 'must add a route to @routes' do
|
27
26
|
route = app.to_app.class.routes['#{verb}'].first
|
28
|
-
route[:path].must_equal ''
|
27
|
+
route[:path].must_equal '/'
|
29
28
|
end
|
30
29
|
|
31
30
|
it 'must extract the extra_params' do
|
@@ -102,15 +101,6 @@ EOS
|
|
102
101
|
describe '::compile_route' do
|
103
102
|
let(:block) { block = Proc.new { |env| [200, {}, []] } }
|
104
103
|
|
105
|
-
it 'must compile an empty string' do
|
106
|
-
path = ''
|
107
|
-
route = Hobbit::Base.send :compile_route, path, &block
|
108
|
-
route[:block].call({}).must_equal block.call({})
|
109
|
-
route[:compiled_path].to_s.must_equal /^$/.to_s
|
110
|
-
route[:extra_params].must_equal []
|
111
|
-
route[:path].must_equal path
|
112
|
-
end
|
113
|
-
|
114
104
|
it 'must compile /' do
|
115
105
|
path = '/'
|
116
106
|
route = Hobbit::Base.send :compile_route, path, &block
|
@@ -168,6 +158,12 @@ EOS
|
|
168
158
|
%w(DELETE GET HEAD OPTIONS PATCH POST PUT).each do |verb|
|
169
159
|
str = <<EOS
|
170
160
|
describe 'when the request matches a route' do
|
161
|
+
it 'must match #{verb} ""' do
|
162
|
+
#{verb.downcase} ''
|
163
|
+
last_response.must_be :ok?
|
164
|
+
last_response.body.must_equal '#{verb}'
|
165
|
+
end
|
166
|
+
|
171
167
|
it 'must match #{verb} /' do
|
172
168
|
#{verb.downcase} '/'
|
173
169
|
last_response.must_be :ok?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hobbit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patricio Mac Adden
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|