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