Sha256: b7818bb3e2cf1e1473d093d364b57a8946bcfed18946df298d33200657f7f3cf

Contents?: true

Size: 1.74 KB

Versions: 17

Compression:

Stored size: 1.74 KB

Contents

require 'spec_helper'

module Deface
  describe SlimConverter do
    include_context "mock Rails.application"

    def slim_to_erb(src)
      conv = Deface::SlimConverter.new(src)
      conv.result.gsub("\n", "")
    end

    describe "convert slim to erb" do
      it "should hanlde simple tags" do
        expect(slim_to_erb('div class="some" id="message"= "Hi, World!"')).to eq("<div class=\"some\" id=\"message\"><%= ::Temple::Utils.escape_html_safe((\"Hi, World!\")) %></div>")
      end

      it "should handle complex tags" do
        expect(slim_to_erb(%q{nav#top-nav-bar
  ul#nav-bar.inline data-hook=''
    - if true
      .nav-links.high_res
        li.dropdown
          .welcome Welcome #{Spree::User.first.email} &#9662;
          ul.dropdown
            li = link_to 'Account', account_path
            li = link_to 'Log out', logout_path
})).to eq("<nav id=\"top-nav-bar\"><ul class=\"inline\" data-hook=\"\" id=\"nav-bar\"><% if true %><div class=\"nav-links high_res\"><li class=\"dropdown\"><div class=\"welcome\">Welcome <%= ::Temple::Utils.escape_html_safe((Spree::User.first.email)) %> &#9662;</div><ul class=\"dropdown\"><li><%= ::Temple::Utils.escape_html_safe((link_to 'Account', account_path)) %></li><li><%= ::Temple::Utils.escape_html_safe((link_to 'Log out', logout_path)) %></li></ul></li></div><% end %></ul></nav>")
      end

      it "should handle Rails capturing" do
        expect(slim_to_erb(%q{#wishlist-form
	= form_for Spree::WishedProduct.new do |f|
		= f.submit 'Save'
})).to eq("<div id=\"wishlist-form\"><% _slim_controls1 = form_for Spree::WishedProduct.new do |f| %><%= ::Temple::Utils.escape_html_safe((f.submit 'Save')) %><% end %><%= ::Temple::Utils.escape_html_safe((_slim_controls1)) %></div>")
      end
    end

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
deface-1.9.0 spec/deface/slim_converter_spec.rb
deface-1.8.2 spec/deface/slim_converter_spec.rb
deface-1.8.1 spec/deface/slim_converter_spec.rb
deface-1.8.0 spec/deface/slim_converter_spec.rb
deface-1.7.0 spec/deface/slim_converter_spec.rb
deface-1.6.2 spec/deface/slim_converter_spec.rb
deface-1.6.1 spec/deface/slim_converter_spec.rb
deface-1.6.0 spec/deface/slim_converter_spec.rb
deface-1.5.3 spec/deface/slim_converter_spec.rb
deface-1.5.2 spec/deface/slim_converter_spec.rb
deface-1.5.1 spec/deface/slim_converter_spec.rb
deface-1.5.0 spec/deface/slim_converter_spec.rb
deface-1.4.0 spec/deface/slim_converter_spec.rb
deface-1.3.2 spec/deface/slim_converter_spec.rb
deface-1.3.1 spec/deface/slim_converter_spec.rb
deface-1.3.0 spec/deface/slim_converter_spec.rb
deface-1.2.0 spec/deface/slim_converter_spec.rb