Obsidian - It's metastable
April 7th, 2008
I recently released a new gem into the rubyworld. It is a collection of useful code that I use everyday in every app i write. It will range from testing code to useful ruby core extensions and libraries. The relevance team will be contributing to this gem regularly and plan to do at least one release a week to the code. The first library that has been added is the model update tracker.
This library allows you to functionally test updates to models with clearer and more focused intent.
It forces you to have a better understanding of how your Objects interact and let's you demonstrate
that knowledge by putting it in your tests. For example instead of writing a test like so
you would write your test like so
Now if an asset really created multiple other objects such as an asset owner and a location the above
test would fail stating that it expected more to happen. This is where you excercise your deep domain
knowledge muscles and make your new obsidian powered test pass.
You have just done youself a great service. If for some reason you change code that affects your
object model and things fall out of place this test will catch that regression error where the original
assert_difference may not. There are also a whole host of other methods you can use with model update
tracker that provide functionality for updates, deletes, and no_difference assertions.
* assert_models_created(models)
* assert_models_updated(models)
* assert_models_destroyed(models)
* assert_no_models_created
* assert_no_models_destroyed
* assert_no_models_updated
You can install Obsidian via rubyforge.
1 2 3 4 |
assert_difference Asset :count do post :create, :asset => {} end |
1 2 3 4 |
assert_models_created(Asset) do post :create, :asset => {} end |
1 2 3 4 |
assert_models_saved(Asset, AssetOwner, Location) do post: create, :asset => {} end |
* assert_models_created(models)
* assert_models_updated(models)
* assert_models_destroyed(models)
* assert_no_models_created
* assert_no_models_destroyed
* assert_no_models_updated
You can install Obsidian via rubyforge.
sudo gem install obsidian
If you want to "git" the source directly you can grab it over at http://github.com/relevance/obsidian/tree/master/README.txt



Sorry, comments are closed for this article.