0
@@ -157,6 +157,123 @@ module Spec
0
+def it_should_be_a_resource_collection_route(name, *args)
0
+ params = extract_options_from_args!(args) || {}
0
+ prefix = args.first.is_a?(String) ? args.shift : ""
0
+ opts = args.first.is_a?(Hash) ? args.shift : {}
0
+ id = opts[:id] || "45"
0
+ it "should provide #{name} with an 'index' route" do
0
+ route_for("#{prefix}/#{name}").should have_route({:action => "index", :controller => "#{name}", :id => nil, :format => nil }.merge(params))
0
+ route_for("#{prefix}/#{name}/index").should have_route({:action => "index", :controller => "#{name}", :id => nil, :format => nil }.merge(params))
0
+ route_for("#{prefix}/#{name}.js").should have_route({:action => "index", :controller => "#{name}", :id => nil, :format => "js"}.merge(params))
0
+ route_for("#{prefix}/#{name}/index.js").should have_route({:action => "index", :controller => "#{name}", :id => nil, :format => "js"}.merge(params))
0
+ it "should provide #{name} with a 'new' route" do
0
+ route_for("#{prefix}/#{name}/new").should have_route({:action => "new", :controller => "#{name}", :id => nil, :format => nil }.merge(params))
0
+ route_for("#{prefix}/#{name}/new.js").should have_route({:action => "new", :controller => "#{name}", :id => nil, :format => "js"}.merge(params))
0
+ it "should provide #{name} with a 'create' route" do
0
+ route_for("#{prefix}/#{name}", :method => :post).should have_route({:action => "create", :controller => "#{name}", :id => nil, :format => nil }.merge(params))
0
+ route_for("#{prefix}/#{name}.js", :method => :post).should have_route({:action => "create", :controller => "#{name}", :id => nil, :format => "js"}.merge(params))
0
+ it "should provide #{name} with a 'show' route" do
0
+ route_for("#{prefix}/#{name}/#{id}").should have_route({:action => "show", :controller => "#{name}", :id => id, :format => nil }.merge(params))
0
+ route_for("#{prefix}/#{name}/#{id}.js").should have_route({:action => "show", :controller => "#{name}", :id => id, :format => "js"}.merge(params))
0
+ it "should provide #{name} with an 'edit' route" do
0
+ route_for("#{prefix}/#{name}/#{id}/edit").should have_route({:action => "edit", :controller => "#{name}", :id => id, :format => nil }.merge(params))
0
+ route_for("#{prefix}/#{name}/#{id}/edit.js").should have_route({:action => "edit", :controller => "#{name}", :id => id, :format => "js"}.merge(params))
0
+ it "should provide #{name} with an 'update' route" do
0
+ route_for("#{prefix}/#{name}/#{id}", :method => :put).should have_route({:action => "update", :controller => "#{name}", :id => id, :format => nil }.merge(params))
0
+ route_for("#{prefix}/#{name}/#{id}.js", :method => :put).should have_route({:action => "update", :controller => "#{name}", :id => id, :format => "js"}.merge(params))
0
+ it "should provide #{name} with a 'delete' route" do
0
+ route_for("#{prefix}/#{name}/#{id}/delete").should have_route({:action => "delete", :controller => "#{name}", :id => id, :format => nil }.merge(params))
0
+ route_for("#{prefix}/#{name}/#{id}/delete.js").should have_route({:action => "delete", :controller => "#{name}", :id => id, :format => "js"}.merge(params))
0
+ it "should provide #{name} with a 'destroy' route" do
0
+ route_for("#{prefix}/#{name}/#{id}", :method => :delete).should have_route({:action => "destroy", :controller => "#{name}", :id => id, :format => nil }.merge(params))
0
+ route_for("#{prefix}/#{name}/#{id}.js", :method => :delete).should have_route({:action => "destroy", :controller => "#{name}", :id => id, :format => "js"}.merge(params))
0
+ # --- I decided that all the routes here will have the following ---
0
+ if !opts.has_key?(:extra) || opts[:extra]
0
+ it "should provide #{name} with a 'one' collection route" do
0
+ route_for("#{prefix}/#{name}/one").should have_route({:action => "one", :controller => "#{name}", :format => nil }.merge(params))
0
+ route_for("#{prefix}/#{name}/one.js").should have_route({:action => "one", :controller => "#{name}", :format => "js"}.merge(params))
0
+ it "should provide #{name} with a 'two' member route" do
0
+ route_for("#{prefix}/#{name}/#{id}/two").should have_route({:action => "two", :controller => "#{name}", :id => id, :format => nil }.merge(params))
0
+ route_for("#{prefix}/#{name}/#{id}/two.js").should have_route({:action => "two", :controller => "#{name}", :id => id, :format => "js"}.merge(params))
0
+ it "should provide #{name} with a 'three' collection route that maps the 'awesome' method" do
0
+ route_for("#{prefix}/#{name}/three").should have_route({:action => "awesome", :controller => "#{name}", :format => nil }.merge(params))
0
+ route_for("#{prefix}/#{name}/three.js").should have_route({:action => "awesome", :controller => "#{name}", :format => "js"}.merge(params))
0
+ it "should provide #{name} with a 'four' member route that maps to the 'awesome' method" do
0
+ route_for("#{prefix}/#{name}/#{id}/four").should have_route({:action => "awesome", :controller => "#{name}", :id => id, :format => nil }.merge(params))
0
+ route_for("#{prefix}/#{name}/#{id}/four.js").should have_route({:action => "awesome", :controller => "#{name}", :id => id, :format => "js"}.merge(params))
0
+def it_should_be_a_resource_object_route(name, *args)
0
+ controller = "#{name}s"
0
+ params = extract_options_from_args!(args) || {}
0
+ prefix = args.first.is_a?(String) ? args.shift : ""
0
+ opts = args.first.is_a?(Hash) ? args.shift : {}
0
+ it "should provide #{name} with a 'show' route" do
0
+ route_for("#{prefix}/#{name}").should have_route({:action => "show", :controller => controller, :format => nil }.merge(params))
0
+ route_for("#{prefix}/#{name}.js").should have_route({:action => "show", :controller => controller, :format => "js"}.merge(params))
0
+ it "should provide #{name} with an 'edit' route" do
0
+ route_for("#{prefix}/#{name}/edit").should have_route({:action => "edit", :controller => controller, :format => nil }.merge(params))
0
+ route_for("#{prefix}/#{name}/edit.js").should have_route({:action => "edit", :controller => controller, :format => "js"}.merge(params))
0
+ it "should provide #{name} with an 'update' route" do
0
+ route_for("#{prefix}/#{name}", :method => :put).should have_route({:action => "update", :controller => controller, :format => nil }.merge(params))
0
+ route_for("#{prefix}/#{name}.js", :method => :put).should have_route({:action => "update", :controller => controller, :format => "js"}.merge(params))
0
+ it "should provide #{name} with a 'delete' route" do
0
+ route_for("#{prefix}/#{name}/delete").should have_route({:action => "delete", :controller => controller, :format => nil }.merge(params))
0
+ route_for("#{prefix}/#{name}/delete.js").should have_route({:action => "delete", :controller => controller, :format => "js"}.merge(params))
0
+ it "should provide #{name} with a 'destroy' route" do
0
+ route_for("#{prefix}/#{name}", :method => :delete).should have_route({:action => "destroy", :controller => controller, :format => nil}.merge(params))
0
+ route_for("#{prefix}/#{name}.js", :method => :delete).should have_route({:action => "destroy", :controller => controller, :format => "js"}.merge(params))
0
+ it "should provide #{name} with a 'one' member route" do
0
+ route_for("#{prefix}/#{name}/one").should have_route({:action => "one", :controller => controller, :format => nil}.merge(params))
0
+ route_for("#{prefix}/#{name}/one.js").should have_route({:action => "one", :controller => controller, :format => "js"}.merge(params))
0
+ it "should provide #{name} with a 'two' member route that maps to the 'awesome' method" do
0
+ route_for("#{prefix}/#{name}/two").should have_route({:action => "awesome", :controller => controller, :format => nil }.merge(params))
0
+ route_for("#{prefix}/#{name}/two.js").should have_route({:action => "awesome", :controller => controller, :format => "js"}.merge(params))
0
Spec::Runner.configure do |config|
0
config.include(Spec::Helpers)
0
config.include(Spec::Matchers)