Re: [rspec-users] validate_presence_of

2009-02-19 Thread Matt Wynne
On 19 Feb 2009, at 05:40, Stephen Eley wrote: On Wed, Feb 18, 2009 at 11:42 PM, Yi Wen hayafi...@gmail.com wrote: Without this syntax sugar, we still have to test validates_presence_of to make sure it's there and won't broken, right? Wrong. You don't have to test validates_presence_of.

Re: [rspec-users] validate_presence_of

2009-02-19 Thread Fernando Perez
Wrong. You don't have to test validates_presence_of. What matters, and therefore what you should test, is whether the model will complain at you if a particular value is left empty. ... If your spec breaks because you changed a method call, you're not testing behavior any more. You're

Re: [rspec-users] validate_presence_of

2009-02-19 Thread Mike Gaffney
Dave, you make a good point. In our system, where we are converting a legacy database/application, we typically have no user stories and have the technical (or you could argue user) requirement that the database logic / constraints get converted. This is where we are typically just encoding

Re: [rspec-users] validate_presence_of

2009-02-19 Thread Stephen Eley
On Thu, Feb 19, 2009 at 12:58 AM, David Chelimsky dchelim...@gmail.com wrote: Also, while I used to be very anal and write should have(1).error_on(:login) and such, I eventually realized that there's no point. Checking on 'valid?' is entire and sufficient. I think this depends on whether or

Re: [rspec-users] validate_presence_of

2009-02-19 Thread David Chelimsky
On Wed, Feb 18, 2009 at 11:40 PM, Stephen Eley sfe...@gmail.com wrote: deliberately_out_of_context_to_make_a_point If your spec breaks because you changed a method call, you're not testing behavior any more. You're testing syntax. /deliberately_out_of_context_to_make_a_point We've got to stop

Re: [rspec-users] validate_presence_of

2009-02-19 Thread Zach Dennis
On Thu, Feb 19, 2009 at 12:31 AM, Stephen Eley sfe...@gmail.com wrote: On Wed, Feb 18, 2009 at 10:42 PM, Mark Wilden m...@mwilden.com wrote: On Wed, Feb 18, 2009 at 4:39 PM, Fernando Perez li...@ruby-forum.com wrote: What's the point in testing validates_presence_of for a model? To make sure

Re: [rspec-users] validate_presence_of

2009-02-19 Thread Yi Wen
Good point, that's actually I am debating with myself everyday and haven't got a clear answer. This is classical calssic unit tester vs. mockist war. :) Talking about this case: 1. I haven't checked how should valite_presence_of is implemented, but it could pretty much be checking if the value

Re: [rspec-users] validate_presence_of

2009-02-19 Thread David Chelimsky
On Thu, Feb 19, 2009 at 8:20 AM, Stephen Eley sfe...@gmail.com wrote: On Thu, Feb 19, 2009 at 12:58 AM, David Chelimsky dchelim...@gmail.com wrote: Also, while I used to be very anal and write should have(1).error_on(:login) and such, I eventually realized that there's no point. Checking

Re: [rspec-users] validate_presence_of

2009-02-19 Thread Stephen Eley
On Thu, Feb 19, 2009 at 12:15 PM, Stephen Eley sfe...@gmail.com wrote: But I did not write any code yet setting the message. Because I haven't written any tests for the message. At this point I don't care what the message is, just that I have the right data. I care about the message when I

Re: [rspec-users] validate_presence_of

2009-02-19 Thread Mark Wilden
On Wed, Feb 18, 2009 at 9:40 PM, Stephen Eley sfe...@gmail.com wrote: On Wed, Feb 18, 2009 at 11:42 PM, Yi Wen hayafi...@gmail.com wrote: validates_presence_of happens to be the name of the method in ActiveRecord that does that. But if you decide to write your own

Re: [rspec-users] validate_presence_of

2009-02-19 Thread Stephen Eley
On Thu, Feb 19, 2009 at 10:55 AM, David Chelimsky dchelim...@gmail.com wrote: This is where this all gets tricky. Yep. 8- TDD (remember? that's where this all started) says you don't write any subject code without a failing *unit test*. This is not about the end result - it's about a

Re: [rspec-users] validate_presence_of

2009-02-19 Thread David Chelimsky
On Thu, Feb 19, 2009 at 11:38 AM, Mark Wilden m...@mwilden.com wrote: On Wed, Feb 18, 2009 at 9:40 PM, Stephen Eley sfe...@gmail.com wrote: On Wed, Feb 18, 2009 at 11:42 PM, Yi Wen hayafi...@gmail.com wrote: validates_presence_of happens to be the name of the method in ActiveRecord that does

Re: [rspec-users] validate_presence_of

2009-02-18 Thread Fernando Perez
Yi Wen wrote: Hello, according to this post: http://blog.davidchelimsky.net/2009/1/13/rspec-1-1-12-is-released I should be able to write: describe User do it {should valdate_presence_of(:login)} end What's the point in testing validates_presence_of for a model? It's already tested

Re: [rspec-users] validate_presence_of

2009-02-18 Thread Pat Maddox
On Wed, Feb 18, 2009 at 4:39 PM, Fernando Perez li...@ruby-forum.com wrote: Yi Wen wrote: Hello, according to this post: http://blog.davidchelimsky.net/2009/1/13/rspec-1-1-12-is-released I should be able to write: describe User do it {should valdate_presence_of(:login)} end What's

Re: [rspec-users] validate_presence_of

2009-02-18 Thread Zach Dennis
On Wed, Feb 18, 2009 at 7:39 PM, Fernando Perez li...@ruby-forum.com wrote: Yi Wen wrote: Hello, according to this post: http://blog.davidchelimsky.net/2009/1/13/rspec-1-1-12-is-released I should be able to write: describe User do it {should valdate_presence_of(:login)} end What's

Re: [rspec-users] validate_presence_of

2009-02-18 Thread Alex Satrapa
On 19/02/2009, at 11:39 , Fernando Perez wrote: What's the point in testing validates_presence_of for a model? It's already tested in the framework, and so readable that a quick glance on the model says it all. Some people want the spec to stand as a contract, so you can then hand the

Re: [rspec-users] validate_presence_of

2009-02-18 Thread Zach Dennis
On Wed, Feb 18, 2009 at 8:47 PM, Alex Satrapa gr...@goldweb.com.au wrote: On 19/02/2009, at 11:39 , Fernando Perez wrote: What's the point in testing validates_presence_of for a model? It's already tested in the framework, and so readable that a quick glance on the model says it all. Some

Re: [rspec-users] validate_presence_of

2009-02-18 Thread Zach Dennis
On Wed, Feb 18, 2009 at 7:39 PM, Fernando Perez li...@ruby-forum.com wrote: Yi Wen wrote: Hello, according to this post: http://blog.davidchelimsky.net/2009/1/13/rspec-1-1-12-is-released I should be able to write: describe User do it {should valdate_presence_of(:login)} end What's

Re: [rspec-users] validate_presence_of

2009-02-18 Thread Jim Gay
On Feb 18, 2009, at 7:39 PM, Fernando Perez wrote: Yi Wen wrote: Hello, according to this post: http://blog.davidchelimsky.net/2009/1/13/rspec-1-1-12-is-released I should be able to write: describe User do it {should valdate_presence_of(:login)} end What's the point in testing

Re: [rspec-users] validate_presence_of

2009-02-18 Thread Alex Satrapa
On 19/02/2009, at 13:02 , Zach Dennis wrote: I have never seen or heard of anyone who writes a spec (developer level RSpec spec), but not the code and then hands it over to someone else and demands that that person implements it. The fun begins when you can point out two or three conflicting

Re: [rspec-users] validate_presence_of

2009-02-18 Thread David Chelimsky
On Wed, Feb 18, 2009 at 9:02 PM, Alex Satrapa gr...@goldweb.com.au wrote: On 19/02/2009, at 13:02 , Zach Dennis wrote: I have never seen or heard of anyone who writes a spec (developer level RSpec spec), but not the code and then hands it over to someone else and demands that that person

Re: [rspec-users] validate_presence_of

2009-02-18 Thread Mark Wilden
On Wed, Feb 18, 2009 at 4:39 PM, Fernando Perez li...@ruby-forum.com wrote: I should be able to write: describe User do it {should valdate_presence_of(:login)} end What's the point in testing validates_presence_of for a model? To make sure you wrote that line of code. ///ark

Re: [rspec-users] validate_presence_of

2009-02-18 Thread David Chelimsky
On Wed, Feb 18, 2009 at 9:42 PM, Mark Wilden m...@mwilden.com wrote: On Wed, Feb 18, 2009 at 4:39 PM, Fernando Perez li...@ruby-forum.com wrote: I should be able to write: describe User do it {should valdate_presence_of(:login)} end What's the point in testing validates_presence_of for

Re: [rspec-users] validate_presence_of

2009-02-18 Thread Pat Maddox
On Wed, Feb 18, 2009 at 7:42 PM, Mark Wilden m...@mwilden.com wrote: On Wed, Feb 18, 2009 at 4:39 PM, Fernando Perez li...@ruby-forum.com wrote: I should be able to write: describe User do it {should valdate_presence_of(:login)} end What's the point in testing validates_presence_of for

Re: [rspec-users] validate_presence_of

2009-02-18 Thread Alex Satrapa
On 19/02/2009, at 14:05 , David Chelimsky wrote: Why not start w/ RSpec but do it right? I made the mistake of showing the guy a spec from a previous project and narrating (not showing) how the code was built from the spec. So the manager didn't realise that the spec was built one line at

Re: [rspec-users] validate_presence_of

2009-02-18 Thread Pat Maddox
On Wed, Feb 18, 2009 at 6:06 PM, Zach Dennis zach.den...@gmail.com wrote: On Wed, Feb 18, 2009 at 7:39 PM, Fernando Perez li...@ruby-forum.com wrote: Yi Wen wrote: Hello, according to this post: http://blog.davidchelimsky.net/2009/1/13/rspec-1-1-12-is-released I should be able to write:

Re: [rspec-users] validate_presence_of

2009-02-18 Thread Yi Wen
We should write a test/spec, whatever you call it, *first* before you want your code. But it doesn't mean one who writes the spec/test will use a monkey coding the code to fix the test. To be realistic, a programmer will write this test, and implement it right away. Just like how TDD should be

Re: [rspec-users] validate_presence_of

2009-02-18 Thread Mike Gaffney
Pat, not nitpicking just using your eample, which was close, but you missed one of the reasons we like shoulda type tests:: should_require_attributes :body, :message = /wtf/ makes you put validates_presence_of :body, :message = hey dude, wtf, you need a body! because we have a bunch of

Re: [rspec-users] validate_presence_of

2009-02-18 Thread Stephen Eley
On Wed, Feb 18, 2009 at 11:42 PM, Yi Wen hayafi...@gmail.com wrote: Without this syntax sugar, we still have to test validates_presence_of to make sure it's there and won't broken, right? Wrong. You don't have to test validates_presence_of. What matters, and therefore what you should test,

Re: [rspec-users] validate_presence_of

2009-02-18 Thread David Chelimsky
On Wed, Feb 18, 2009 at 11:31 PM, Stephen Eley sfe...@gmail.com wrote: On Wed, Feb 18, 2009 at 10:42 PM, Mark Wilden m...@mwilden.com wrote: On Wed, Feb 18, 2009 at 4:39 PM, Fernando Perez li...@ruby-forum.com wrote: What's the point in testing validates_presence_of for a model? To make sure

[rspec-users] validate_presence_of

2009-02-17 Thread Yi Wen
Hello, according to this post: http://blog.davidchelimsky.net/2009/1/13/rspec-1-1-12-is-released I should be able to write: describe User do it {should valdate_presence_of(:login)} end with rspec 1.1.12 But I got: NO NAME undefined method `valdate_presence_of' for

Re: [rspec-users] validate_presence_of

2009-02-17 Thread Yi Wen
Sorry for the spam, I relized there was a typo. It should be it {should validate_presence_of(:login)} It still didn't work On Tue, Feb 17, 2009 at 6:04 PM, Yi Wen hayafi...@gmail.com wrote: Hello, according to this post:

Re: [rspec-users] validate_presence_of

2009-02-17 Thread David Chelimsky
On Tue, Feb 17, 2009 at 6:25 PM, Yi Wen hayafi...@gmail.com wrote: Sorry for the spam, I relized there was a typo. It should be it {should validate_presence_of(:login)} It still didn't work Scrolling up a bit ... There are a few matcher libraries out there like

Re: [rspec-users] validate_presence_of

2009-02-17 Thread Tim Glen
according to this post: http://blog.davidchelimsky.net/2009/1/13/rspec-1-1-12-is-released I should be able to write: describe User do it {should valdate_presence_of(:login)} end with rspec 1.1.12 But I got: NO NAME undefined method `valdate_presence_of' for

Re: [rspec-users] validate_presence_of

2009-02-17 Thread Yi Wen
ah! sorry, my bad. Thanks! On Tue, Feb 17, 2009 at 6:56 PM, David Chelimsky dchelim...@gmail.comwrote: On Tue, Feb 17, 2009 at 6:25 PM, Yi Wen hayafi...@gmail.com wrote: Sorry for the spam, I relized there was a typo. It should be it {should validate_presence_of(:login)} It still

Re: [rspec-users] validate_presence_of

2009-02-17 Thread David Chelimsky
On Tue, Feb 17, 2009 at 8:42 PM, Yi Wen hayafi...@gmail.com wrote: ah! sorry, my bad. Thanks! No worries - I always just read the code first too :) On Tue, Feb 17, 2009 at 6:56 PM, David Chelimsky dchelim...@gmail.com wrote: On Tue, Feb 17, 2009 at 6:25 PM, Yi Wen hayafi...@gmail.com