Sha256: 56c8c9a1abd7451110ce9155ae5cea58119eff99c0251b9fc9c3f327f26a3bfc
Contents?: true
Size: 762 Bytes
Versions: 4
Compression:
Stored size: 762 Bytes
Contents
require 'erubis' describe Musterb do def evaluate(template, _binding) erb = Musterb.to_erb(template) Erubis::Eruby.new(erb).result(_binding) end it "correctly replaces variables" do planet = "World" evaluate("Hello, {{planet}}!", binding).should eq "Hello, World!" end it "correctly evaluates if a variable is set" do set_var = "set" unset_var = nil evaluate("{{#set_var}}foo{{/set_var}}", binding).should eq "foo" evaluate("{{#unset_var}}foo{{/unset_var}}", binding).should eq "" end it "skips blocks for truthy values" do set_var = "set" unset_var = nil evaluate("{{^set_var}}foo{{/set_var}}", binding).should eq "" evaluate("{{^unset_var}}foo{{/unset_var}}", binding).should eq "foo" end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
musterb-0.0.4 | spec/musterb_spec.rb |
musterb-0.0.3 | spec/musterb_spec.rb |
musterb-0.0.2 | spec/musterb_spec.rb |
musterb-0.0.1 | spec/musterb_spec.rb |