I have a rubygem that defines its own SemanticFormBuilder class that adds a new Formtastic input type. The code works as expected, but I cannot figure out how to add tests to it. I thought I could do something like loading Formtastic, call semantic_form_for, and then entering an ad using my own type :as , but I have no idea where to start.
Does anyone know of any gems that do something similar so that I can take a look at the source? Any suggestions on where to start?
My gem requires Rails 2.3.x
The source for my user input looks like this, and I include it in the initializer in my application:
module ClassyEnumHelper class SemanticFormBuilder < Formtastic::SemanticFormBuilder def enum_select_input(method, options) enum_class = object.send(method) unless enum_class.respond_to? :base_class raise "#{method} does not refer to a defined ClassyEnum object" end options[:collection] = enum_class.base_class.all_with_name options[:selected] = enum_class.to_s select_input(method, options) end end end
Not sure if any of my other source codes will help, but it can be found here http://github.com/beerlington/classy_enum
source share