June 17, 2008

Rails Testing Notes

Okay, so there is a little ambiguity on a few things that shoulda and rails testing does for you:

XUnit Testing Frameworks 101:
-setup and teardown methods run before and after (respectively) EACH test method in a TestCase or shoulda context gets run, not once at the beginning of the context/TestCase and once at the end
They are tremendously useful for avoiding code duplication and making your test cases read easier.
(gleaned from reading and analyzing source)
-Rails unit and functional tests have a top level parent that extends Test::Unit::TestCase (part of the ruby standard lib)
http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit/TestCase.html
The core concept behind this testing methodology is here--also mentioned in the Programming Ruby book--understand it.

should_eventually "be the best dang program in the whole world" do

end
is how you specify test cases you haven't written yet, but you know you'll need them...
(gleaned from shoulda source code inspection)

Mocha/Mocking/Stubing
http://mocha.rubyforge.org/
- This mock/stub framework is awesome. Make sure you understand how to:
Object#stubs
Object#expects and all of the goodies in Mocha::Expectation (especially never, raises, once methods)
Class.any_instance

May 6, 2008

Tidy erb views

To make your html markup look pretty and be indented correctly within erb templates:
- Don't indent <% %> tags...(indent the code within those tags if you need to to):
- In other words--all <% -%> tags should start at the first column of the text file
- Its okay to indent <%= %> tags because they actually produce markup--they should render at the correct point.

CLA-OIT Rails Plugins


-umn_helper plugin that encapsulates any general tool that is universally useful--some of this functionality could likely be shared publicly too. Either way, its our top level plugin where we put handy rails tools that we use that could easily be shared without any special config

claoit_helper--this plugin constitutes more specific functionality where extra work would be required to share the plugin with others.

cla_data_center--this plugin should contain functionality specific to working with a CLA_DATA_CENTER database and tables within it where the app db is on the same db server as the CLA_DATA_CENTER.

auth_tokens -- A general purpose standardized pseudo role based authorization tool/methodology. Eventually we hope to release this publicly, but for now somewhat dependent on the cla_data_center and the umn_auth_filter.

Way to signify need for abstraction into plugin

When you come across code that should be abstracted and incorporated into a plugin, please mark a comment looking something like:

# TODO:auth_tokens move the :confirm => "are you sure?" to plugin
# TODO:cla_data_center
# TODO:umn_helper
# TODO:cla_helper

Basic format:
# TODO:plugin_name some notes

If in a view you can do:
<%
# TODO:plugin_name
-%>

For more general info on plugins see:

March 13, 2008

first post

Here we go...
I'm pretty sure this blog will be where I post nerd stuff I want to remember or share with others with links, who knows? Thats the good thing about blogging...