Sha256: c435a814a5e0fa5312f3d0ead9c69ec59e5529b21bef7e1ece6fd2137023a927

Contents?: true

Size: 1.65 KB

Versions: 6

Compression:

Stored size: 1.65 KB

Contents

describe Musterb::Musterbifier do
  it "does not change vanilla strings" do
    Musterb::Musterbifier.new("Hello, world!").to_erb.should eq "Hello, world!"
  end

  it "replaces mustaches correctly" do
    Musterb::Musterbifier.new("Hello, {{world}}!").to_erb.should eq "Hello, <%== musterb['world'] %>!"
  end

  it "replaces triple staches correctly" do
    Musterb::Musterbifier.new("Hello, {{{world}}}!").to_erb.should eq "Hello, <%= musterb['world'] %>!"
  end

  it "does not escape if it starts with &" do
    Musterb::Musterbifier.new("Hello, {{& world}}!").to_erb.should eq "Hello, <%= musterb['world'] %>!"
  end

  it "replaces blocks correctly" do
    Musterb::Musterbifier.new("{{#cond}}foo{{/cond}}").to_erb.should eq "<% musterb.block_if musterb['cond'] do %>foo<% end %>"
  end

  it "can do #." do
    Musterb::Musterbifier.new("{{#.}}foo{{/.}}").to_erb.should eq "<% musterb.block_if musterb.current do %>foo<% end %>"
  end

  it "replaces carrot correctly" do
    Musterb::Musterbifier.new("{{^cond}}foo{{/cond}}").to_erb.should eq "<% musterb.block_unless musterb['cond'] do %>foo<% end %>"
  end

  it "replaces comments with nothing" do
    Musterb::Musterbifier.new("{{! foo\n bar}}").to_erb.should eq ""
  end

  it "replaces . with current value" do
    Musterb::Musterbifier.new("{{.}}").to_erb.should eq "<%== musterb.current %>"
  end

  it "replaces foo.bar with a chain" do
    Musterb::Musterbifier.new("{{foo.bar}}").to_erb.should eq "<%== musterb.chain('foo')['bar'] %>"
  end

  it "replaces calls for partials with an exception by default" do
    lambda { Musterb::Musterbifier.new("{{> foo}}").to_erb }.should raise_error NotImplementedError
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
musterb-1.0.1 spec/musterb/musterbifier_spec.rb
musterb-1.0.0 spec/musterb/musterbifier_spec.rb
musterb-0.2.0 spec/musterb/musterbifier_spec.rb
musterb-0.1.2 spec/musterb/musterbifier_spec.rb
musterb-0.1.1 spec/musterb/musterbifier_spec.rb
musterb-0.1.0 spec/musterb/musterbifier_spec.rb