Skip to content

Commit

Permalink
Support for routing resources.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eivind Uggedal committed Apr 11, 2008
1 parent d4278ad commit aeccde7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/halcyon.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$:.unshift File.dirname(__FILE__)

%w(rubygems rack merb-core/core_ext merb-core/dispatch/router json uri).each {|dep|require dep}
%w(rubygems rack merb-core/core_ext merb-core/vendor/facets merb-core/dispatch/router json uri).each {|dep|require dep}

# Provides global values, like the root of the current application directory,
# the current logger, the application name, and the framework version.
Expand Down
12 changes: 12 additions & 0 deletions spec/halcyon/router_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,16 @@
Halcyon::Application::Router.route(request)[:arbitrary].should == 'random'
end

it "should match index method of resources" do
index_req = Rack::Request.new(Rack::MockRequest.env_for('/resources'))
Halcyon::Application::Router.route(index_req)[:controller].should == 'resources'
Halcyon::Application::Router.route(index_req)[:action].should == 'index'
end

it "should match show method of resource" do
show_req = Rack::Request.new(Rack::MockRequest.env_for('/resources/id'))
Halcyon::Application::Router.route(show_req)[:controller].should == 'resources'
Halcyon::Application::Router.route(show_req)[:action].should == 'show'
end

end
13 changes: 13 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,21 @@ def cause_exception

end

class Resources < Application

def index
ok('List of resources')
end

def show
ok("One resource: #{params[:id]}")
end
end

class Halcyon::Application
route do |r|
r.resources :resources

r.match('/hello/:name').to(:controller => 'specs', :action => 'greeter')
r.match('/:action').to(:controller => 'specs')
r.match('/:controller/:action').to()
Expand Down

0 comments on commit aeccde7

Please sign in to comment.