Sha256: 4b62af1e7ca109a7c4b7ee19953f3ca781e63323c30af01ba9d1d47ff4e58ad9
Contents?: true
Size: 1.08 KB
Versions: 11
Compression:
Stored size: 1.08 KB
Contents
require 'test_helper' class BaseTest < ActiveSupport::TestCase class NoLogic < ExpressTemplates::Components::Base has_markup -> { h1 { span "Some stuff" } } end test ".has_markup makes compile return the block passed through express compiled" do assert_equal %Q("<h1><span>Some stuff</span></h1>"), NoLogic.new.compile end test "components register themselves as macros" do assert ExpressTemplates::Expander.instance_methods.include?(:no_logic) end class Context def initialize ; @foo = ['bar', 'baz'] ; end end test "fragments and has_markup are synonyms for emits" do assert_equal NoLogic.method(:emits), NoLogic.method(:fragments) assert_equal NoLogic.method(:emits), NoLogic.method(:has_markup) end class Helpers < ECB helper :title_helper, &-> { @foo.first } emits -> { h1 { title_helper } } end test "helpers defined in component are evaluated in context" do compiled = Helpers.new.compile assert_equal "<h1>bar</h1>", Context.new.instance_eval(Interpolator.transform(compiled)) end end
Version data entries
11 entries across 11 versions & 2 rubygems