Permalink
Browse files

Don't error out on missing ApiTaster.routes, closes #16

  • Loading branch information...
1 parent 4d8c654 commit 1d8718e174449792848f07e956b64201f95477c5 @fredwu committed Jul 16, 2012
Showing with 15 additions and 1 deletion.
  1. +5 −1 lib/api_taster/route.rb
  2. +10 −0 spec/controllers/api_taster/routes_controller_spec.rb
View
6 lib/api_taster/route.rb
@@ -15,7 +15,11 @@ def map_routes
normalise_routes!
- Mapper.instance_eval(&self.mappings.call)
+ begin
+ Mapper.instance_eval(&self.mappings.call)
+ rescue
+ Route.mappings = {}
+ end
end
def normalise_routes!
View
10 spec/controllers/api_taster/routes_controller_spec.rb
@@ -2,6 +2,16 @@
module ApiTaster
describe RoutesController do
+ context "missing ApiTaster.routes" do
+ it "#index" do
+ Route.stub(:mappings).and_return(nil)
+ get :index, :use_route => :api_taster
+
+ response.should be_success
+ assigns(:routes).should be_kind_of(Hash)
+ end
+ end
+
it "#index" do
get :index, :use_route => :api_taster

0 comments on commit 1d8718e

Please sign in to comment.