test_helper.rb 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. require 'rubygems'
  2. require 'bundler'
  3. Bundler.setup
  4. require 'test/unit'
  5. require 'mocha'
  6. # Configure Rails
  7. ENV["RAILS_ENV"] = "test"
  8. require 'active_support'
  9. require 'action_controller'
  10. require 'active_model'
  11. require 'rails/railtie'
  12. $:.unshift File.expand_path('../../lib', __FILE__)
  13. require 'responders'
  14. I18n.load_path << File.expand_path('../locales/en.yml', __FILE__)
  15. I18n.reload!
  16. Responders::Routes = ActionDispatch::Routing::RouteSet.new
  17. Responders::Routes.draw do
  18. match '/admin/:action', :controller => "admin/addresses"
  19. match '/:controller(/:action(/:id))'
  20. end
  21. class ApplicationController < ActionController::Base
  22. include Responders::Routes.url_helpers
  23. self.view_paths = File.join(File.dirname(__FILE__), 'views')
  24. respond_to :html, :xml
  25. end
  26. class ActiveSupport::TestCase
  27. setup do
  28. @routes = Responders::Routes
  29. end
  30. end
  31. class Model
  32. include ActiveModel::Conversion
  33. include ActiveModel::Validations
  34. attr_accessor :persisted, :updated_at
  35. alias :persisted? :persisted
  36. def persisted?
  37. @persisted
  38. end
  39. def to_xml(*args)
  40. "<xml />"
  41. end
  42. def initialize(updated_at=nil)
  43. @persisted = true
  44. self.updated_at = updated_at
  45. end
  46. end
  47. class Address < Model
  48. end
  49. class User < Model
  50. end