Test rails model with Cucumber?

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.

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

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/scrum8

Best,

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

Actually, 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.