Testing with code injection

Most of my unit tests are too long and repetative, so I’m trying to
refactor them with some code injection.

What I want to do is something like in category_test:

def setup
@valid_values = {:name => [“frank”, “bob, “vfdsnj543543”]}
@invalid_values = {:name => [”", nil, “some absurdely long name that
won’t fit in the db”]}

I’m struggling to find a way to inject the necessary methods to test
all the possiblities. Doing anything with the base TestCase has
undesireable results.

I’d like know what other people have done to achieve this sort of

maybe rspec could help you, especially the stub and mock section


Look over heckle (http://seattlerb.rubyforge.org/heckle/).

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs