Re: [rspec-users] specs on private methods

2008-01-11 Thread Jarkko Laine
On Jan 11, 2008, at 5:54 PM, Ben Mabey <[EMAIL PROTECTED]> wrote: > David Chelimsky wrote: >> >> >> In TDD there is a rule of thumb that says don't stub a method in the >> same class as the method you're testing. The risk is that as the real >> implementation of by_input_sets!() changes over tim

Re: [rspec-users] specs on private methods

2008-01-11 Thread Zach Dennis
On Jan 11, 2008 12:56 PM, Cody P. Skidmore <[EMAIL PROTECTED]> wrote: > Thank you Zach. I was just about to ask about this. I'm just getting > started with restful_authentication and have missed the context of your > point. restful_authentication is such a huge improvement over what I'm > use to

Re: [rspec-users] specs on private methods

2008-01-11 Thread Cody P. Skidmore
Thank you Zach. I was just about to ask about this. I'm just getting started with restful_authentication and have missed the context of your point. restful_authentication is such a huge improvement over what I'm use to. Could you elaborate just a little on the use context in controllers? Is th

Re: [rspec-users] specs on private methods

2008-01-11 Thread Zach Dennis
To add, all of our managers return LoginResult objects which contain methods like: - successful? - user - message In the controller our code will look like: if login.successful? self.current_user = login.user else flash[:error] = login.message end This has worked well because it allows e

Re: [rspec-users] specs on private methods

2008-01-11 Thread Zach Dennis
We pass the required items in as method arguments. In the spirit of sharing code and getting people to review code. Here is our current LoginManager: class LoginManager include Injection inject :invitation_manager def login_from_cookie(cookies, session) CookieLoginManager.new( :co

Re: [rspec-users] specs on private methods

2008-01-11 Thread Ben Mabey
Zach Dennis wrote: > On Jan 11, 2008 11:56 AM, David Chelimsky <[EMAIL PROTECTED]> wrote: > >> On Jan 11, 2008 9:54 AM, Ben Mabey <[EMAIL PROTECTED]> wrote: >> >>> David Chelimsky wrote: >>> In TDD there is a rule of thumb that says don't stub a method in the same class as

Re: [rspec-users] specs on private methods

2008-01-11 Thread David Chelimsky
On Jan 11, 2008 11:40 AM, Zach Dennis <[EMAIL PROTECTED]> wrote: > On Jan 11, 2008 11:56 AM, David Chelimsky <[EMAIL PROTECTED]> wrote: > > On Jan 11, 2008 9:54 AM, Ben Mabey <[EMAIL PROTECTED]> wrote: > > > David Chelimsky wrote: > > > > > > > > > > > > In TDD there is a rule of thumb that says do

Re: [rspec-users] specs on private methods

2008-01-11 Thread Zach Dennis
On Jan 11, 2008 11:56 AM, David Chelimsky <[EMAIL PROTECTED]> wrote: > On Jan 11, 2008 9:54 AM, Ben Mabey <[EMAIL PROTECTED]> wrote: > > David Chelimsky wrote: > > > > > > > > > In TDD there is a rule of thumb that says don't stub a method in the > > > same class as the method you're testing. The r

Re: [rspec-users] specs on private methods

2008-01-11 Thread David Chelimsky
On Jan 11, 2008 9:54 AM, Ben Mabey <[EMAIL PROTECTED]> wrote: > David Chelimsky wrote: > > > > > > In TDD there is a rule of thumb that says don't stub a method in the > > same class as the method you're testing. The risk is that as the real > > implementation of by_input_sets!() changes over time,

Re: [rspec-users] specs on private methods

2008-01-11 Thread Ben Mabey
David Chelimsky wrote: > > > In TDD there is a rule of thumb that says don't stub a method in the > same class as the method you're testing. The risk is that as the real > implementation of by_input_sets!() changes over time, it has access to > internal state that could impact the behaviour of deco

Re: [rspec-users] specs on private methods

2008-01-11 Thread Zach Dennis
On Jan 11, 2008 5:23 AM, David Chelimsky <[EMAIL PROTECTED]> wrote: > On Jan 11, 2008 3:49 AM, Shot (Piotr Szotkowski) <[EMAIL PROTECTED]> wrote: > > Daniel Tenner: > > > > > Might be a personal thing, but my approach is that I try to test the > > > public behaviour of the object. Testing private m

Re: [rspec-users] specs on private methods

2008-01-11 Thread David Chelimsky
On Jan 11, 2008 8:04 AM, Shot (Piotr Szotkowski) <[EMAIL PROTECTED]> wrote: > David Chelimsky: > > > On Jan 11, 2008 3:49 AM, Shot (Piotr Szotkowski) <[EMAIL PROTECTED]> wrote: > > >> One run of by_input_sets!() takes a couple of seconds, so can > >> be tested; one run of decompose!() takes much lo

Re: [rspec-users] specs on private methods

2008-01-11 Thread Shot (Piotr Szotkowski)
David Chelimsky: > On Jan 11, 2008 3:49 AM, Shot (Piotr Szotkowski) <[EMAIL PROTECTED]> wrote: >> One run of by_input_sets!() takes a couple of seconds, so can >> be tested; one run of decompose!() takes much longer, so to test >> decompose!() I should stub by_input_sets!() so it returns canned >

Re: [rspec-users] specs on private methods

2008-01-11 Thread David Chelimsky
On Jan 11, 2008 3:49 AM, Shot (Piotr Szotkowski) <[EMAIL PROTECTED]> wrote: > Daniel Tenner: > > > Might be a personal thing, but my approach is that I try to test the > > public behaviour of the object. Testing private methods is, imho, > > getting dangerously close to specifying how the object do

Re: [rspec-users] specs on private methods

2008-01-11 Thread Shot (Piotr Szotkowski)
Daniel Tenner: > Might be a personal thing, but my approach is that I try to test the > public behaviour of the object. Testing private methods is, imho, > getting dangerously close to specifying how the object does its > business, rather than what it does. I agree on principle, but I ran into th

Re: [rspec-users] specs on private methods

2008-01-10 Thread Francois Wurmus
Yes, you're absolutely right. I somehow ignored the class name in my previous answers, but that would have been the next point of attack. ;-) Pat Maddox schrieb: > On Jan 10, 2008 12:34 PM, Francois Wurmus <[EMAIL PROTECTED]> wrote: >> Even my suggestion wouldn't be a sufficient spec. What abou

Re: [rspec-users] specs on private methods

2008-01-10 Thread Pat Maddox
On Jan 10, 2008 12:34 PM, Francois Wurmus <[EMAIL PROTECTED]> wrote: > Even my suggestion wouldn't be a sufficient spec. What about completely > wrong mac addresses? Empty addresses, too many characters, invalid > characters? I just sent a reply that crossed wires with yours...anyway, introducing

Re: [rspec-users] specs on private methods

2008-01-10 Thread Pat Maddox
On Jan 10, 2008 12:25 PM, Jarkko Laine <[EMAIL PROTECTED]> wrote: > Also, this line of code is a bit smelly: > > >> normalized = @signup.normalize_mac(@signup.mac_address) > > Since normalize_mac is an instance method in the Signup class, there's > no point passing the mac_address as a paramet

Re: [rspec-users] specs on private methods

2008-01-10 Thread Francois Wurmus
Even my suggestion wouldn't be a sufficient spec. What about completely wrong mac addresses? Empty addresses, too many characters, invalid characters? It is not for nothing that the rspec test cases are called examples - you may define any number of example inputs and expected outputs that are

Re: [rspec-users] specs on private methods

2008-01-10 Thread Jarkko Laine
On 10.1.2008, at 22.21, Francois Wurmus wrote: > Apart from private or public methods I see a problem in your test > case. > You don't make sure that your mac_address is returned in exactly the > way > you want - you are merely saying it should look like the return > value of > some (protec

Re: [rspec-users] specs on private methods

2008-01-10 Thread Francois Wurmus
Apart from private or public methods I see a problem in your test case. You don't make sure that your mac_address is returned in exactly the way you want - you are merely saying it should look like the return value of some (protected) method you call (normalize_mac). Let's assume this method was

[rspec-users] specs on private methods

2008-01-10 Thread barsalou
It's interesting that this thread has started because I just ran into this problem. The error I got was: NoMethodError in 'Signup she be a valid mac address' protected method `normalize_mac' called for # ./spec/models/signup_spec.rb:10: Here's the spec: describe Signup do before(:each) do

Re: [rspec-users] specs on private methods

2008-01-09 Thread Pat Maddox
On Jan 9, 2008 5:26 AM, Richard Conroy <[EMAIL PROTECTED]> wrote: > On Jan 8, 2008 7:14 PM, Daniel Tenner <[EMAIL PROTECTED]> wrote: > > Might be a personal thing, but my approach is that I try to test the > > public behaviour of the object. Testing private methods is, imho, > > getting dangerously

Re: [rspec-users] specs on private methods

2008-01-09 Thread Pat Maddox
On Jan 8, 2008 11:25 AM, Matt Patterson <[EMAIL PROTECTED]> wrote: > On 8 Jan 2008, at 19:14, Daniel Tenner wrote: > > > > Might be a personal thing, but my approach is that I try to test the > > public behaviour of the object. Testing private methods is, imho, > > getting dangerously close to spec

Re: [rspec-users] specs on private methods

2008-01-09 Thread Rick DeNatale
On Jan 8, 2008 3:56 PM, Francois Wurmus <[EMAIL PROTECTED]> wrote: > Chris Olsen schrieb: > > Will obj.send(:method) work in 1.9 or is it saying that the send call > > requires 2 params, the method and the object reference? > > > obj.send(:method) will work for non-private methods and send! works f

Re: [rspec-users] specs on private methods

2008-01-09 Thread Stefan Magnus Landrø
This is also worth checking out: http://xunitpatterns.com/ -- Bekk Open Source http://boss.bekk.no ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] specs on private methods

2008-01-09 Thread David Chelimsky
On Jan 9, 2008 7:26 AM, Richard Conroy <[EMAIL PROTECTED]> wrote: > On Jan 8, 2008 7:14 PM, Daniel Tenner <[EMAIL PROTECTED]> wrote: > > Might be a personal thing, but my approach is that I try to test the > > public behaviour of the object. Testing private methods is, imho, > > getting dangerously

Re: [rspec-users] specs on private methods

2008-01-09 Thread Richard Conroy
On Jan 8, 2008 7:14 PM, Daniel Tenner <[EMAIL PROTECTED]> wrote: > Might be a personal thing, but my approach is that I try to test the > public behaviour of the object. Testing private methods is, imho, > getting dangerously close to specifying how the object does its > business, rather than what

Re: [rspec-users] specs on private methods

2008-01-09 Thread David Chelimsky
On Jan 9, 2008 7:12 AM, Stefan Magnus Landrø <[EMAIL PROTECTED]> wrote: > > 2008/1/9, Kerry Buckley < [EMAIL PROTECTED]>: > > > On Jan 9, 2008 10:01 AM, Stefan Magnus Landrø < [EMAIL PROTECTED]> > wrote: > > > I totally agree with you, David! > > > > > > For quite a while I was testing all my metho

Re: [rspec-users] specs on private methods

2008-01-09 Thread David Chelimsky
On Jan 9, 2008 6:09 AM, Kerry Buckley <[EMAIL PROTECTED]> wrote: > On Jan 9, 2008 10:01 AM, Stefan Magnus Landrø <[EMAIL PROTECTED]> wrote: > > I totally agree with you, David! Then you agree with the majority of the TDD community. > > > > For quite a while I was testing all my methods (even had

Re: [rspec-users] specs on private methods

2008-01-09 Thread Stefan Magnus Landrø
Well, I think it all depends on the scenario - but in a lot of cases it should absolutely be considered a code-smell. Stefan 2008/1/9, Kerry Buckley <[EMAIL PROTECTED]>: > > On Jan 9, 2008 10:01 AM, Stefan Magnus Landrø <[EMAIL PROTECTED]> > wrote: > > I totally agree with you, David! > > > > For

Re: [rspec-users] specs on private methods

2008-01-09 Thread Kerry Buckley
On Jan 9, 2008 10:01 AM, Stefan Magnus Landrø <[EMAIL PROTECTED]> wrote: > I totally agree with you, David! > > For quite a while I was testing all my methods (even had to declare them > protected/package scope in java!), but I realized that I was getting into a > lot of trouble. Now I've shifted t

Re: [rspec-users] specs on private methods

2008-01-09 Thread Daniel Tenner
Just to clarify, this is what I meant in my original email :-) Most of my methods are very small - in Ruby any method longer than 5 lines is, imho, a code smell that's waiting to be fixed. However, no matter how many methods are used to implement the functionality, I test the public behavio

Re: [rspec-users] specs on private methods

2008-01-09 Thread Stefan Magnus Landrø
I totally agree with you, David! For quite a while I was testing all my methods (even had to declare them protected/package scope in java!), but I realized that I was getting into a lot of trouble. Now I've shifted to testing functionality in stead of methods. Now, sometimes you might end up havi

Re: [rspec-users] specs on private methods

2008-01-08 Thread Francois Wurmus
obj.send(:method) will work for non-private methods and send! works for private methods. additionally there is send() without a receiving object. that is the only of those methods requiring two parameters. Chris Olsen schrieb: > Will obj.send(:method) work in 1.9 or is it saying that the send

Re: [rspec-users] specs on private methods

2008-01-08 Thread David Chelimsky
On Jan 8, 2008 1:25 PM, Matt Patterson <[EMAIL PROTECTED]> wrote: > On 8 Jan 2008, at 19:14, Daniel Tenner wrote: > > > > Might be a personal thing, but my approach is that I try to test the > > public behaviour of the object. Testing private methods is, imho, > > getting dangerously close to speci

Re: [rspec-users] specs on private methods

2008-01-08 Thread Francois Wurmus
The send call never expects an object reference as a parameter. Either it is called on an object or without an object context (i.e. kernel). In the first case the parameter should contain one of the receiving object's methods. In the second case the parameter is a kernel method. But... that's n

Re: [rspec-users] specs on private methods

2008-01-08 Thread David Chelimsky
On Jan 8, 2008 2:47 PM, Chris Olsen <[EMAIL PROTECTED]> wrote: > Will obj.send(:method) work in 1.9 or is it saying that the send call > requires 2 params, the method and the object reference? In 1.9 you can say obj.send!(:method) even if :method is private. obj.send(:method) will not work for pri

Re: [rspec-users] specs on private methods

2008-01-08 Thread Chris Olsen
Will obj.send(:method) work in 1.9 or is it saying that the send call requires 2 params, the method and the object reference? -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman

Re: [rspec-users] specs on private methods

2008-01-08 Thread Tim Harper
Well there we go, Ben's method still stands :) Tim On Jan 8, 2008, at 12:36 PM, Ben Mabey wrote: > Yes. http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l24 > > Tim Harper wrote: >> Doesn't 1.9 allow you to call obj.send!, which will allow you to >> access private methods? >> >> Tim >> >> On Ja

Re: [rspec-users] specs on private methods

2008-01-08 Thread Ben Mabey
Yes. http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l24 Tim Harper wrote: > Doesn't 1.9 allow you to call obj.send!, which will allow you to > access private methods? > > Tim > > On Jan 8, 2008, at 12:27 PM, Scott Taylor wrote: > > >> On Jan 8, 2008, at 2:20 PM, Ben Mabey wrote: >> >> >

Re: [rspec-users] specs on private methods

2008-01-08 Thread Tim Harper
Doesn't 1.9 allow you to call obj.send!, which will allow you to access private methods? Tim On Jan 8, 2008, at 12:27 PM, Scott Taylor wrote: > > On Jan 8, 2008, at 2:20 PM, Ben Mabey wrote: > >> Chris Olsen wrote: >>> How does a person test private methods? >>> >>> Is there a way to declare t

Re: [rspec-users] specs on private methods

2008-01-08 Thread Scott Taylor
On Jan 8, 2008, at 2:20 PM, Ben Mabey wrote: > Chris Olsen wrote: >> How does a person test private methods? >> >> Is there a way to declare them as private, but retain any tests that >> were written during the initial development? >> >> Thanks. >> > When I need to do this I just use the send met

Re: [rspec-users] specs on private methods

2008-01-08 Thread Matt Patterson
On 8 Jan 2008, at 19:14, Daniel Tenner wrote: > Might be a personal thing, but my approach is that I try to test the > public behaviour of the object. Testing private methods is, imho, > getting dangerously close to specifying how the object does its > business, rather than what it does. > If yo

Re: [rspec-users] specs on private methods

2008-01-08 Thread Ben Mabey
Chris Olsen wrote: > How does a person test private methods? > > Is there a way to declare them as private, but retain any tests that > were written during the initial development? > > Thanks. > When I need to do this I just use the send method. -Ben

Re: [rspec-users] specs on private methods

2008-01-08 Thread Daniel Tenner
Might be a personal thing, but my approach is that I try to test the public behaviour of the object. Testing private methods is, imho, getting dangerously close to specifying how the object does its business, rather than what it does. I would just spec the externally visible behaviour, where

Re: [rspec-users] specs on private methods

2008-01-08 Thread Matt Patterson
On 8 Jan 2008, at 18:39, Chris Olsen wrote: > How does a person test private methods? > > Is there a way to declare them as private, but retain any tests that > were written during the initial development? I'm rather liking Jay Field's approach (described at http:// blog.jayfields.com/2007/11/ru

[rspec-users] specs on private methods

2008-01-08 Thread Chris Olsen
How does a person test private methods? Is there a way to declare them as private, but retain any tests that were written during the initial development? Thanks. -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyfor