summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2014-02-28 21:30:38 -0700
committerDan Allen <dan.j.allen@gmail.com>2014-02-28 21:31:32 -0700
commit526ade87cc533e5153dc4aea62435075c8d27bee (patch)
tree89e6498df09f9b08551d3d35b58f93a1765431f6 /test
parent04b7eb416cd17b61d58e7199577bc89de36ab630 (diff)
fix behavior of AbstractNode#set_attr, add test
Diffstat (limited to 'test')
-rw-r--r--test/attributes_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/attributes_test.rb b/test/attributes_test.rb
index ad3000ed..95743365 100644
--- a/test/attributes_test.rb
+++ b/test/attributes_test.rb
@@ -250,6 +250,19 @@ content
assert doc.attributes.has_key? 'basebackend-html'
end
+ test 'set_attr should not overwrite existing key if overwrite is false' do
+ node = Asciidoctor::Block.new nil, :paragraph, :attributes => { 'foo' => 'bar' }
+ assert_equal 'bar', (node.attr 'foo')
+ node.set_attr 'foo', 'baz', false
+ assert_equal 'bar', (node.attr 'foo')
+ end
+
+ test 'set_attr should overwrite existing key by default' do
+ node = Asciidoctor::Block.new nil, :paragraph, :attributes => { 'foo' => 'bar' }
+ assert_equal 'bar', (node.attr 'foo')
+ node.set_attr 'foo', 'baz'
+ assert_equal 'baz', (node.attr 'foo')
+ end
end
context 'Interpolation' do