From a48ec866ea8c7d5deb16f966ce92fc39a14438b2 Mon Sep 17 00:00:00 2001 From: Michael Edlund Date: Wed, 26 Aug 2020 11:22:22 -0700 Subject: [PATCH] Crop spec and documentation update --- README.md | 3 ++- spec/gastly/image_spec.rb | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 071372e..5cf462c 100644 --- a/README.md +++ b/README.md @@ -56,10 +56,11 @@ screenshot = Gastly.screenshot('http://google.com', selector: '#hplogo', timeout image = screenshot.capture ``` -You can resize or change the format of the screenshot: +You can resize, crop or change the format of the screenshot: ```ruby image = screenshot.capture +image.crop(width: 250, height: 250, x: 10, y: 0) # Crop with an offset image.resize(width: 110, height: 110) # Creates a preview of the web page image.format('png') image.save('output.png') diff --git a/spec/gastly/image_spec.rb b/spec/gastly/image_spec.rb index 0f42ee3..77b9d23 100644 --- a/spec/gastly/image_spec.rb +++ b/spec/gastly/image_spec.rb @@ -12,6 +12,14 @@ end end + context '#crop' do + it 'invokes method #crop with arguments' do + width, height, x, y = 100, 100, 0, 0 + expect_any_instance_of(MiniMagick::Image).to receive(:crop).with("#{width}x#{height}+#{x}+#{y}") + subject.crop(width: 100, height: 100, x: 0, y: 0) + end + end + context '#format' do it 'invokes method #format' do ext = 'png'