Commit 5c115a98eb330adfce8c55c0fdff851ac2af6bb0
1 parent
b096aa74
Exists in
master
and in
29 other branches
macros: add macro tests
Showing
1 changed file
with
37 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,37 @@ |
1 | +require File.dirname(__FILE__) + '/../test_helper' | |
2 | + | |
3 | +class MacroTest < ActiveSupport::TestCase | |
4 | + | |
5 | + class Plugin1 < Noosfero::Plugin | |
6 | + end | |
7 | + | |
8 | + class Plugin1::Macro < Noosfero::Plugin::Macro | |
9 | + def parse(params, inner_html, source) | |
10 | + "Testing: #{inner_html}" | |
11 | + end | |
12 | + end | |
13 | + | |
14 | + MACRO = "<div class='macro nonEdit' data-macro='#{Plugin1::Macro.identifier}' data-macro-attr1='1' data-macro-attr2='2' data-macro-attr3='3'>It works!</div>" | |
15 | + | |
16 | + def setup | |
17 | + @macro = Plugin1::Macro.new | |
18 | + @macro_element = Hpricot(MACRO).search('.macro').first | |
19 | + end | |
20 | + | |
21 | + attr_reader :macro, :macro_element | |
22 | + | |
23 | + should 'access plugin' do | |
24 | + assert_equal Plugin1, Plugin1::Macro.plugin | |
25 | + end | |
26 | + | |
27 | + should 'parse attributes' do | |
28 | + attributes = macro.attributes(macro_element) | |
29 | + assert_equal '1', attributes['attr1'] | |
30 | + assert_equal '2', attributes['attr2'] | |
31 | + assert_equal '3', attributes['attr3'] | |
32 | + end | |
33 | + | |
34 | + should 'convert macro' do | |
35 | + assert_equal 'Testing: It works!', macro.convert(macro_element, nil) | |
36 | + end | |
37 | +end | ... | ... |