Use explicit error

This commit is contained in:
ccocchi 2012-04-15 23:32:26 +02:00
parent 4e6142602f
commit e1e5ec6f23
2 changed files with 4 additions and 2 deletions

View File

@ -1,5 +1,7 @@
module RablFastJson
module Renderers
class PartialError < StandardError; end
class Base
def initialize(context) # :nodoc:
@ -79,7 +81,7 @@ module RablFastJson
# rendering time.
#
def partial(template_path, options = {})
raise "No object was given to partial" unless options[:object]
raise PartialError.new("No object was given to partial") unless options[:object]
object = options[:object]
return [] if object.respond_to?(:empty?) && object.empty?

View File

@ -98,7 +98,7 @@ class TestJsonRenderer < ActiveSupport::TestCase
@template.data = false
@template.source = { :user => ->(s) { partial('users/base') } }
assert_raises(RuntimeError) { render_json_output }
assert_raises(RablFastJson::Renderers::PartialError) { render_json_output }
end
test "partial with empty values should not raise an error" do