Permalink
Browse files

Revert "Revert "Converted RailsHelpers to follow the ! for output con…

…catination idiom.""

This reverts commit ad84f02.
  • Loading branch information...
1 parent ad84f02 commit f31686e0e3f14bde9ae9b50089871fb40b5f29f6 Brian Takita committed Mar 12, 2010
@@ -12,8 +12,12 @@ def url_for(*args)
# Erector needs to manually output their result.
def self.def_simple_rails_helper(method_name)
module_eval(<<-METHOD_DEF, __FILE__, __LINE__)
+ def #{method_name}!(*args, &block)
+ text! #{method_name}(*args, &block)
+ end
+
def #{method_name}(*args, &block)
- text helpers.#{method_name}(*args, &block)
+ helpers.#{method_name}(*args, &block)
end
METHOD_DEF
end
@@ -112,7 +116,7 @@ def render(*args, &block)
helpers.concat(helpers.render(*args, &block))
helpers.output_buffer.to_s
end
- rawtext(captured)
+ text!(captured)
end
def form_for(record_or_name_or_array, *args, &proc)
@@ -84,31 +84,31 @@ def @controller.default_url_options(options = nil)
describe "#auto_discovery_link_tag" do
it "renders tag" do
Erector.inline do
- auto_discovery_link_tag(:rss, "rails")
+ auto_discovery_link_tag!(:rss, "rails")
end.to_s(:helpers => @view).should == %{<link href="rails" rel="alternate" title="RSS" type="application/rss+xml" />}
end
end
describe "#javascript_include_tag" do
it "renders tag" do
Erector.inline do
- javascript_include_tag("rails")
+ javascript_include_tag!("rails")
end.to_s(:helpers => @view).should == %{<script src="/javascripts/rails.js" type="text/javascript"></script>}
end
end
describe "#stylesheet_link_tag" do
it "renders tag" do
Erector.inline do
- stylesheet_link_tag("rails")
+ stylesheet_link_tag!("rails")
end.to_s(:helpers => @view).should == %{<link href="/stylesheets/rails.css" media="screen" rel="stylesheet" type="text/css" />}
end
end
describe "#image_tag" do
it "renders tag" do
Erector.inline do
- image_tag("/foo")
+ image_tag!("/foo")
end.to_s(:helpers => @view).should == %{<img alt="Foo" src="/foo" />}
end
end
@@ -134,7 +134,7 @@ def @controller.default_url_options(options = nil)
:drop_receiving_element].each do |helper|
describe "##{helper}" do
it "renders helper js" do
- @controller.render :widget => Erector.inline { send(helper, "rails", :url => "/foo") }
+ @controller.render :widget => Erector.inline { text! send(helper, "rails", :url => "/foo") }
@response.body.should =~ %r{<script type="text/javascript">.*</script>}m
end
end
@@ -145,7 +145,7 @@ def @controller.default_url_options(options = nil)
it "renders a link with the name as the content and the onclick handler" do
widget_class = Class.new(Erector::Widget) do
def content
- link_to_function("hi", "alert('hi')")
+ link_to_function!("hi", "alert('hi')")
end
end
@controller.render :widget => widget_class
@@ -157,7 +157,7 @@ def content
it "renders the name and the block rjs contents onto onclick" do
widget_class = Class.new(Erector::Widget) do
def content
- link_to_function("Show me more", nil, :id => "more_link") do |page|
+ link_to_function!("Show me more", nil, :id => "more_link") do |page|
page[:details].visual_effect :toggle_blind
page[:more_link].replace_html "Show me less"
end
@@ -181,7 +181,7 @@ def content
it "renders the error message" do
widget_class = Class.new(Erector::Widget) do
def content
- error_messages_for('user')
+ error_messages_for!('user')
end
end
@@ -210,7 +210,7 @@ def content
it "can be mixed with erector and rails helpers" do
Erector.inline do
form_tag("/posts") do
- div { submit_tag 'Save' }
+ div { submit_tag! 'Save' }
end
end.to_s(:helpers => @view).should == %{<form action="/posts" method="post"><div><input name="commit" type="submit" value="Save" /></div></form>}
end
@@ -6,7 +6,7 @@
view.output_buffer = ""
view.instance_eval do
Erector.inline do
- image_tag "test.gif"
+ image_tag! "test.gif"
end.to_s.should == '<img alt="Test" src="/images/test.gif" />'
end
end

0 comments on commit f31686e

Please sign in to comment.