Can't access image_tag from helper module-Collection of common programming errors

I would like to test the following helper module function:

module UploadsHelper

  def custom_img_tag(upload, width, height, id)
     if width > Upload::MAX_CROP_WIDTH
       image_tag(upload.photo.url(:original), :id => "box", :width => Upload::MAX_CROP_WIDTH, :height => (height*Upload::MAX_CROP_WIDTH/width).to_i)
     else
       image_tag(upload.photo.url(:original), :id => "box")
     end
   end

end

However when I run the following test:

describe UploadsController do
  include UploadsHelper
    describe "custom_img_tag(upload, width, height, id)" do
           before(:each) do
             @upload = Factory(:upload)
             geo = Paperclip::Geometry.from_file(@upload.photo.to_file(:original))
             @width   = geo.width
             @height  = geo.height
           end

       it "should return the original image tag for an image that is not wider than  MAX_CROP_WIDTH" do
         #custom_img_tag(@upload,@width, @heigth, "cropbox" ).should == ''
       end
     end

I get the following error:

Failure/Error: custom_img_tag(@upload,@width, @heigth, "cropbox" ).should == ''
     NoMethodError:
       You have a nil object when you didn't expect it!

Why do I get this error and how can I test this method?

Update: I added the following to the spec test file:

include ActionView::Helpers 

Which produces the following error:

NameError:
       undefined local variable or method `config' for #

Originally posted 2013-11-09 21:07:47.