Sha256: 4c6ee163580ac3d0f01915b051ca9d16ca4060cdd53602aedfedb983703a582e
Contents?: true
Size: 1.78 KB
Versions: 2
Compression:
Stored size: 1.78 KB
Contents
require File.expand_path("../lib/mote", File.dirname(__FILE__)) scope do test "assignment" do example = Mote.parse("${ \"***\" }") assert_equal "***", example.call end test "comment" do template = (<<-EOT).gsub(/ {4}/, "") * % # "*" * EOT example = Mote.parse(template) assert_equal "*\n*\n", example.call.squeeze("\n") end test "control flow" do template = (<<-EOT).gsub(/ {4}/, "") % if false * % else *** % end EOT example = Mote.parse(template) assert_equal "\n ***\n\n", example.call end test "block evaluation" do template = (<<-EOT).gsub(/ {4}/, "") % 3.times { * % } EOT example = Mote.parse(template) assert_equal "\n*\n\n*\n\n*\n\n", example.call end test "parameters" do template = (<<-EOT).gsub(/ {4}/, "") % params[:n].times { * % } EOT example = Mote.parse(template) assert_equal "\n*\n\n*\n\n*\n\n", example[:n => 3] assert_equal "\n*\n\n*\n\n*\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] end test "quotes" do example = Mote.parse("'foo' 'bar' 'baz'") assert_equal "'foo' 'bar' 'baz'", example.call end test "context" do context = Object.new context.instance_variable_set(:@user, "Bruno") example = Mote.parse("${ @user }", context) assert_equal "Bruno", example.call end test "locals" do context = Object.new example = Mote.parse("${ user }", context, [:user]) assert_equal "Bruno", example.call(user: "Bruno") end end include Mote::Helpers scope do test "helpers" do assert_equal "\n *\n\n *\n\n *\n\n", mote("test/basic.erb", :n => 3) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mote-0.1.0 | test/mote_test.rb |
mote-0.1.0.rc1 | test/mote_test.rb |