Yep, that solved it. Thanks! On Mon, Jun 22, 2009 at 3:02 PM, David Chelimsky <dchelim...@gmail.com>wrote:
> On Mon, Jun 22, 2009 at 2:57 PM, Peer Allan<p...@bipolarsoftware.ca> > wrote: > > Thanks David, I completely missed that in your first response. > > No problem. Let me know if it helps :) > > > Peer > > > > On Mon, Jun 22, 2009 at 2:31 PM, David Chelimsky <dchelim...@gmail.com> > > wrote: > >> > >> On Mon, Jun 22, 2009 at 2:07 PM, Peer Allan<p...@bipolarsoftware.ca> > >> wrote: > >> > Still having trouble, here is my code. > >> > Code: > >> > class MyFormBuilder < ActionView::Helpers::FormBuilder > >> > def custom_select(field_name, *args) > >> > field_name ||= :salutation > >> > salutations = > >> > Lookup.for_type_and_column('Contact','salutation').map{|lookup| > >> > lookup.description} > >> > select(field_name, salutations, :include_blank => true, :prompt => > >> > "Please select salutation..") > >> > end > >> > end > >> > Spec: > >> > before(:each) do > >> > @object = mock_model(Company) > >> > @builder = MyFormBuilder.new(:company, @object, self, {}, nil) > >> > end > >> > > >> > it "should return collection of currency codes" do > >> > @builder.custom_select(:salutation, {}) > >> > end > >> > No assertion in there, but it doesn't matter because I get this error: > >> > private method `select' called for > >> > #<ActiveSupport::TestCase::Subclass_1::Subclass_1:0x72b229c> > >> > I haven't had any success getting around this one, without stubbing > >> > beyond > >> > recognition. Any ideas? > >> > >> This is what I was saying before - that you can't use self anymore > >> because the helper module is not included in the current context. > >> Instead, use the helper object: > >> > >> @builder = MyFormBuilder.new(:company, @object, helper, {}, nil) > >> > >> HTH, > >> David > >> > >> > peer > >> > On Mon, Jun 22, 2009 at 12:57 PM, David Chelimsky < > dchelim...@gmail.com> > >> > wrote: > >> >> > >> >> On Mon, Jun 22, 2009 at 12:53 PM, Peer Allan<p...@bipolarsoftware.ca > > > >> >> wrote: > >> >> > Hello all, > >> >> > In a bit of a conundrum here. I have a custom form builder I am > >> >> > trying > >> >> > to > >> >> > test and can't seem to get it to work. I found this > >> >> > http://www.pathf.com/blogs/2007/12/rspec-and-rails/ > >> >> > >> >> Things have changed a bit since Dec 07. The helper module is no > longer > >> >> included directly in the example group, but are exposed through a > >> >> helper object instead. > >> >> > >> >> > which helps in that it > >> >> > points me to the HelperExampleGroup to get the @template methods I > am > >> >> > going > >> >> > to need. The problem is that we have our form builders in their > own > >> >> > folder > >> >> > (app/form_builders) and hence their own spec folder > >> >> > (spec/form_builders). > >> >> > How can I get the specs in that folder (spec/form_builders) to > >> >> > behave > >> >> > like > >> >> > they were helper tests so that I have access to the @template > object? > >> >> > Thanks > >> >> > Peer > >> >> > >> >> describe "thing", :type => :helper do > >> >> ... > >> >> end > >> >> > >> >> Cheers, > >> >> David > >> >> _______________________________________________ > >> >> rspec-users mailing list > >> >> rspec-users@rubyforge.org > >> >> http://rubyforge.org/mailman/listinfo/rspec-users > >> > > >> > > >> > _______________________________________________ > >> > rspec-users mailing list > >> > rspec-users@rubyforge.org > >> > http://rubyforge.org/mailman/listinfo/rspec-users > >> > > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users@rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users@rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users