Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
oops forgot to undo this fubar optimization on the mongo side
- Loading branch information
Showing
1 changed file
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3d8004e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check out my code at https://github.com/kristianmandrup/stringex/blob/master/test_mongoid/acts_as_url_mongoid_test.rb
Start the mongoid database
$ mongod
All there is to it!
I don't see why adding
acts_as_url
directly toMongoid::Document
as a class method that in turn also includesStringex::ActsAsUrl
is such a bad idea? This is very common practice in the Mongoid world, especially with this kind of gem, where you would expect, that if you include and use this gem, you pretty much want to use the "url as name" strategy for most if not all of your models...Just the way I see it and how I would use it. Check out any gem that supports Mongoid and you will quickly see how to setup the test suite.
BTW: Doesn't almost everybody use rspec by now? The test-unit (and family) looks so ancient to me.... so old school 2005 (and before) IMO, closely mirroring on Unit Tests for Java. But hey, do whatever you feel comfortable and productive with ;)
Why use
rake test
at all?3d8004e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
including ActsAsUrl isn't as easy with Mongoid [or Datamapper, i'm guessing] because of this: https://gist.github.com/9f1e652a8199376c1859 when you include a class/module that has extensions/inclusions, those methods don't show up on the newest object. i can hack around with aliasing to get include Mongoid::Document to reinclude the Stringex features easy enough but i wasn't sure how magic-friendly Mongoid users are. with all the data definitions in the models, i figured there's a non-zero chance that those users may want to have to manually include things or something. but since you mentioned it as a weird thing, that confirms my impulse to just make it work for the end user without them having to get so involved.
using rspec adds another dependency. that's why i never use it on oss stuff. what's fubar is that add_development_dependency adds regular dependencies for any gem version under 1.2.0 basically, which includes lot of ppl. i hate unnecessary dependencies so i just use test::unit because it's in the standard lib. i used to prefer rspec but now tbh it doesn't matter. there's little you can do with one testing framework that you can't do in another [with perhaps more work]. tools are tools.