features/step_definitions/httpthumbnailer_steps.rb in httpthumbnailer-0.0.3 vs features/step_definitions/httpthumbnailer_steps.rb in httpthumbnailer-0.0.4
- old
+ new
@@ -1,5 +1,9 @@
+Given /httpthumbnailer log is empty/ do
+ (support_dir + 'server.log').truncate(0)
+end
+
Given /httpthumbnailer server is running at (.*)/ do |url|
start_server(
"bundle exec #{script('httpthumbnailer')}",
'/tmp/httpthumbnailer.pid',
support_dir + 'server.log',
@@ -18,14 +22,41 @@
Then /I will get multipart response/ do
@response.header['Content-Type'].first.should match /^multipart/
@response_multipart = MultipartResponse.new(@response.header['Content-Type'].last, @response.body)
end
+Then /response body will be CRLF endend lines like/ do |body|
+ @response.body.should match(body)
+ @response.body.each do |line|
+ line[-2,2].should == "\r\n"
+ end
+end
+
+Then /response body will be CRLF endend lines$/ do |body|
+ @response.body.should == body.gsub("\n", "\r\n") + "\r\n"
+end
+
+Then /response status will be (.*)/ do |status|
+ @response.status.should == status.to_i
+end
+
+Then /response content type will be (.*)/ do |content_type|
+ @response.header['Content-Type'].first.should == content_type
+end
+
Then /(.*) part mime type will be (.*)/ do |part, mime|
@response_multipart.part[part_no(part)].header['Content-Type'].should == mime
end
+Then /(.*) part content type will be (.*)/ do |part, content_type|
+ @response_multipart.part[part_no(part)].header['Content-Type'].should == content_type
+end
+
+Then /(.*) part body will be CRLF endend lines$/ do |part, body|
+ @response_multipart.part[part_no(part)].body.should == body.gsub("\n", "\r\n") + "\r\n"
+end
+
Then /(.*) part will contain (.*) image of size (.*)x(.*)/ do |part, format, width, height|
mime = @response_multipart.part[part_no(part)].header['Content-Type']
data = @response_multipart.part[part_no(part)].body
fail("expecte image got #{mime}: #{data}") unless mime =~ /^image\//
@@ -42,7 +73,12 @@
(support_dir + file).open('w'){|f| f.write(data)}
end
And /that image pixel at (.*)x(.*) will be of color (.*)/ do |x, y, color|
@image.pixel_color(x.to_i, y.to_i).to_color.sub(/^#/, '0x').should == color
+end
+
+
+And /there will be no leaked images/ do
+ HTTPClient.new.get_content("http://localhost:3100/stats/images").to_i.should == 0
end