test/parser_test.rb in radius-0.6.1 vs test/parser_test.rb in radius-0.7.0.prerelease

- old
+ new

@@ -1,6 +1,6 @@ -require File.join(File.dirname(__FILE__), 'test_helper') +require File.expand_path(File.dirname(__FILE__) + '/test_helper') class RadiusParserTest < Test::Unit::TestCase include RadiusTestHelper def setup @@ -236,20 +236,37 @@ def test_parse_fail_on_wrong_end_tag assert_raises(Radius::WrongEndTagError) { @parser.parse("<r:reverse><r:capitalize></r:reverse>") } end def test_parse_with_default_tag_prefix - define_tag("hello") { |tag| "Hello world!" } @parser = Radius::Parser.new(@context) + define_tag("hello") { |tag| "Hello world!" } assert_equal "<p>Hello world!</p>", @parser.parse('<p><radius:hello /></p>') end def test_parse_with_other_radius_like_tags - define_tag('hello') { "hello" } @parser = Radius::Parser.new(@context, :tag_prefix => "ralph") + define_tag('hello') { "hello" } assert_equal "<r:ralph:hello />", @parser.parse("<r:ralph:hello />") end + + def test_copyin_global_values + @context.globals.foo = 'bar' + assert_equal 'bar', Radius::Parser.new(@context).context.globals.foo + end + + def test_does_not_pollute_copied_globals + @context.globals.foo = 'bar' + parser = Radius::Parser.new(@context) + parser.context.globals.foo = '[baz]' + assert_equal 'bar', @context.globals.foo + end + + def test_parse_with_other_namespaces + @parser = Radius::Parser.new(@context, :tag_prefix => 'r') + assert_equal "<fb:test>hello world</fb:test>", @parser.parse("<fb:test>hello world</fb:test>") + end protected def assert_parse_output(output, input, message = nil) r = @parser.parse(input) @@ -285,6 +302,6 @@ def user_with_attributes UserWithAttributes.new('John', 25, 'test@johnwlong.com') end -end \ No newline at end of file +end