Rails helper testing cheatsheetEdit
Tools
- RSpec 2 (spec framework)
 
- RR (mocking library)
 
- Factory Girl (object mother library)
 
- Rails 3 (application framework)
 
Mocking and stubbing
Although helper methods are mixed into the example group itself:
describe FooHelper do
  describe '#funky_method' do
    it 'returns true' do
      funky_method.should be_true
    end
  end
end
If you need to set up mock expectations you will need to use the explicit helper instance that is available inside example groups:
it 'delegates to #foo_method' do
  mock(helper).foo_method
  helper.funky_method
end