From 5c115a98eb330adfce8c55c0fdff851ac2af6bb0 Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Thu, 13 Feb 2014 20:51:04 -0300 Subject: [PATCH] macros: add macro tests --- test/unit/macro_test.rb | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+), 0 deletions(-) create mode 100644 test/unit/macro_test.rb diff --git a/test/unit/macro_test.rb b/test/unit/macro_test.rb new file mode 100644 index 0000000..19473b0 --- /dev/null +++ b/test/unit/macro_test.rb @@ -0,0 +1,37 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class MacroTest < ActiveSupport::TestCase + + class Plugin1 < Noosfero::Plugin + end + + class Plugin1::Macro < Noosfero::Plugin::Macro + def parse(params, inner_html, source) + "Testing: #{inner_html}" + end + end + + MACRO = "
It works!
" + + def setup + @macro = Plugin1::Macro.new + @macro_element = Hpricot(MACRO).search('.macro').first + end + + attr_reader :macro, :macro_element + + should 'access plugin' do + assert_equal Plugin1, Plugin1::Macro.plugin + end + + should 'parse attributes' do + attributes = macro.attributes(macro_element) + assert_equal '1', attributes['attr1'] + assert_equal '2', attributes['attr2'] + assert_equal '3', attributes['attr3'] + end + + should 'convert macro' do + assert_equal 'Testing: It works!', macro.convert(macro_element, nil) + end +end -- libgit2 0.21.2