How do I test helpers in Rails?

后端 未结 5 1483
北海茫月
北海茫月 2021-02-03 18:24

I\'m trying to build some unit tests for testing my Rails helpers, but I can never remember how to access them. Annoying. Suggestions?

5条回答
  •  孤城傲影
    2021-02-03 19:07

    You can do the same in RSpec as:

    require File.dirname(__FILE__) + '/../spec_helper'
    
    describe FoosHelper do
    
      it "should do something" do
        helper.some_helper_method.should == @something
      end
    
    end
    

提交回复
热议问题