Sha256: 906b0771705aa207fc47071e96d482b46215cfd40c8bd8fa85d13226c12571c8

Contents?: true

Size: 1.58 KB

Versions: 46

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

module Synvert::Core
  describe Engine::Erb do
    it 'encodes / decodes' do
      source = <<~EOF
        <% content_for :head do %>
          <style>
            body {
              background-image: url(<%= asset_path('bg.png') %>);
            }
          </style>
        <% end %>

        <%
          foo = 'bar'
          post = Post.find(:first)
          bar = 'foo'
        %>

        <%= user.first_name %> <%= user.last_name %>

        <% if User.current &&
              User.current.admin %>
          <%= rounded_content("page") do %>
          <div class='test'>
            <% if post %>
              <div id="title"><%= foo %></div>
              <% form_for post do |f| %>
                <label><%= link_to_function 'test', "confirm('test');" %></label>
                <%= f.text_field 'bar' %>
              <% end %>
            <% end %></div>
          <% end %>
        <% end %>
      EOF
      encoded_source = Engine::Erb.encode(source)
      expect(encoded_source).to be_include 'content_for :head do'
      expect(encoded_source).to be_include " asset_path('bg.png')"
      expect(encoded_source).to be_include 'post = Post.find(:first)'
      expect(encoded_source).to be_include "link_to_function 'test', \"confirm('test');\""
      expect(encoded_source).to be_include 'end'
      expect(encoded_source).to be_include 'user.first_name ;'
      expect(encoded_source).to be_include 'user.last_name ;'
      expect(encoded_source).not_to be_include 'style'
      expect(encoded_source).not_to be_include 'div'
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
synvert-core-2.2.2 spec/synvert/core/engine/erb_spec.rb
synvert-core-2.2.1 spec/synvert/core/engine/erb_spec.rb
synvert-core-2.2.0 spec/synvert/core/engine/erb_spec.rb
synvert-core-2.1.2 spec/synvert/core/engine/erb_spec.rb
synvert-core-2.1.1 spec/synvert/core/engine/erb_spec.rb
synvert-core-2.1.0 spec/synvert/core/engine/erb_spec.rb
synvert-core-2.0.3 spec/synvert/core/engine/erb_spec.rb
synvert-core-2.0.2 spec/synvert/core/engine/erb_spec.rb
synvert-core-2.0.1 spec/synvert/core/engine/erb_spec.rb
synvert-core-2.0.0 spec/synvert/core/engine/erb_spec.rb
synvert-core-1.35.4 spec/synvert/core/engine/erb_spec.rb
synvert-core-1.35.3 spec/synvert/core/engine/erb_spec.rb
synvert-core-1.35.2 spec/synvert/core/engine/erb_spec.rb
synvert-core-1.35.1 spec/synvert/core/engine/erb_spec.rb
synvert-core-1.35.0 spec/synvert/core/engine/erb_spec.rb
synvert-core-1.34.0 spec/synvert/core/engine/erb_spec.rb
synvert-core-1.33.3 spec/synvert/core/engine/erb_spec.rb
synvert-core-1.33.2 spec/synvert/core/engine/erb_spec.rb
synvert-core-1.33.1 spec/synvert/core/engine/erb_spec.rb
synvert-core-1.33.0 spec/synvert/core/engine/erb_spec.rb