forked from jfairbairn/em-net-http
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspec_helper.rb
More file actions
39 lines (33 loc) · 973 Bytes
/
spec_helper.rb
File metadata and controls
39 lines (33 loc) · 973 Bytes
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
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'em-net-http'
require 'time'
require 'rspec'
require 'mimic'
RSpec.configure do |config|
config.before(:all) do
Mimic.mimic do
Net::HTTPResponse::CODE_TO_OBJ.each do |code, klass|
get("/code/#{code}").returning("#{code} #{klass.name}", code.to_i, {})
end
get('/hello').returning('Hello World!', 200, {'Content-Type'=>'text/plain'})
class BigImageResponse
def each
::File.open('spec/image.jpg', "rb") { |file|
while part = file.read(8192)
yield part
end
}
end
end
resp = BigImageResponse.new
get('/image').returning(resp, 200, {"Content-Type" => 'image/jpeg'})
post('/testpost') do
"You said #{request.body.read}."
end
end
end
config.after(:all) do
Mimic.cleanup!
end
end