Wolfmans Howlings

A programmers Blog about Programming solutions and a few other issues

XPath matchers for rspec

Posted by Jim Morris on Wed Jan 02 13:32:50 -0800 2008

I've been working on a project that is mostly Java for the last many months, so haven't had much Ruby or Rails stuff to share.

However one thing I found when working on my tests in Java was an xpath matcher for JUnit 4.0 using the Hamcrest libraries.

... Show more ...

Posted in Rails,RSpec  |  Tags rspec,xpath,matcher  |  5 comments

RSpec testing all actions of a controller

Posted by Jim Morris on Sat Jul 28 14:23:07 -0700 2007

A pattern I find very helpful is to find all the actions in a controller and apply a test to all those actions.

For instance this is useful for automatically testing all actions are protected from unauthorized access when using a login system.

... Show more ...

Posted in Rails,RSpec  |  Tags rails,rspec,controllers  |  14 comments

Using RSpec to test HAML helpers

Posted by Jim Morris on Sat Jul 14 16:44:33 -0700 2007

UPDATED for HAML 2.0 and RSpec 1.1.5 - Changed open to haml_tag, prefix helper. to all rspec calls...

The most recent release of HAML introduced a neat feature that allows you to use HAML-like syntax in your helpers to generate HTML HAML#haml_tag.

... Show more ...

Posted in HAML,Rails,RSpec  |  Tags test,haml,rspec,helpers  |  9 comments

RSpec testing views for escaped HTML

Posted by Jim Morris on Fri Jul 06 18:22:57 -0700 2007

For my social networking site snowdogsr.us I decided to escape all user input that gets displayed. I know people like to trick out their profiles with HTML but I want to avoid the various hacks that it allows.

So thinking I had done a good job of using h everywhere I output user input fields, I decided to see if I could actually test this with RSpec view tests.

... Show more ...

Posted in Rails,RSpec  |  Tags rails,rspec,escapinghtml  |  4 comments