This repository has been archived by the owner on Jan 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
106 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ def initialize(url) | |
end | ||
|
||
PhantomJSError = Class.new(RuntimeError) | ||
UnknownError = Class.new(RuntimeError) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,37 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Gastly::Image do | ||
let(:image) { MiniMagick::Image.new('test.png') } | ||
subject { Gastly::Image.new(image) } | ||
|
||
context '#resize' do | ||
it 'invokes method #resize with arguments' do | ||
width, height = 100, 100 | ||
expect_any_instance_of(MiniMagick::Image).to receive(:resize).with("#{width}x#{height}") | ||
subject.resize(width: 100, height: 100) | ||
end | ||
end | ||
|
||
context '#format' do | ||
it 'invokes method #format' do | ||
ext = 'png' | ||
expect_any_instance_of(MiniMagick::Image).to receive(:format).with(ext) | ||
subject.format(ext) | ||
end | ||
end | ||
|
||
context '#save' do | ||
let(:output) { 'output.png' } | ||
before do | ||
expect_any_instance_of(MiniMagick::Image).to receive(:write).with(output) | ||
end | ||
|
||
it 'invokes method #write' do | ||
subject.save(output) | ||
end | ||
|
||
it 'returns a string' do | ||
expect(subject.save(output)).to eq output | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,22 @@ | ||
require 'spec_helper' | ||
|
||
describe Gastly do | ||
let(:url) { 'http://google.com' } | ||
|
||
context '#screenshot' do | ||
it 'returns an instance of Gastly::Screenshot' do | ||
expect(Gastly.screenshot(url, timeout: 1000)).to be_instance_of Gastly::Screenshot | ||
end | ||
end | ||
|
||
context '#capture' do | ||
it 'creates a screenshot' do | ||
tmp = 'spec/support/tmp' | ||
path = "#{tmp}/output.png" | ||
expect(Dir.glob("#{tmp}/*").length).to eq 0 | ||
Gastly.capture(url, path) | ||
expect(Dir.glob("#{tmp}/*").length).to eq 1 | ||
FileUtils.rm Dir.glob("#{tmp}/*") | ||
end | ||
end | ||
end |