Permalink
Browse files

monkey patching and more to get the test suite working

  • Loading branch information...
rwilcox committed Oct 20, 2011
1 parent 60c11fa commit f56381a2d73a6a4a2b7ecc69aac5e16530d20084
Showing with 59 additions and 1 deletion.
  1. +16 −1 spec/delegate_presenter_base_spec.rb
  2. +32 −0 spec/samples/application_controller.rb
  3. +11 −0 spec/spec_helper.rb
@@ -2,12 +2,27 @@
require 'spec_helper'
# Pull in some fake helpers. In a Real Rails app these would be provided by Rails
# TODO: is there an easy way to test this closer to the actual behavior? By pulling in
# some of Rails, for example?
class FakeHelpers
def h(s)
s.gsub(/&/, "&amp;").gsub(/\"/, "&quot;").gsub(/>/, "&gt;").gsub(/</, "&lt;")
end
end
class FakeDelegatePresenter < DelegatePresenter::Base
def helpers
FakeHelpers.new
end
end
describe "DelegatePresenter::Base" do
describe "HTML building helpers" do
before do
@ap = DelegatePresenter::Base.new(1)
@ap = FakeDelegatePresenter.new(1)
end
it "handles HTML elements that should not be escaped" do
@@ -0,0 +1,32 @@
module ActionController
class Base
@@before_filters = []
def self.before_filters
@@before_filters
end
def self.before_filter(name)
@@before_filters << name
end
end
end
module ApplicationHelper
end
class ApplicationController < ActionController::Base
extend ActionView::Helpers
extend ActionView::Helpers::TagHelper
extend ActionView::Helpers::UrlHelper
extend ApplicationHelper
extend DelegatePresenter::ApplicationController
def view_context
@view_context ||= ApplicationController
end
def view_context=(input)
@view_context = input
end
end
View
@@ -0,0 +1,11 @@
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
require 'delegate_presenter'
require 'rubygems'
require 'bundler/setup'
Bundler.require
Dir.glob(['./spec/samples/*.rb', './spec/support/*.rb']) do |file|
require file
end

0 comments on commit f56381a

Please sign in to comment.