rory 0.3.4 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rory/dispatcher.rb +2 -1
- data/lib/rory/version.rb +1 -1
- data/spec/application_spec.rb +3 -3
- data/spec/controller_spec.rb +2 -2
- data/spec/dispatcher_spec.rb +10 -0
- metadata +2 -2
data/lib/rory/dispatcher.rb
CHANGED
@@ -17,7 +17,8 @@ module Rory
|
|
17
17
|
def get_route
|
18
18
|
match = nil
|
19
19
|
route = route_map.detect do |route_hash|
|
20
|
-
|
20
|
+
path_name = @request.path_info[1..-1] || ''
|
21
|
+
match = route_hash[:regex].match(path_name)
|
21
22
|
methods = route_hash[:methods] || []
|
22
23
|
match && (methods.empty? || methods.include?(method.to_sym))
|
23
24
|
end
|
data/lib/rory/version.rb
CHANGED
data/spec/application_spec.rb
CHANGED
@@ -40,7 +40,7 @@ describe Rory::Application do
|
|
40
40
|
|
41
41
|
describe ".call" do
|
42
42
|
it "forwards arg to new dispatcher, and calls dispatch" do
|
43
|
-
dispatcher =
|
43
|
+
dispatcher = double(:dispatch => :expected)
|
44
44
|
rack_request = double
|
45
45
|
Rack::Request.stub(:new).with(:env).and_return(rack_request)
|
46
46
|
Rory::Dispatcher.should_receive(:new).with(rack_request, Fixture::Application.instance).and_return(dispatcher)
|
@@ -51,7 +51,7 @@ describe Rory::Application do
|
|
51
51
|
describe ".load_config_data" do
|
52
52
|
it "returns parsed yaml file with given name from directory at config_path" do
|
53
53
|
Fixture::Application.any_instance.stub(:config_path).and_return('Africa the Great')
|
54
|
-
YAML.stub
|
54
|
+
YAML.stub(:load_file).with(
|
55
55
|
File.expand_path(File.join('Africa the Great', 'foo_type.yml'))).
|
56
56
|
and_return(:oscar_the_grouch_takes_a_nap)
|
57
57
|
Fixture::Application.load_config_data(:foo_type).should == :oscar_the_grouch_takes_a_nap
|
@@ -62,7 +62,7 @@ describe Rory::Application do
|
|
62
62
|
it "sets up sequel connection to DB from YAML file" do
|
63
63
|
config = { 'development' => :expected }
|
64
64
|
Fixture::Application.any_instance.stub(:load_config_data).with(:database).and_return(config)
|
65
|
-
Sequel.should_receive(:connect).with(:expected).and_return(
|
65
|
+
Sequel.should_receive(:connect).with(:expected).and_return(double(:loggers => []))
|
66
66
|
Fixture::Application.connect_db('development')
|
67
67
|
end
|
68
68
|
end
|
data/spec/controller_spec.rb
CHANGED
@@ -51,7 +51,7 @@ describe Rory::Controller do
|
|
51
51
|
|
52
52
|
describe "#redirect" do
|
53
53
|
it "delegates to dispatcher from request" do
|
54
|
-
@request[:dispatcher] = dispatcher =
|
54
|
+
@request[:dispatcher] = dispatcher = double
|
55
55
|
dispatcher.should_receive(:redirect).with(:whatever)
|
56
56
|
controller = Rory::Controller.new(@request)
|
57
57
|
controller.redirect(:whatever)
|
@@ -60,7 +60,7 @@ describe Rory::Controller do
|
|
60
60
|
|
61
61
|
describe "#render_not_found" do
|
62
62
|
it "delegates to dispatcher from request" do
|
63
|
-
@request[:dispatcher] = dispatcher =
|
63
|
+
@request[:dispatcher] = dispatcher = double
|
64
64
|
dispatcher.should_receive(:render_not_found)
|
65
65
|
controller = Rory::Controller.new(@request)
|
66
66
|
controller.render_not_found
|
data/spec/dispatcher_spec.rb
CHANGED
@@ -75,6 +75,16 @@ describe Rory::Dispatcher do
|
|
75
75
|
}
|
76
76
|
end
|
77
77
|
|
78
|
+
it "works with empty path" do
|
79
|
+
@request.stub(:path_info => '', :request_method => 'GET')
|
80
|
+
@dispatcher.get_route.should == {
|
81
|
+
:controller => 'root',
|
82
|
+
:action => 'vegetable',
|
83
|
+
:regex => /^$/,
|
84
|
+
:methods => [:get]
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
78
88
|
it "works with root url represented by slash" do
|
79
89
|
@request.stub(:path_info => '/', :request_method => 'GET')
|
80
90
|
@dispatcher.get_route.should == {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-02-
|
12
|
+
date: 2014-02-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|