Posted By

nflamel on 01/15/10


Tagged

test rails helper


Versions (?)

Test a helper class on Ruby On Rails


 / Published in: Rails
 

This is the code I use when I want to test a helper. It uses Factory Girl and Shoulda, but they're not needed to make it work.

  1. require File.dirname(__FILE__) + '/../test_helper'
  2. require 'action_view/test_case'
  3.  
  4. class MyHelperTest < ActionView::TestCase
  5.  
  6. include MyHelper
  7.  
  8. context 'a helper in some context' do
  9. setup do
  10. Factory(:some_object)
  11. end
  12.  
  13. should 'assert this test' do
  14. assert_some_helper_function_works
  15. end
  16. end
  17. end

Report this snippet  

You need to login to post a comment.