Skip to content

Instantly share code, notes, and snippets.

@djanowski
Created January 8, 2009 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djanowski/44688 to your computer and use it in GitHub Desktop.
Save djanowski/44688 to your computer and use it in GitHub Desktop.
# class TagsHelperTest < Test::Unit::TestCase
# helper 'app/helpers/tags'
#
# def test_tag
# assert_equal "<div></div>", helper.tag(:div)
# end
# end
require 'haml/engine'
module TestingHelpers
def self.included(base)
class << base
def helper(*path)
path[-1] = "#{path[-1]}.rb"
load root_path(*path)
end
end
end
def helper
@helper ||= HelperContext.new
end
class HelperContext
include Haml::Helpers
def initialize
init_haml_helpers
end
end
end
def helpers(&b)
TestingHelpers::HelperContext.class_eval(&b)
Sinatra::EventContext.class_eval(&b)
end
Test::Unit::TestCase.send(:include, TestingHelpers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment