Sha256: aef79126b166d8a84106dcc4f6211585d4f24db3c9b621a26683670afdcd9e19
Contents?: true
Size: 976 Bytes
Versions: 1
Compression:
Stored size: 976 Bytes
Contents
require 'erubis' describe Musterb do it "correctly replaces variables" do planet = "World" erb = Musterb.to_erb("Hello, {{planet}}!") Erubis::Eruby.new(erb).result(binding).should eq "Hello, World!" end it "correctly evaluates if a variable is set" do hash = {:set_var => "set"} Musterb.render("{{#set_var}}foo{{/set_var}}", hash).should eq "foo" Musterb.render("{{#unset_var}}foo{{/unset_var}}", hash).should eq "" end it "skips blocks for truthy values" do hash = {:set_var => "set"} Musterb.render("{{^set_var}}foo{{/set_var}}", hash).should eq "" Musterb.render("{{^unset_var}}foo{{/unset_var}}", hash).should eq "foo" end it "can pull out deeply nested values" do hash = {:foo => {:bar => {:baz => 42}}} Musterb.render("{{foo.bar.baz}}", hash).should eq "42" end it "can iterate over values" do hash = {:foos => [1, 2, 3]} Musterb.render("{{#foos}}{{.}}{{/foos}}", hash).should eq "123" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
musterb-0.0.5 | spec/musterb_spec.rb |