Curious if anyone has Shoulda working with test/unit in Rails 3. I tried it this morning and am getting: test/unit/practice_member_test.rb:4:in `<class:PracticeMemberTest>'': undefined method `context'' for PracticeMemberTest:Class (NoMethodError) Now, I have a Rails 3 project with Rspec including Shoulda also and it works 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. It it helps, here is my test: require ''test_helper'' class PracticeMemberTest < Test::Unit::TestCase context "practice member" do should "get global practice member count not including Demo Practice" do assert_equal PracticeMember.practice_members_global_count, 0 practice = Factory.create(:practice_one) practice_member = Factory.create(:practice_member) practice_member.practice_id = practice.id practice_member.save practice_member = Factory.create(:practice_member) practice_member.practice_id = practice.id practice_member.save assert_equal PracticeMember.practice_members_global_count, 2 end end end -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
David Kahn wrote in post #968428:> Curious if anyone has Shoulda working with test/unit in Rails 3. I tried > it > this morning and am getting: > > test/unit/practice_member_test.rb:4:in `<class:PracticeMemberTest>'': > undefined method `context'' for PracticeMemberTest:Class (NoMethodError) > > Now, I have a Rails 3 project with Rspec including Shoulda also and it > works > 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? Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, Dec 14, 2010 at 4:26 PM, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> David Kahn wrote in post #968428: > > Curious if anyone has Shoulda working with test/unit in Rails 3. I tried > > it > > this morning and am getting: > > > > test/unit/practice_member_test.rb:4:in `<class:PracticeMemberTest>'': > > undefined method `context'' for PracticeMemberTest:Class (NoMethodError) > > > > Now, I have a Rails 3 project with Rspec including Shoulda also and it > > works > > 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... just does not feel necessary to me. I like the "should ....." vs "argument.should be_nil" or the like. Just reads better to me. One less DSL to use (arguably) 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. Does Rspec have these/similar? I think the documentation is better for Shoulda, not that this means everything but is important. 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?> > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > > -- > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
David Kahn wrote in post #968465:> On Tue, Dec 14, 2010 at 4:26 PM, Marnen Laibow-Koser > <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>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.> 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 marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, Dec 14, 2010 at 6:17 PM, David Kahn <dk-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org>wrote:> Curious if anyone has Shoulda working with test/unit in Rails 3. I tried it > this morning and am getting: > > test/unit/practice_member_test.rb:4:in `<class:PracticeMemberTest>'': > undefined method `context'' for PracticeMemberTest:Class (NoMethodError) > > Now, I have a Rails 3 project with Rspec including Shoulda also and it > works 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. > > > It it helps, here is my test: > > require ''test_helper'' > > class PracticeMemberTest < Test::Unit::TestCase > context "practice member" do > should "get global practice member count not including Demo Practice" > do > assert_equal PracticeMember.practice_members_global_count, 0 > > practice = Factory.create(:practice_one) > > practice_member = Factory.create(:practice_member) > practice_member.practice_id = practice.id > practice_member.save > practice_member = Factory.create(:practice_member) > practice_member.practice_id = practice.id > practice_member.save > > assert_equal PracticeMember.practice_members_global_count, 2 > end > end > end > >the whole context syntax is been deprecated in favor of a pure rspec like syntax. http://robots.thoughtbot.com/post/701863189/shoulda-rails3-and-beyond -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
from thoughbot ''We’re committed to using RSpec, so we don’t want to spend time adding features to Shoulda’s context framework. '' -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, Dec 15, 2010 at 8:51 AM, radhames brito <rbritom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > from thoughbot > > ''We’re committed to using RSpec, so we don’t want to spend time adding > features to Shoulda’s context framework. '' >Thanks... I found and read the article the quote came from - http://robots.thoughtbot.com/post/701863189/shoulda-rails3-and-beyond - which pretty much puts the nail in the coffin :)> -- > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, Dec 15, 2010 at 8:30 AM, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> David Kahn wrote in post #968465: > > On Tue, Dec 14, 2010 at 4:26 PM, Marnen Laibow-Koser > > <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>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 > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Dec-16 19:00 UTC
Re: Re: Re: Using Shoulda with Test/Unit in Rails 3
David Kahn wrote in post #968911:> On Wed, Dec 15, 2010 at 8:30 AM, Marnen Laibow-Koser > <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote: > >> >> >> value.should == 3 >> I assure you, it is necessary. The assert_ syntax of Test::Unit lends >> I just looked up Shoulda''s documentation to see the differences. I >> better designed one. That means RSpec. >> > >> > 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.Learn about what coolness? It''s not clear from your quotation.> 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...RSpec doesn''t have the canned validation and association matchers that Shoulda does, but they''re pretty easy to write for yourself if you want to. Some of my stuff on Github should give you ideas...reflect_on_association is *very* useful.> that way I will > forget > about shoulda.Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.