2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2016-02-20 20:08:28 +05:30
|
|
|
# Mock external requests to youtube
|
|
|
|
|
require 'webmock/rspec'
|
2016-08-17 23:57:40 +05:30
|
|
|
WebMock.disable_net_connect!(allow_localhost: true, allow: /stripe.com/)
|
2016-02-20 20:08:28 +05:30
|
|
|
|
|
|
|
|
RSpec.configure do |config|
|
|
|
|
|
config.before(:each) do
|
|
|
|
|
mock_commercial_request
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def mock_commercial_request
|
|
|
|
|
response = {
|
2018-11-13 18:01:49 -08:00
|
|
|
author_name: 'Confreaks',
|
|
|
|
|
html: '<iframe width="560" height="315" frameborder="0" allowfullscreen></iframe>',
|
|
|
|
|
thumbnail_width: 480,
|
|
|
|
|
thumbnail_url: '/images/rails.png',
|
|
|
|
|
provider_name: 'YouTube',
|
|
|
|
|
width: 459,
|
|
|
|
|
type: 'video',
|
|
|
|
|
provider_url: 'http://www.youtube.com/',
|
|
|
|
|
version: '1.0',
|
2016-02-20 20:08:28 +05:30
|
|
|
thumbnail_height: 360,
|
2018-11-13 18:01:49 -08:00
|
|
|
title: 'RailsConf 2014 - Closing Keynote by Aaron Patterson',
|
|
|
|
|
author_url: 'https://www.youtube.com/user/Confreaks',
|
|
|
|
|
height: 344
|
2016-02-20 20:08:28 +05:30
|
|
|
}
|
2017-04-06 23:19:58 -04:00
|
|
|
WebMock.stub_request(:get, /.*youtube.*/)
|
|
|
|
|
.to_return(status: 200, body: response.to_json, headers: {})
|
2016-02-20 20:08:28 +05:30
|
|
|
end
|