Permalink
Browse files

Initial spec

  • Loading branch information...
1 parent 8dc2466 commit b13428f22a0f6198603a0daabe66c220b90b9d49 Yehuda Katz committed Jul 17, 2008
@@ -1,4 +1,4 @@
-class MerbRestServer::Main < MerbRestServer::Application
+class MerbRestServer::Rest < MerbRestServer::Application
def index
render
@@ -22,8 +22,8 @@ module MerbRestServer
# Slice metadata
self.description = "MerbRestServer is a chunky Merb slice!"
- self.version = "0.0.1"
- self.author = "YOUR NAME"
+ self.version = "0.5.0"
+ self.author = "Yehuda Katz"
# Stub classes loaded hook - runs before LoadClasses BootLoader
# right after a slice's classes have been loaded internally.
@@ -1,61 +0,0 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-
-describe "MerbRestServer::Main (controller)" do
-
- # Feel free to remove the specs below
-
- before :all do
- Merb::Router.prepare { |r| r.add_slice(:MerbRestServer) } if standalone?
- end
-
- after :all do
- Merb::Router.reset! if standalone?
- end
-
- it "should have access to the slice module" do
- controller = dispatch_to(MerbRestServer::Main, :index)
- controller.slice.should == MerbRestServer
- controller.slice.should == MerbRestServer::Main.slice
- end
-
- it "should have an index action" do
- controller = dispatch_to(MerbRestServer::Main, :index)
- controller.status.should == 200
- controller.body.should contain('MerbRestServer')
- end
-
- it "should work with the default route" do
- controller = get("/merb_rest_server/main/index")
- controller.should be_kind_of(MerbRestServer::Main)
- controller.action_name.should == 'index'
- end
-
- it "should work with the example named route" do
- controller = get("/merb_rest_server/index.html")
- controller.should be_kind_of(MerbRestServer::Main)
- controller.action_name.should == 'index'
- end
-
- it "should have routes in MerbRestServer.routes" do
- MerbRestServer.routes.should_not be_empty
- end
-
- it "should have a slice_url helper method for slice-specific routes" do
- controller = dispatch_to(MerbRestServer::Main, 'index')
- controller.slice_url(:action => 'show', :format => 'html').should == "/merb_rest_server/main/show.html"
- controller.slice_url(:merb_rest_server_index, :format => 'html').should == "/merb_rest_server/index.html"
- end
-
- it "should have helper methods for dealing with public paths" do
- controller = dispatch_to(MerbRestServer::Main, :index)
- controller.public_path_for(:image).should == "/slices/merb_rest_server/images"
- controller.public_path_for(:javascript).should == "/slices/merb_rest_server/javascripts"
- controller.public_path_for(:stylesheet).should == "/slices/merb_rest_server/stylesheets"
- end
-
- it "should have a slice-specific _template_root" do
- MerbRestServer::Main._template_root.should == MerbRestServer.dir_for(:view)
- MerbRestServer::Main._template_root.should == MerbRestServer::Application._template_root
- end
-
-end
@@ -0,0 +1,66 @@
+require File.dirname(__FILE__) + '/../spec_helper'
+
+describe "MerbRestServer::Rest (controller)" do
+
+ # Feel free to remove the specs below
+
+ before :all do
+ Merb::Router.prepare { |r| r.add_slice(:MerbRestServer, :path => "rest", :default_routes => false) } if standalone?
+ end
+
+ after :all do
+ Merb::Router.reset! if standalone?
+ end
+
+ it "routes GET /rest/foo/1 to Rest#show :id => 1" do
+ controller = get("/rest/foo/1")
+ controller.action_name.should == "show"
+ end
+
+ # it "should have access to the slice module" do
+ # controller = dispatch_to(MerbRestServer::Rest, :index)
+ # controller.slice.should == MerbRestServer
+ # controller.slice.should == MerbRestServer::Rest.slice
+ # end
+ #
+ # it "should have an index action" do
+ # controller = dispatch_to(MerbRestServer::Rest, :index)
+ # controller.status.should == 200
+ # controller.body.should contain('MerbRestServer')
+ # end
+ #
+ # it "should work with the default route" do
+ # controller = get("/merb_rest_server/main/index")
+ # controller.should be_kind_of(MerbRestServer::Rest)
+ # controller.action_name.should == 'index'
+ # end
+ #
+ # it "should work with the example named route" do
+ # controller = get("/merb_rest_server/index.html")
+ # controller.should be_kind_of(MerbRestServer::Main)
+ # controller.action_name.should == 'index'
+ # end
+ #
+ # it "should have routes in MerbRestServer.routes" do
+ # MerbRestServer.routes.should_not be_empty
+ # end
+ #
+ # it "should have a slice_url helper method for slice-specific routes" do
+ # controller = dispatch_to(MerbRestServer::Main, 'index')
+ # controller.slice_url(:action => 'show', :format => 'html').should == "/merb_rest_server/main/show.html"
+ # controller.slice_url(:merb_rest_server_index, :format => 'html').should == "/merb_rest_server/index.html"
+ # end
+ #
+ # it "should have helper methods for dealing with public paths" do
+ # controller = dispatch_to(MerbRestServer::Main, :index)
+ # controller.public_path_for(:image).should == "/slices/merb_rest_server/images"
+ # controller.public_path_for(:javascript).should == "/slices/merb_rest_server/javascripts"
+ # controller.public_path_for(:stylesheet).should == "/slices/merb_rest_server/stylesheets"
+ # end
+ #
+ # it "should have a slice-specific _template_root" do
+ # MerbRestServer::Main._template_root.should == MerbRestServer.dir_for(:view)
+ # MerbRestServer::Main._template_root.should == MerbRestServer::Application._template_root
+ # end
+
+end
@@ -41,8 +41,8 @@
it "should have metadata properties" do
MerbRestServer.description.should == "MerbRestServer is a chunky Merb slice!"
- MerbRestServer.version.should == "0.0.1"
- MerbRestServer.author.should == "YOUR NAME"
+ MerbRestServer.version.should == "0.5.0"
+ MerbRestServer.author.should == "Yehuda Katz"
end
it "should have :routes and :named_routes properties" do

0 comments on commit b13428f

Please sign in to comment.