All, Is there away to test a collection with rspec 1.3? I''ve seen Jim Weirich''s rspec-collection, but it requires rspec 2.0. I''d like to go to rspec 2.0, but have another dependency that will not work with rspec 2.0. I may have to bite the bullet and see if I can update that dependency to work wit rspec 2 and go to rspec 2. What I''d like to do is: describe "blah" do subject { a-collection } subjects.each do |s| subject { s } it { should pass a test } end end BTW: Using this to test a 3rd party app. Probably not the right tool, but I like ruby and its tools. So, I have access to the app db and send a message to the app via a service and need to see if things changed the way I expected. I''d love to actually test without doing it that way, but it would require Jruby to be able to mock java objects and return those mocks in the java. If that was possible than I''d test the java directly using jruby and rspec. I have tested some java with rspec, but those java classes don''t involve db calls or other communications that I''d like to mock. If the java class involves any of those communications, I just have to write an integration test with fixtures, sending the data and then testing results. Any ideas other than find a java testing tool, because I just try to avoid java but can''t since it is how I have to pay the bills. :( Thanks, GregD
Have you looked at JTestR? I''m not sure how active it is being developed and it might not do what you are looking for... but it might be worth a shot. jay On Fri, Feb 11, 2011 at 11:28 AM, GregD <gditrick at fuse.net> wrote:> All, > > Is there away to test a collection with rspec 1.3? ?I''ve seen Jim > Weirich''s rspec-collection, but it requires rspec 2.0. ?I''d like to go > to rspec 2.0, but have another dependency that will not work with > rspec 2.0. ?I may have to bite the bullet and see if I can update that > dependency to work wit rspec 2 and go to rspec 2. > > What I''d like to do is: > > describe "blah" do > ?subject { a-collection } > > ?subjects.each do |s| > ? ? ?subject { s } > > ? ? ?it { should pass a test } > ?end > end > > BTW: ?Using this to test a 3rd party app. ?Probably not the right > tool, but I like ruby and its tools. ?So, I have access to the app db > and send a message to the app via a service and need to see if things > changed the way I expected. ?I''d love to actually test without doing > it that way, but it would require Jruby to be able to mock java > objects and return those mocks in the java. ?If that was possible than > I''d test the java directly using jruby and rspec. ?I have tested some > java with rspec, but those java classes don''t involve db calls or > other communications that I''d like to mock. ?If the java class > involves any of those communications, I just have to write an > integration test with fixtures, sending the data and then testing > results. > > Any ideas other than find a java testing tool, because I just try to > avoid java but can''t since it is how I have to pay the bills. ?:( > > > Thanks, > > GregD > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
---- Jay McGaffigan <hooligan495 at gmail.com> wrote:> Have you looked at JTestR? > I''m not sure how active it is being developed and it might not do what > you are looking for... but it might be worth a shot. >Yes. I can pretty much do all of what jtestr is doing. But, I believe that when you mock a java class that mock can not be returned in another java class that you are testing. So, if I have a java class that creates a java object of a DB object, I don''t think I can mock that java DB object and expect the java that I''m testing to use that mock. I don''t think Jtestr can do that, because I don''t believe jruby is able to that. I maybe wrong, but jtestr examples only show simple mocking of say a hash. I can do that. But, if I need to mock the java hash object that is used in a java class, it will not return that mock to the java class I am testing. Again I might be wrong about jtestr. Maybe it can do that. I know I cannot just using jruby. I have tried with db objects and pinged Nick Sieger who replied it was not possible.