Question

I am trying to get the whole setup working with Autotest/Growl/Shoulda on my Mac to test a gem I'm working on for Authlogic. I've used RSpec in the past quite a bit but would like to switch to Shoulda.

This gem is going to work with Rails, but others gems I've made are just plain old ruby libraries with no dependencies on Rails modules. What's the recommended way to test rubygems?

ZenTest seems to be focused largely on Rails, as I have yet to find a gem that makes it so calling autotest automagically runs all my TestUnit tests no matter if I'm using Rails, Sinatra, or just making a gem.

Question is, what is your setup/workflow for running tests on gems you are building? Do you have any resources that would help me out?

Or a more specific, testable question: How do I run the test suite for Paperclip or Authlogic with Autotest?

I've been using these as resources so far:

Thanks so much. Want to make testing a core part of my workflow.

Was it helpful?

Solution

Autotest (and ZenTest in general) isn't focused on Rails. Indeed, the rails code was extracted out into a separate gem. However it does, by default, expect the files in your project folder to adhere to a certain layout and file naming convention. For example:

.
|-- lib
|   `-- my_library.rb
`-- test
    |-- test_helper.rb
    `-- test_mylibrary.rb

I have just posted a small project that works with Shoulda and is testable with Autotest.

If you would like to deviate from these conventions (e.g by suffixing rather than prefixing "test" onto your test code file names) than you can provide a .autotest file that uses an API provided by autotest to use your own scheme. There's a pretty complete example in the RSpec project itself.

OTHER TIPS

I was having a similar problem, so I thought I would share my solution for posterity.

I have a project tree with a large number of files. I knew about autotest's convention of looking for mappings between files in lib/ and files in test/. But I made the mistake of thinking this meant that autotest just looked for files in lib/ and test/ by default. Not so. If you don't tell it to look for specific files or directories, it will scan the entire tree. This may not be a good thing if your tree has over 100,000 files in it. :-)

So I was running autotest and seeing no results, thinking it wasn't finding files, when really it was finding too many files and trying to churn through them all without giving any feedback. By moving the largest directory out of the main tree, I got autotest to respond.

(I may have to learn to hack on the autotest config files.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top