Hi all, Can I test my rails model with cucumber? Or is this not what cucumber is used for? If it is, can anyone lead me to documentation on how to use cuke to test Rails model please. I have read the cuke wiki rails section, but I still can not understand how to use cuke to test my model. Many thanks for your help. -- Certified Scrum Master http://blog.scrum8.com | http://jobs.scrum8.com | http://twitter.com/scrum8
Cucumber is meant to be used for integration testing. You should use one of the unit test frameworks (rspec, shoulds, test::unit) to test your models specifically. --Tim Riendeau On Oct 13, 2009, at 9:02 AM, Joshua Partogi wrote:> > Hi all, > > Can I test my rails model with cucumber? Or is this not what cucumber > is used for? If it is, can anyone lead me to documentation on how to > use cuke to test Rails model please. I have read the cuke wiki rails > section, but I still can not understand how to use cuke to test my > model. > > Many thanks for your help. > > -- > Certified Scrum Master > http://blog.scrum8.com | http://jobs.scrum8.com | http://twitter.com/scrum8 > > >
Joshua Partogi wrote:> Hi all, > > Can I test my rails model with cucumber? Or is this not what cucumber > is used for? If it is, can anyone lead me to documentation on how to > use cuke to test Rails model please. I have read the cuke wiki rails > section, but I still can not understand how to use cuke to test my > model.I don''t see how this is a good use of Cucumber. Cucumber seems to be best for testing user interface.> > Many thanks for your help. > > -- > Certified Scrum Master > http://blog.scrum8.com | http://jobs.scrum8.com | > http://twitter.com/scrum8Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
Hi Marnen, On Oct 14, 12:55 am, Marnen Laibow-Koser <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Joshua Partogi wrote: > > Hi all, > > > Can I test my rails model with cucumber? Or is this not what cucumber > > is used for? If it is, can anyone lead me to documentation on how to > > use cuke to test Rails model please. I have read the cuke wiki rails > > section, but I still can not understand how to use cuke to test my > > model. > > I don''t see how this is a good use of Cucumber. Cucumber seems to be > best for testing user interface.Thank you very much for the insight. Now I know that I shouldn''t waste time trying to figure out to test my model with cuke. Kind regards, -- Certified Scrum Master http://blog.scrum8.com | http://jobs.scrum8.com | http://twitter.com/scrum8
IMHO Cucumber is an excellent tool to use to on top of rspec to do unit testing. Dear Joshua, Doing unit tests with cucumber has not yet been approved as a best practice, but don''t let that stop you from experimenting. Cucumber is no substitute for rspec , it''s a complement, a way of writing tests in a more natural language, using rspec''s power underneath. Thus, it is not only suited for integration tests, but for view test, database tests, and anything else that you can think of. Jim Weirich has started an implementation of unit test with cucumber. http://github.com/jimweirich/Given I recommend you simply write in cucumber what you need to test, and figure out how to make it reusable to other models. A good friend has started an implementation of reusable steps in Spanish, soon it will be available in English too. http://github.com/nando/mundo-pepino All the best! Raimond Garcia -- Posted via http://www.ruby-forum.com/.
Joshua Partogi wrote:> Hi all, > > Can I test my rails model with cucumber? Or is this not what cucumber > is used for? If it is, can anyone lead me to documentation on how to > use cuke to test Rails model please. I have read the cuke wiki rails > section, but I still can not understand how to use cuke to test my > model. > > Many thanks for your help. > > -- > Certified Scrum Master > http://blog.scrum8.com | http://jobs.scrum8.com | > http://twitter.com/scrum8Actually, I agree with Tim Riendeau, cucumber is meant as a Business Readable Behavior Description language, but I don''t like non-answer answers. It absolutely CAN be used to test models, although it is not the best option, currently IMHO the best choice at least for Rails models, is Rspec+Shoulda alone, but here''s an exmaple of one way to do it (on top of rspec and shoulda): http://www.pastie.org/656364 I hope it answers your question, although is extremely verbose for a model unit test, where a simple rspec test would suffice and be much more expressive for a programmer, after all unit tests are not meant to be seen or used by customers, in that area, Cucumber is the way to go right now. -- Posted via http://www.ruby-forum.com/.