I''m using Shoulda. After copying the code here.... .... http://joshuaclayton.github.com/code/2009/07/14/should-act-as-list.html.... into my test_helper file so I can test acts_as_list, I came across issues. For one I realized I had to get rid of the _ between the "should" and "have" in past cases, but here, I get this error when I run my unit test: ./test/test_helper.rb:28:in `should_act_as_list'': undefined method `have_instance_methods'' for ArticleTest:Class (NoMethodError) What''s the Rails 3 way to test acts_as_list with Shoulda? -- 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-22 17:45 UTC
Re: Shoulda issue: no more "should have_instance_methods" ?
daze wrote in post #969974:> I''m using Shoulda. > After copying the code here.... > .... > http://joshuaclayton.github.com/code/2009/07/14/should-act-as-list.html.... > into my test_helper file so I can test acts_as_list, I came across > issues. For one I realized I had to get rid of the _ between the > "should" and "have" in past cases, but here, I get this error when I > run my unit test: > > ./test/test_helper.rb:28:in `should_act_as_list'': undefined method > `have_instance_methods'' for ArticleTest:Class (NoMethodError) > > What''s the Rails 3 way to test acts_as_list with Shoulda?Well, that whole way of testing is wrongheaded and always was. You shouldn''t be testing for implementation details like instance methods; rather, you should be testing for behavior. (Although I sometimes test for acts_as_list by making sure the appropriate module was included into the class.) Usually, if you''re trying to poke into internals, something is wrong with your tests. The object being tested should generally be considered a black box. (BTW, consider RSpec instead of Shoulda. I believe even Shoulda''s own developers have switched.) 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.
David Kahn
2010-Dec-22 17:53 UTC
Re: Re: Shoulda issue: no more "should have_instance_methods" ?
On Wed, Dec 22, 2010 at 11:45 AM, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> daze wrote in post #969974: > > I''m using Shoulda. > > After copying the code here.... > > .... > > > http://joshuaclayton.github.com/code/2009/07/14/should-act-as-list.html.. > .. > > into my test_helper file so I can test acts_as_list, I came across > > issues. For one I realized I had to get rid of the _ between the > > "should" and "have" in past cases, but here, I get this error when I > > run my unit test: > > > > ./test/test_helper.rb:28:in `should_act_as_list'': undefined method > > `have_instance_methods'' for ArticleTest:Class (NoMethodError) > > > > What''s the Rails 3 way to test acts_as_list with Shoulda? > > Well, that whole way of testing is wrongheaded and always was. You > shouldn''t be testing for implementation details like instance methods; > rather, you should be testing for behavior. (Although I sometimes test > for acts_as_list by making sure the appropriate module was included into > the class.) > > Usually, if you''re trying to poke into internals, something is wrong > with your tests. The object being tested should generally be considered > a black box. (BTW, consider RSpec instead of Shoulda. I believe even > Shoulda''s own developers have switched.) >From what I understand, Thoughtbot, the developers of Shoulda are using Rspec however are continuing to use and support the Shoulda helpers... as they make life easier than not using them.> > 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.
On Dec 22, 9:45 am, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Well, that whole way of testing is wrongheaded and always was. You > shouldn''t be testing for implementation details like instance methods; > rather, you should be testing for behavior. (Although I sometimes test > for acts_as_list by making sure the appropriate module was included into > the class.) > > Usually, if you''re trying to poke into internals, something is wrong > with your tests. The object being tested should generally be considered > a black box. (BTW, consider RSpec instead of Shoulda. I believe even > Shoulda''s own developers have switched.)Okay - so what exactly should I do regarding testing the acts_as_list gem? On Dec 22, 9:53 am, David Kahn <d...-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org> wrote:> From what I understand, Thoughtbot, the developers of Shoulda are using > Rspec however are continuing to use and support the Shoulda helpers... as > they make life easier than not using them.I will get rspec I guess. You can use rspec and shoulda together, right? -- 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.
Marnen Laibow-Koser
2010-Dec-22 21:33 UTC
Re: Shoulda issue: no more "should have_instance_methods" ?
daze wrote in post #970132:> On Dec 22, 9:45am, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> Well, that whole way of testing is wrongheaded and always was. You >> shouldn''t be testing for implementation details like instance methods; >> rather, you should be testing for behavior. (Although I sometimes test >> for acts_as_list by making sure the appropriate module was included into >> the class.) >> >> Usually, if you''re trying to poke into internals, something is wrong >> with your tests. The object being tested should generally be considered >> a black box. (BTW, consider RSpec instead of Shoulda. I believe even >> Shoulda''s own developers have switched.) > > Okay - so what exactly should I do regarding testing the acts_as_list > gem?As I said above, test behavior, or test that the one module (I think it''s Acts::somethingorother) got included in the appropriate class.> > On Dec 22, 9:53am, David Kahn <d...-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org> wrote: >> From what I understand, Thoughtbot, the developers of Shoulda are using >> Rspec however are continuing to use and support the Shoulda helpers... as >> they make life easier than not using them. > > I will get rspec I guess. You can use rspec and shoulda together, > right?I''m not sure, but I don''t understand why you''d want to. Shoulda is basically an RSpec knockoff. 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.
David Kahn
2010-Dec-22 22:01 UTC
Re: Re: Shoulda issue: no more "should have_instance_methods" ?
On Wed, Dec 22, 2010 at 3:33 PM, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> daze wrote in post #970132: > > On Dec 22, 9:45am, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > >> Well, that whole way of testing is wrongheaded and always was. You > >> shouldn''t be testing for implementation details like instance methods; > >> rather, you should be testing for behavior. (Although I sometimes test > >> for acts_as_list by making sure the appropriate module was included into > >> the class.) > >> > >> Usually, if you''re trying to poke into internals, something is wrong > >> with your tests. The object being tested should generally be considered > >> a black box. (BTW, consider RSpec instead of Shoulda. I believe even > >> Shoulda''s own developers have switched.) > > > > Okay - so what exactly should I do regarding testing the acts_as_list > > gem? > > As I said above, test behavior, or test that the one module (I think > it''s Acts::somethingorother) got included in the appropriate class. > > > > > On Dec 22, 9:53am, David Kahn <d...-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org> wrote: > >> From what I understand, Thoughtbot, the developers of Shoulda are using > >> Rspec however are continuing to use and support the Shoulda helpers... > as > >> they make life easier than not using them. > > > > I will get rspec I guess. You can use rspec and shoulda together, > > right? > > I''m not sure, but I don''t understand why you''d want to. Shoulda is > basically an RSpec knockoff. >...yes you can use Rspec with shoulda, in fact that is the intended use at this point as the Thoughtbot team say they are using Rspec. I think the matchers add value to rspec and to date no one has shown me how to do some of the same things that the shoulda matchers do in pure rspec w/o 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-/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.
Great, thanks! So in summary: 1) Use rspec and shoulda together, as the Thoughtbot team (which created shoulda) is saying they are using rspec 2) To test acts_as_list, test the behavior of it (or test the inclusion of that one module in the appropriate class) I don''t know what "that one module is" or how to test its inclusion in a class though... but otherwise thanks guys! -- 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.
Philip Hallstrom
2010-Dec-22 22:58 UTC
Re: Re: Shoulda issue: no more "should have_instance_methods" ?
> 2) To test acts_as_list, test the behavior of it (or test the > inclusion of that one module in the appropriate class) > > I don''t know what "that one module is" or how to test its inclusion in > a class though... but otherwise thanks guys!If it were me I wouldn''t test for the inclusion of the class. I''d test to the behavior only. Test that when you move an item around in the list the results are what you expect. That way when you decide to switch to "acts_as_list_on_steroids_fu" which implements the same behavior but adds all kinds of other goodies your tests will still pass and more importantly they pass for the right reason. -philip -- 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.
David Kahn
2010-Dec-23 00:11 UTC
Re: Re: Shoulda issue: no more "should have_instance_methods" ?
On Wed, Dec 22, 2010 at 4:38 PM, daze <dmonopoly10-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Great, thanks! > > So in summary: > > 1) Use rspec and shoulda together, as the Thoughtbot team (which > created shoulda) is saying they are using rspec >PS - I cant find the original but this looks like a republish of the Thoughtbot writup on the status of Shoulda: http://www.l-exp.com/m/feed/show/971486> 2) To test acts_as_list, test the behavior of it (or test the > inclusion of that one module in the appropriate class) > > I don''t know what "that one module is" or how to test its inclusion in > a class though... but otherwise thanks guys! > > -- > 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.