Assert that plist engine respond to #dump

This commit is contained in:
ccocchi 2012-11-14 12:10:54 +01:00
parent 2939638c0d
commit aa659d0b8b
3 changed files with 13 additions and 4 deletions

View File

@ -33,7 +33,7 @@ module RablRails
mattr_accessor :responder_default_template
@@responder_default_template = 'show'
mattr_accessor :plist_engine
mattr_reader :plist_engine
@@plist_engine = nil
mattr_accessor :include_plist_root
@ -65,6 +65,11 @@ module RablRails
ActiveSupport::XmlMini.backend
end
def self.plist_engine=(name)
raise "Your plist engine does not respond to #dump" unless name.respond_to?(:dump)
@@plist_engine = name
end
def self.cache_templates?
ActionController::Base.perform_caching && @@cache_templates
end

View File

@ -1,4 +1,7 @@
require 'test_helper'
require 'plist'
RablRails.plist_engine = Plist::Emit
class TestPlistRenderer < ActiveSupport::TestCase
INDENT_REGEXP = /\n(\s)*/
@ -20,6 +23,10 @@ class TestPlistRenderer < ActiveSupport::TestCase
output.sub!(HEADER_REGEXP, '').gsub!(%r(</?plist[^>]*>), '').sub!(%r(<dict/?>), '').sub(%r(</dict>), '')
end
test "plist engine should responsd to #dump" do
assert_raises(RuntimeError) { RablRails.plist_engine = Object.new }
end
test "render object wth empty template" do
@template.source = {}
assert_equal %q(), render_plist_output

View File

@ -22,9 +22,6 @@ class <<Singleton
end
require 'rabl-rails'
require 'plist'
RablRails.plist_engine = Plist::Emit
module ActiveSupport
class TestCase