got it. The normal FormBuilder class uses template as a pass through for
the basic form fields.
before do
helper = Object.new.extend ActionView::Helpers::FormHelper
@object = mock_model(Foo)
@builder = RandomFormBuilder(:foo, @object, helper, {}, nil)
end
then all works beautifully.
On Thu, Feb 5, 2009 at 11:05 AM, Chris Flipse <cflipse at gmail.com>
wrote:
> I''m trying to set up and run a new form builder under rails, which
lives
> under the helpers directory, but isn''t really a helper. (Not a
module, so
> doesn''t mix in well)
>
> Short of dropping down into a view spec, how do I set up to actually spec
> the form builder?
>
> describe RandomFormBuilder do
> attr_reader :builder
> before do
> @object = mock_model(Foo)
> @builder = RandomFormBuilder.new(:foo, @object, #template#, {}, nil)
> end
>
> describe "#text_field" do
> it "should have a label" do
> @builder.text_field(:foo).should have_tag("label",
"Foo")
> end
> end
> end
>
> class RandomFormBuilder < ActionView::Helpers::FormBuilder
> def text_field(method, *args)
> label(method)
> super(method, *args)
> end
> end
>
> That''s sort of what I''ve got at the moment. #template#
supposed to be an
> object with access to all the normal helpers, I _think_.
> using helper in that location gives me a NoMethodError.
>
> using self in that location ends up with the helper trying to delegate
> methods to Spec::Rails::Example::RailsExampleGroup::Subclass ....
>
>
> has anybody figured out what hoops this needs?
>
> --
> // anything worth taking seriously is worth making fun of
> // http://blog.devcaffeine.com/
>
--
// anything worth taking seriously is worth making fun of
// http://blog.devcaffeine.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/rspec-users/attachments/20090205/3bc2eecc/attachment-0001.html>