spec/unit/router_spec.rb in restfulness-0.2.5 vs spec/unit/router_spec.rb in restfulness-0.2.6
- old
+ new
@@ -4,10 +4,13 @@
describe Restfulness::Router do
class RouterResource < Restfulness::Resource
end
+ class SecondRouterResource < Restfulness::Resource
+ end
+
let :klass do
Restfulness::Router
end
let :resource do
@@ -36,9 +39,21 @@
obj.add 'projects', resource
obj.routes.length.should eql(1)
route = obj.routes.first
route.should be_a(Restfulness::Route)
route.path.should eql(['projects'])
+ end
+ it "should accept block as scope" do
+ obj = klass.new
+ obj.add 'project', RouterResource do
+ add 'examples', SecondRouterResource
+ end
+ route = obj.routes.first
+ route.resource.should eql(RouterResource)
+ route.path.should eql(['project', 'examples'])
+ route = obj.routes.last
+ route.resource.should eql(SecondRouterResource)
+ route.path.should eql(['project'])
end
end
describe "#scope" do
it "should append to the current_scope attribute in block and reset" do