test/mote_test.rb in mote-1.1.3 vs test/mote_test.rb in mote-1.1.4

- old
+ new

@@ -20,11 +20,11 @@ example = Mote.parse("\n% if true\n\n\n% else\n\n% end") assert_equal "\n\n\n", example.call end test "assignment" do - example = Mote.parse("{{ \"***\" }}") + example = Mote.parse("{{ '***' }}") assert_equal "***", example.call end test "comment" do template = (<<-EOT).gsub(/ {4}/, "") @@ -73,11 +73,11 @@ assert_equal "*\n*\n*\n*\n", example[:n => 4] end test "multiline" do example = Mote.parse("The\nMan\nAnd\n{{\"The\"}}\nSea") - assert_equal "The\nMan\nAnd\nThe\nSea", example[:n => 3] + assert_equal "The\nMan\nAnd\nThe\nSea", example.call end test "quotes" do example = Mote.parse("'foo' 'bar' 'baz'") assert_equal "'foo' 'bar' 'baz'", example.call @@ -85,12 +85,12 @@ test "context" do context = Object.new def context.user; "Bruno"; end - example = Mote.parse("{{ context.user }}", context, [:context]) - assert_equal "Bruno", example.call(context: context) + example = Mote.parse("{{ user }}", context) + assert_equal "Bruno", example.call end test "locals" do example = Mote.parse("{{ user }}", TOPLEVEL_BINDING, [:user]) assert_equal "Bruno", example.call(user: "Bruno") @@ -99,26 +99,22 @@ test "nil" do example = Mote.parse("{{ user }}", TOPLEVEL_BINDING, [:user]) assert_equal "", example.call(user: nil) end - test "curly bug" do - example = Mote.parse("{{ [1, 2, 3].map { |i| i * i }.join(',') }}") - assert_equal "1,4,9", example.call - end - test "multi-line XML-style directives" do template = (<<-EOT).gsub(/^ /, "") - <? res = "" - [1, 2, 3].each_with_index do |item, idx| - res << "%d. %d\n" % [idx + 1, item * item] - end + <? + # Multiline code evaluation + lucky = [1, 3, 7, 9, 13, 15] + prime = [2, 3, 5, 7, 11, 13] ?> - {{ res }} + + {{ lucky & prime }} EOT example = Mote.parse(template) - assert_equal "\n1. 1\n2. 4\n3. 9\n\n", example.call + assert_equal "\n\n[3, 7, 13]\n", example.call end test "preserve XML directives" do template = (<<-EOT).gsub(/^ /, "") <?xml "hello" ?>