Skip to content

Commit

Permalink
make all tests pass with erbse 0.1.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Oct 7, 2016
1 parent ea50b9f commit af43b88
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 39 deletions.
6 changes: 3 additions & 3 deletions Gemfile
Expand Up @@ -5,6 +5,6 @@ gemspec

gem "railties", "~> 4.2.0"
gem "activemodel"
gem "minitest", "~> 5.2"
gem "tilt", "~> 2.0"
gem "cells", path: "../cells"
# gem "cells", path: "../cells"
gem "erbse", path: "../erbse"
gem "minitest-line"
2 changes: 1 addition & 1 deletion cells-erb.gemspec
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib']

spec.add_dependency "cells", "~> 4.0"
spec.add_dependency "erbse", ">= 0.1.0"
spec.add_dependency "erbse", ">= 0.1.1"

spec.add_development_dependency "bundler"
spec.add_development_dependency "rake"
Expand Down
4 changes: 3 additions & 1 deletion lib/cell/erb/template.rb
Expand Up @@ -37,7 +37,8 @@ def form_tag_html(html_options)
end

def concat(string)
@output_buffer << string
raise "[Cells-ERB] The #concat helper uses global state and is not supported anymore.
Please change your code to simple `+` String concatenation or tell the gem authors to remove #concat usage."
end


Expand All @@ -56,6 +57,7 @@ def prepare
end

def precompiled_template(locals)
# puts @template.call(data)
@template.call(data)
end
end
Expand Down
10 changes: 5 additions & 5 deletions test/dummy/app/cells/song/with_form_tag_and_content_tag.erb
Expand Up @@ -14,9 +14,9 @@ Word.
<% end %>
<%- answer = "<script>oui!</script>" %>
<% answer = "<script>oui!</script>" %>
<%- content = capture do %>
<%@ content = capture do %>
Bonjour!
<%= link_to "Coffee?", "/coffee" %>
<b>Yes please!</b>
Expand All @@ -27,8 +27,8 @@ Weiter!

<%= content %>
<%- breadcrumbs = capture do %>
<%- [link_to("1", "/1"), link_to("2", "/2")].join("+") %>
<%@ breadcrumbs = capture do %>
<%= [link_to("1", "/1"), link_to("2", "/2")].join("+") %>
<% end %>
<%= breadcrumbs %>
Expand All @@ -40,4 +40,4 @@ Weiter!
<%= f.text_field :id %>
<% end %>
<%= concatting %>
<%= concatting %>
6 changes: 4 additions & 2 deletions test/dummy/app/cells/song_cell.rb
Expand Up @@ -57,8 +57,10 @@ def current_page

def concatting
content_tag :div do
concat content_tag :p, "Concat!"
concat "Whoo"
# concat content_tag :p, "Concat!"
# concat "Whoo"
content_tag(:p, "Concat!") +
"Whoo"
end
end
end
33 changes: 6 additions & 27 deletions test/erb_test.rb
Expand Up @@ -39,44 +39,23 @@ class ErbTest < MiniTest::Spec
form_with_body_tag = "<form url=\"/rails/escapes/too/much\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"button\"/></form>"
form_with_body_tag = "<form method=\"post\" url=\"/rails/escapes/too/much\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /></div><input type=\"button\"/></form>" if ActionPack::VERSION::MAJOR == 3

form_for_tag = "<form class=\"new_open\" id=\"new_open\" action=\"/\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" />
<input type=\"text\" name=\"open[id]\" id=\"open_id\" />
</form>"
form_for_tag = "<form class=\"new_open\" id=\"new_open\" action=\"/\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"text\" name=\"open[id]\" id=\"open_id\" /></form>"
form_for_tag = "<form accept-charset=\"UTF-8\" action=\"/\" class=\"new_open\" id=\"new_open\" method=\"post\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /></div>
<input id=\"open_id\" name=\"open[id]\" size=\"30\" type=\"text\" />
</form>" if ActionPack::VERSION::MAJOR == 3

song_cell.(:with_form_tag_and_content_tag).must_equal %{Word.
#{form_tag}
<a href=\"/rails/sucks\">
hallo
#{form_tag}<a href=\"/rails/sucks\"> hallo
<div class="row">
Cool
</div>
</a>
<ul data-x="{&quot;a&quot;:&quot;1&quot;}">
Hallo
</ul>
</form>
Weiter!
</a><ul data-x="{&quot;a&quot;:&quot;1&quot;}"> Hallo
</ul></form>Weiter!
Bonjour!
<a href=\"/coffee\">Coffee?</a>
<b>Yes please!</b>
<script>oui!</script>
<a href=\"/1\">1</a>+<a href=\"/2\">2</a>
<b>No current page!<b>
#{form_with_body_tag}
#{form_for_tag}
<div><p>Concat!</p>Whoo</div>}
<a href=\"/coffee\">Coffee?</a> <b>Yes please!</b>
<script>oui!</script><a href=\"/1\">1</a>+<a href=\"/2\">2</a><b>No current page!<b>#{form_with_body_tag}#{form_for_tag}<div><p>Concat!</p>Whoo</div>}
end

it do
Expand Down

0 comments on commit af43b88

Please sign in to comment.