1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
ENV['RAILS_ENV'] = 'test'
$:.unshift File.expand_path('../../lib', __FILE__)
# require 'rspec/mocks'
require 'minitest/mock'
require 'minitest/autorun'
require 'rabl-rails'
require 'plist'
require 'action_dispatch/http/mime_type'
require 'action_view'
if RUBY_ENGINE == 'jruby'
require 'nokogiri'
elsif RUBY_ENGINE == 'ruby'
require 'libxml'
end
ActionView::Template.register_template_handler :rabl, RablRails::Handlers::Rabl
module Configurable
def with_configuration(key, value)
accessor = "#{key}="
old_value = RablRails.configuration.send(key)
RablRails.configuration.send(accessor, value)
yield
ensure
RablRails.configuration.send(accessor, old_value)
end
end
Minitest::Test.send(:include, Configurable)
module Rails
def self.cache
end
end
module ActionController
module Base
def self.perform_caching
false
end
end
end
class Context
class LookupContext
def initialize(format)
@format = format
end
def formats
[@format]
end
end
attr_writer :virtual_path
attr_reader :lookup_context
def initialize(format = :json)
@_assigns = {}
@virtual_path = nil
@lookup_context = LookupContext.new(format)
end
def assigns
@_assigns
end
def params
{}
end
def context_method
end
end
class User
attr_accessor :id, :name
def initialize(id = nil, name = nil)
@id = id
@name = name
end
end
|