Convert shoulda to a gem
Reported by Tammer Saleh | July 16th, 2008 @ 12:40 PM
Ever since the move to git, the gem has fallen behind in development. What I'd like to do is change the plugin into a gem, now that rails has much better gem support all around.
Comments and changes to this ticket
-
Nathaniel Bibler August 30th, 2008 @ 10:10 PM
- Agreed. Especially with the Rails config.gem support, it'd be nice to have this available as a GitHub gem.
-
Josh Nichols September 12th, 2008 @ 02:05 PM
I've made a branch for this: http://github.com/technicalpickl...
Some notes about the changes:
- Created lib/shoulda/rails.rb, which handles loading shoulda, and the rails macros. init.rb now requires this.
- Moved tasks to lib/shoulda/tasks, and added lib/shoulda/tasks.rb which automatically loads those tasks. Added tasks/shoulda.rake which requires 'shoulda/tasks' for backwards compatibility.
- Uses echoe for gem generation. I'm actually using my own fork of it, which supports generating shoulda.gemspec in ruby format, which GitHub knows and loves. I haven't been able to get Evan to merge this yet though.
Usage in non-rails, add to test/helper.rb:
require 'shoulda'If you happen to be using activerecord too, you can just do:
require 'shoulda/active_record'Usage in rails app, as plugin: the same as it was.
Usage in a rails app, as a gem, add to config/environment.rb:
config.gem 'shoulda', :lib => 'shoulda/rails'And to Rakefile:
require 'shoulda/tasks'The last part is necessary if you want the rake tasks. Rails's gem support isn't smart enough to load tasks from a gem yet, but there's a ticket open here
This whole process was made a lot easier to the recent refactorings Ryan added to move isolate the shoulda core from the macros for activerecord, actioncontroller, and actionmailer.
-
Josh Nichols September 12th, 2008 @ 02:29 PM
Forgot to commit/push a few changes. Should be up to date now.
-
Ryan McGeary September 14th, 2008 @ 12:24 AM
Josh and I just chatted. I have a concern with depending on the technicalpickles-echoe fork. I really like the idea of being able to auto-generate the gemspec for GitHub usage, but I'm worried about relying on a "non-standard" echoe fork.
Tammer, I noticed the typical thoughtbot gem doesn't depend on hoe or echoe. Would you like Shoulda to follow a similar pattern as factory_girl, paperclip, etc? (We can still get auto-generated gemspecs similar to how factory_girl does it)
I would also like to bring up the subject of versioning. Given that the old shoulda gem was on version 1.1.1, I think it would make sense to version this new gem at 2.0, but the shoulda plugin is versioned at 4.x which might cause confusion.
Tammer, Do you have any preference on version numbers?
-
Ryan McGeary September 14th, 2008 @ 08:23 AM
- → Assigned user changed from Tammer Saleh to Ryan McGeary
-
Ryan McGeary September 14th, 2008 @ 09:19 AM
I just cherry-picked Josh's organizational changes that were in his branch. [Note, I made some minor changes from the original commits, but I tried to tame git as best I could to give Josh credit]
Still to do is the actual gemification. To avoid the dependency on Josh's echoe -- which is a fork of echoe -- which is a fork of hoe, I'm planning on manually rolling a gemspec in the Rakefile similar to factory_girl for now.
I won't publish a GitHub gemspec file until after hearing from Tammer about versions and rubygems management.
-
Ryan McGeary September 14th, 2008 @ 11:16 AM
Recent gem changes committed:
rake gemaddedrake gemspecadded, but no GitHub gemspec was published yet- VERSION bumped to 1.99.0 pending a decision on that
-
Tammer Saleh September 14th, 2008 @ 11:25 AM
Yeah, I don't want to depend on a fork of echoe. If you can do without hoe/echoe altogether, then that would be great, but it's not a big deal. And I'm fine with whatever version you want to tag onto the gem. I'm not sure anyone other than the developers knows what version the plugin is currently.
-
Ryan McGeary September 14th, 2008 @ 11:29 AM
Tammer, Thanks. Currently, there's no dependency on hoe or echoe. I'll move forward with a 2.0 gem version and publish a GitHub gemspec later today.
-
Ryan McGeary September 14th, 2008 @ 12:24 PM
- → State changed from new to committed
Shoulda is now a gem. Well, at least a GitHub gem. I created a v2.0.0 tag.
Thanks for the help Josh.
-
Josh Nichols September 14th, 2008 @ 03:36 PM
Sweet!
One last thing to do is update the thoughtbot/shoulda repo to generate RubyGems. It's just a checkbox on the edit screen.
-
Dan Croak September 14th, 2008 @ 03:38 PM
To chime in, I've been manually changing the gemspec on various other Ruby projects on github. I haven't yet felt the need for auto-generating the gemspec with a tool like hoe/echoe and I like the lightness and explicitness of working directly with the gemspec.
Shoulda is a larger project than the other gems I've been involved with, however, so if there's strong sentiment for using hoe/echoe/etc., that's understandable.
-
Dan Croak September 14th, 2008 @ 03:39 PM
Also, I just turned on the RubyGem flag for shoulda in github.
-
Josh Nichols September 14th, 2008 @ 03:50 PM
The gem didn't actually build. Tried the debugging outlined on http://gems.github.com/:
>$ gem build shoulda.gemspec ERROR: While executing gem ... (Errno::ENOENT)
No such file or directory - test/rails_root/docI think we just need to run 'rake gemspec', and commit the updated gemspec.
-
Ryan McGeary September 14th, 2008 @ 08:15 PM
Sorry about the shoulda.gemspec github issue. I'm not sure what I did wrong before. Anyway, I reran
rake gemspec. It's now indexed by GitHub:$ sudo gem install thoughtbot-shoulda Successfully installed thoughtbot-shoulda-2.0.0 1 gem installed Installing ri documentation for thoughtbot-shoulda-2.0.0... Installing RDoc documentation for thoughtbot-shoulda-2.0.0... -
Sean Hussey September 15th, 2008 @ 02:06 PM
After installing the gem and freezing it to vendor/gems, I had to change the require in the Rakefile to reflect the new directory:
begin require 'vendor/gems/thoughtbot-shoulda-2.0.0/lib/shoulda/tasks' rescue LoadError end
This is an issue on systems where the shoulda gem is not installed globally.
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
