Test a helper class on Ruby On Rails


/ Published in: Rails
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.