Permalink
Browse files

fix error handling in namespace

  • Loading branch information...
1 parent 113e02f commit d116e689da607667c3093801d52bff26bc583c4a @rkh committed Mar 10, 2013
Showing with 6 additions and 2 deletions.
  1. +5 −2 lib/sinatra/namespace.rb
  2. +1 −0 spec/spec_helper.rb
@@ -177,7 +177,7 @@ def not_found(&block)
end
def errors
- base.errors.merge(@errors)
+ base.errors.merge(namespace_errors)
end
def namespace_errors
@@ -188,7 +188,10 @@ def error(*codes, &block)
args = Sinatra::Base.send(:compile!, "ERROR", /^#{@pattern}/, block)
codes = codes.map { |c| Array(c) }.flatten
codes << Exception if codes.empty?
- codes.each { |c| @errors[c] = args }
+ codes.each do |c|
+ errors = @errors[c] ||= []
+ errors << args
+ end
end
def respond_to(*args)
View
@@ -1,3 +1,4 @@
+ENV['RACK_ENV'] = 'test'
require 'sinatra/contrib'
RSpec.configure do |config|

0 comments on commit d116e68

Please sign in to comment.