Permalink
Browse files

Fix Rails integration with Form#button

  • Loading branch information...
1 parent ae150af commit 26322648e0aaac3c9a6b3f5822d1e75d3c359a60 @jeremyevans committed May 2, 2012
Showing with 9 additions and 2 deletions.
  1. +5 −0 lib/forme/rails.rb
  2. +2 −1 spec/rails_integration_spec.rb
  3. +2 −1 spec/sinatra_integration_spec.rb
View
@@ -45,6 +45,11 @@ def input(*)
template.raw(super.to_s)
end
+ # Return a string version of the button that is already marked as safe.
+ def button(*)
+ template.raw(super.to_s)
+ end
+
# If a block is given, create a new output buffer and make sure all the
# output of the tag goes into that buffer, and return the buffer.
# Otherwise, just return a string version of the tag that is already
@@ -22,6 +22,7 @@ def index
<p>FBB</p>
<%= f.input(:first) %>
<%= f.input(:last) %>
+ <%= f.button('Save') %>
<% end %>
END
end
@@ -153,7 +154,7 @@ def o.puts(*) end
end
specify "#form should add start and end tags and yield Forme::Form instance" do
- sin_get('/index').should == '<form action="/baz"> <p>FBB</p> <input id="first" name="first" type="text" value="foo"/> <input id="last" name="last" type="text" value="bar"/> </form>'
+ sin_get('/index').should == '<form action="/baz"> <p>FBB</p> <input id="first" name="first" type="text" value="foo"/> <input id="last" name="last" type="text" value="bar"/> <input type="submit" value="Save"/> </form>'
end
specify "#form should have inputs work with a block" do
@@ -17,6 +17,7 @@ class FormeSinatraTest < Sinatra::Base
<p>FBB</p>
<%= f.input(:first) %>
<%= f.input(:last) %>
+ <%= f.button('Save') %>
<% end %>
END
end
@@ -146,7 +147,7 @@ def o.puts(*) end
end
specify "#form should add start and end tags and yield Forme::Form instance" do
- sin_get('/').should == '<form action="/baz"> <p>FBB</p> <input id="first" name="first" type="text" value="foo"/> <input id="last" name="last" type="text" value="bar"/> </form>'
+ sin_get('/').should == '<form action="/baz"> <p>FBB</p> <input id="first" name="first" type="text" value="foo"/> <input id="last" name="last" type="text" value="bar"/> <input type="submit" value="Save"/> </form>'
end
specify "#form should have inputs work with a block" do

0 comments on commit 2632264

Please sign in to comment.