Sha256: 5862c8bfcec7236fa683ece74c2ede3361f3b382129794b163db14da3fbc8896
Contents?: true
Size: 1.32 KB
Versions: 2
Compression:
Stored size: 1.32 KB
Contents
require 'spec_helper' module Landable describe ScreenshotService do let(:publicist_url) { nil } let(:screenshot_url) { 'http://google.com/asdf' } let(:screenshot_content) { 'screenshot-content' } before(:each) do Landable.configuration.stub(:publicist_url) { publicist_url } end describe '#capture' do context 'with configured publicist url' do let(:publicist_url) { 'http://publicist.foo/' } it 'should return a file pointer to the downloaded screenshot' do Net::HTTP.should_receive(:post_form) do |uri, params| uri.to_s.should eq 'http://publicist.foo/api/services/screenshots' params.should eq('screenshot[url]' => screenshot_url) double('response', code: '200', content_type: 'image/png', body: screenshot_content) end screenshot = ScreenshotService.capture screenshot_url screenshot.should be_a Tempfile screenshot.read.should eq screenshot_content end end context 'without configured publicist url' do it 'should return nil with a warning' do Net::HTTP.should_not_receive(:post_form) Rails.logger.should_receive(:warn).with(/#{screenshot_url}/) ScreenshotService.capture(screenshot_url).should be_nil end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
landable-1.14.0 | spec/services/landable/screenshot_service_spec.rb |
landable-1.13.2 | spec/services/landable/screenshot_service_spec.rb |