Sha256: fedbc61cf590ca8de1398d56a4a2f90e4a67a517066ba5e01d4825181c4f3644

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 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
    example = Mote.parse("*<%# \"*\" %>*")
    assert_equal "**", example.call
  end

  test "control flow" do
    example = Mote.parse("<% if false %>*<% else %>***<% end %>")
    assert_equal "***", example.call
  end

  test "block evaluation" do
    example = Mote.parse("<% 3.times { %>*<% } %>")
    assert_equal "***", example.call
  end

  test "parameters" do
    example = Mote.parse("<% params[:n].times { %>*<% } %>")
    assert_equal "***", example[:n => 3]
    assert_equal "****", example[:n => 4]
  end

  test "multiline" do
    example = Mote.parse("The\nMan\nAnd\n<%=\n\"The\"\n%>\nSea")
    assert_equal "The\nMan\nAnd\nThe\nSea", example[:n => 3]
  end
end

include Mote::Helpers

scope do
  test do
    assert_equal "1 2 3", mote("1 <%= 2 %> 3")
  end

  test do
    assert_equal "1 2 3", mote("1 <%= params[:n] %> 3", :n => 2)
  end

  test do
    assert_equal "***\n", mote_file("test/basic.erb", :n => 3)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mote-0.0.1 test/mote_test.rb
mote-0.0.1.rc3 test/mote_test.rb