/usr/lib/ruby/1.8/innate/mock.rb is in libinnate-ruby1.8 2010.07-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | module Innate
module Mock
HTTP_METHODS = %w[ CONNECT DELETE GET HEAD OPTIONS POST PUT TRACE ]
OPTIONS = {:app => Innate}
HTTP_METHODS.each do |method|
(class << self; self; end).
send(:define_method, method.downcase){|*args|
mock(method, *args)
}
end
def self.mock(method, *args)
mock_request.request(method, *args)
end
def self.mock_request(app = OPTIONS[:app])
Rack::MockRequest.new(app)
end
def self.session
yield Session.new
end
class Session
attr_accessor :cookie
def initialize
@cookie = nil
end
HTTP_METHODS.each do |method|
define_method(method.downcase){|*args|
extract_cookie(method, *args)
}
end
def extract_cookie(method, path, hash = {})
hash['HTTP_COOKIE'] ||= @cookie if @cookie
response = Mock::mock(method, path, hash)
cookie = response['Set-Cookie']
@cookie = cookie if cookie
response
end
end
end
end
|