features/step_definitions/httpthumbnailer_steps.rb in httpthumbnailer-1.0.0 vs features/step_definitions/httpthumbnailer_steps.rb in httpthumbnailer-1.1.0
- old
+ new
@@ -14,11 +14,11 @@
When /I save response body/ do
@saved_response_body = @response.body
end
-Then /(.*) header should be (.*)/ do |header, value|
+Then /^([^ ]+) header should be (.*)/ do |header, value|
@response.header[header].should_not be_empty
@response.header[header].first.should == value
end
Then /I should get multipart response/ do
@@ -67,27 +67,19 @@
Then /response mime type should be (.*)/ do |mime_type|
step "response content type should be #{mime_type}"
end
-Then /(.*) part mime type should be (.*)/ do |part, mime|
- @response_multipart[part_no(part)].headers['content-type'].should == mime
+Then /^([^ ]+) part (.*) header should be (.*)/ do |part, header, value|
+ @response_multipart[part_no(part)].headers[header.downcase].should == value
end
-Then /(.*) part content type should be (.*)/ do |part, content_type|
- @response_multipart[part_no(part)].headers['content-type'].should == content_type
-end
-
-Then /(.*) part status should be (.*)/ do |part, status|
- @response_multipart[part_no(part)].headers['status'].should == status
-end
-
-Then /(.*) part body should be CRLF endend lines$/ do |part, body|
+Then /^([^ ]+) part body should be CRLF endend lines$/ do |part, body|
@response_multipart[part_no(part)].body.should == body.gsub("\n", "\r\n")
end
-Then /(.*) part body should be CRLF endend lines like$/ do |part, body|
+Then /^([^ ]+) part body should be CRLF endend lines like$/ do |part, body|
pbody = @response_multipart[part_no(part)].body
pbody.should match(body)
end
Then /response should contain (.*) image of size (.*)x(.*)/ do |format, width, height|
@@ -139,14 +131,25 @@
And /that image should be (.*) bit image/ do |bits|
@image.depth.should == bits.to_i
end
-
And /there should be no leaked images/ do
Integer(http_client.get_content("http://localhost:3100/stats/images_loaded").strip).should == 0
end
And /there should be maximum (.*) images loaded during single request/ do |max|
Integer(http_client.get_content("http://localhost:3100/stats/max_images_loaded").strip).should <= max.to_i
+end
+
+And /response body should be JSON encoded/ do
+ @json = JSON.load(@response.body)
+end
+
+And /response JSON should contain key (.*) of value (.*)/ do |key, value|
+ @json[key].should == value
+end
+
+And /response JSON should contain key (.*) of integer value (.*)/ do |key, value|
+ @json[key].should == value.to_i
end