Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding a test for rendering a simple_form with cells outside of rails.

  • Loading branch information...
commit 8e9c4bc2f0c8700e06e5509e9e38d1e6e43b8349 1 parent bdf33cd
@apotonick authored
View
1  cells.gemspec
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
s.add_development_dependency "shoulda"
s.add_development_dependency "haml"
s.add_development_dependency "slim"
+ s.add_development_dependency "simple_form"
s.add_development_dependency "tzinfo" # FIXME: why the hell do we need this for 3.1?
s.add_development_dependency "minitest", ">= 2.8.1"
end
View
5 test/app/cells/rails_helper_api_test/bassist/edit.html.erb
@@ -0,0 +1,5 @@
+<%= simple_form_for @fruit do |f| %>
+ <%= f.input :title %>
+ <%= f.button :submit %>
+<% end %>
+<%= url_for(:host => "apotomo.de") %>
View
59 test/rails_helper_api_test.rb
@@ -0,0 +1,59 @@
+require 'test_helper'
+require 'cell/rails/helper_api'
+
+
+class RailsHelperAPITest < MiniTest::Spec
+ class ::Fruit
+ extend ActiveModel::Naming
+ include ActiveModel::Conversion
+
+ def initialize(attributes={})
+ @attributes = attributes
+ end
+
+ def title
+ @attributes[:title]
+ end
+
+ def persisted?
+ false
+ end
+ end
+
+
+ class FakeRoutes # should be sinatra's url helper instance
+ def url_for(*)
+ end
+ end
+
+ module FakeHelpers
+ def fruits_path(model, *args)
+ "/fruits"
+ end
+ end
+
+ require "simple_form"
+ class BassistCell < Cell::Base
+ include Cell::Rails::HelperAPI
+
+ self._helpers = FakeHelpers
+ self._routes = FakeRoutes.new
+
+ def edit
+ @tone = "C"
+ @fruit = Fruit.new(:title => "Banana")
+ render
+ end
+ end
+
+ describe "Rails::HelperAPI" do
+ it "allows accessing the request object" do
+ #BassistCell.append_view_path(".")
+ assert_equal '<form accept-charset="UTF-8" action="/fruits" class="simple_form new_fruit" id="new_fruit" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /></div>
+ <div class="input string required"><label class="string required" for="fruit_title"><abbr title="required">*</abbr> Title</label><input class="string required" id="fruit_title" name="fruit[title]" required="required" size="50" type="text" value="Banana" /></div>
+ <input class="button" name="commit" type="submit" value="Create Fruit" />
+</form>
+', BassistCell.new.render_state(:edit)
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.