On Wed, Dec 15, 2010 at 8:30 AM, Marnen Laibow-Koser <li...@ruby-forum.com>wrote:
> David Kahn wrote in post #968465: > > On Tue, Dec 14, 2010 at 4:26 PM, Marnen Laibow-Koser > > <li...@ruby-forum.com>wrote: > > > >> > fine. I tried placing "require 'shoulda'" in test helper to no avail, > >> > but > >> > when I run the debugger and type Shoulda, the object is found. > >> > >> What's the point of using RSpec and Shoulda together? I thought all > >> Shoulda did was give an RSpec-like syntax to Test::Unit. > >> > >> Come to think of it, what's the point of using Shoulda (instead of > >> RSpec) at all? > >> > > > > Well, > > I like that I can include it in Test/Unit. > > Not really into the .should and the argument that it makes tests > > readable... > > So you're saying you don't think that > value.should == 3 > is more readable than > assert_equal 3, value > ? > > First of all, I can't imagine how the English-like syntax *isn't* the > more readable; second, if that's so, then why are you using Shoulda at > all. > > > just does not feel necessary to me. > > I assure you, it is necessary. The assert_ syntax of Test::Unit lends > itself to writing unreadable, implementation-focused tests. RSpec-style > "should" syntax encourages you to think about behavior, as well as > keeping the code more readable. > > I really don't know why anyone would voluntarily choose Test::Unit, > unless it be inertia. > > > I like the "should ....." vs "argument.should be_nil" or the like. Just > > reads better to me. > > I just looked up Shoulda's documentation to see the differences. I > don't see how you can seriously claim that Shoulda reads better than > RSpec. The use of the word "should" simply appears to be poorly copied > from RSpec without serious thought about the semantics -- as evidenced > by the fact that "should" can't begin an assertion in English or RSpec, > but can in Shoulda. Yuck! > > > > One less DSL to use (arguably) > > Argument lost. It's still a DSL, just a poorly designed one. So use a > better designed one. That means RSpec. > > > One of the things I really like in Shoulda that I have seen so far are > > the > > matchers... things like: > > > > it { should belong_to(:contact) } > > it { should have_many(:addresses) } > > it { should validate_presence_of(:address) } > > it { should allow_value('55416').for(:zip) } > > it { should_not allow_value('554316').for(:zip) } > > > > I think these are very cool... and save a lot of time. This is what made > > me > > look into shoulda. > > Then IMHO you are using Shoulda for entirely the wrong reasons. > > > Does Rspec have these/similar? > > RSpec has many similar methods. Not the ones you quoted above, exactly, > but those would be easy to write. > And where would I learn about them? Perhaps I missed it but even in the Rspec book I dont see any mention of such coolness. I know I can use shoulda with rspec and get its helpers but if you know some specifics that Rspec does this as concisely --- like validation and associations if you can point me in the right direction I would appreciate it... that way I will forget about shoulda. > > > I think the documentation is better for Shoulda, not that this means > > everything but is important. > > Haven't looked at the Shoulda docs in detail, so can't comment. > > > And Shoulda gives me what I consider the best feature of Rspec - the > > grouping syntax (describe... it ....).... that is the one thing to date > > that > > I felt I would miss of empirical value by not using Rspec. > > > > So why not? What am I missing? > > Almost everything, apparently. :) Shoulda seems to me to be a cheap > knockoff of RSpec with less readable and less well thought out syntax, > and improper semantics. Why use the cheap knockoff when you could use > the real thing? > > Have you even tried RSpec? > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > mar...@marnen.org > > Sent from my iPhone > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-t...@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com<rubyonrails-talk%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.