Re: [rspec-users] Specing protected methods

2008-10-23 Thread Avdi Grimm
On Thu, Oct 23, 2008 at 5:00 PM, Avdi Grimm <[EMAIL PROTECTED]> wrote: > FWIW, I blogged my answer to this question recently: > http://avdi.org/devblog/2008/10/21/testing-private-methods/ ...and to be a little more concrete, at first glance the way I'd apply that advice to your code example is to

Re: [rspec-users] Specing protected methods

2008-10-23 Thread Avdi Grimm
On Thu, Oct 23, 2008 at 5:16 AM, Bastien <[EMAIL PROTECTED]> wrote: > Hi everyone, > Do anyone know if there's a way to spec protected methods ? > Thanks in advance FWIW, I blogged my answer to this question recently: http://avdi.org/devblog/2008/10/21/testing-private-methods/ -- Avdi Home: htt

Re: [rspec-users] Specing protected methods

2008-10-23 Thread David Chelimsky
On Thu, Oct 23, 2008 at 10:00 AM, Bastien <[EMAIL PROTECTED]> wrote: > Thanks for all your answers. > > I was just wondering how about using send in my specs ? It would > bypass the protected limitation without altering my code : > > @survey.send( :sub_total, [EMAIL PROTECTED] ) > > Is that the kin

Re: [rspec-users] Specing protected methods

2008-10-23 Thread Bastien
Thanks for all your answers. I was just wondering how about using send in my specs ? It would bypass the protected limitation without altering my code : @survey.send( :sub_total, [EMAIL PROTECTED] ) Is that the kind of trickery you were referring to David ? Would that be bad practice ? Regards

Re: [rspec-users] Specing protected methods

2008-10-23 Thread David Chelimsky
On Thu, Oct 23, 2008 at 6:49 AM, Bastien <[EMAIL PROTECTED]> wrote: > I totally agree with the ''listening to your specs" concepts and > always divide my code into small methods easier to spec. > Now let me get you right, here's my code : > > class Survey < ActiveRecord::Base > has_many :participa

Re: [rspec-users] Specing protected methods

2008-10-23 Thread Pat Maddox
Bastien <[EMAIL PROTECTED]> writes: > I totally agree with the ''listening to your specs" concepts and > always divide my code into small methods easier to spec. > Now let me get you right, here's my code : > > class Survey < ActiveRecord::Base > has_many :participants > ... > def generate_r

Re: [rspec-users] Specing protected methods

2008-10-23 Thread Craig Demyanovich
On Thu, Oct 23, 2008 at 7:49 AM, Bastien <[EMAIL PROTECTED]> wrote: > I m already specing the "generate_reports" methods with a mock on > "sub_total", but I would also like to spec that method. I've put this > method into protected because it doesn't make sens to call it from > outside this class.

Re: [rspec-users] Specing protected methods

2008-10-23 Thread Bastien
I totally agree with the ''listening to your specs" concepts and always divide my code into small methods easier to spec. Now let me get you right, here's my code : class Survey < ActiveRecord::Base has_many :participants ... def generate_reports ... sub_total = sub_total(participant

Re: [rspec-users] Specing protected methods

2008-10-23 Thread Matt Wynne
On 23 Oct 2008, at 10:16, Bastien wrote: Hi everyone, Do anyone know if there's a way to spec protected methods ? Thanks in advance Sorry if this sounds preachy, but I would always advise you to factor out the code in the method into another class, then test that class. If the behaviour of

[rspec-users] Specing protected methods

2008-10-23 Thread Bastien
Hi everyone, Do anyone know if there's a way to spec protected methods ? Thanks in advance -- Bastien ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users