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} ▾ 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)) %> ▾</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