mocking external requests
This commit is contained in:
parent
adf4ad8c51
commit
01af9115a0
1
Gemfile
1
Gemfile
@ -52,6 +52,7 @@ group :test do
|
||||
gem 'simplecov', "~> 0.7.1"
|
||||
gem 'timecop'
|
||||
gem 'webmock'
|
||||
gem 'sinatra'
|
||||
end
|
||||
|
||||
group :production do
|
||||
|
@ -177,6 +177,8 @@ GEM
|
||||
pry-rails (0.3.2)
|
||||
pry (>= 0.9.10)
|
||||
rack (1.5.2)
|
||||
rack-protection (1.5.3)
|
||||
rack
|
||||
rack-test (0.6.2)
|
||||
rack (>= 1.0)
|
||||
rack-timeout (0.0.4)
|
||||
@ -229,6 +231,10 @@ GEM
|
||||
multi_json (~> 1.0)
|
||||
simplecov-html (~> 0.7.1)
|
||||
simplecov-html (0.7.1)
|
||||
sinatra (1.4.5)
|
||||
rack (~> 1.4)
|
||||
rack-protection (~> 1.4)
|
||||
tilt (~> 1.3, >= 1.3.4)
|
||||
slop (3.5.0)
|
||||
spring (1.1.2)
|
||||
spring-commands-rspec (1.0.2)
|
||||
@ -310,6 +316,7 @@ DEPENDENCIES
|
||||
shoulda-matchers
|
||||
simple_form!
|
||||
simplecov (~> 0.7.1)
|
||||
sinatra
|
||||
spring
|
||||
spring-commands-rspec
|
||||
timecop
|
||||
|
@ -29,23 +29,7 @@
|
||||
<video class="video-js vjs-blue-skin" id="bvVideo1" preload="auto" controls>
|
||||
<source src="//video2.bettervideo.com/video/PRO/MP4640x360/720.<%= @videolisting.videocode %>.mp4" type="video/mp4"></source> <!-- Video URL goes here" -->
|
||||
</video>
|
||||
<script>
|
||||
videojs('bvVideo1',{
|
||||
"width": 640,
|
||||
"height": 360,
|
||||
"poster": '//video2.bettervideo.com/video/PRO/JPG640x360/720.<%= @videolisting.videocode %>.jpg', // Video Preview URL goes here
|
||||
"plugins": {
|
||||
"errors": {},
|
||||
"bvSocial": {"reddit":false,"delicious":false},
|
||||
"bvReporting": {
|
||||
"secondaryGA":"UA-XXXXXXXX-X", /* Put your Google Analytics UID here */
|
||||
"secondaryLabel":"Interactive Video"
|
||||
},
|
||||
"bvThemeLoader": {}
|
||||
}
|
||||
}, function() { /* Player Ready Callback, 'this' => reference to this player */ } );
|
||||
|
||||
</script>
|
||||
</div>
|
||||
|
||||
</li>
|
||||
@ -63,5 +47,20 @@
|
||||
var clip = new ZeroClipboard($("#clip_button"));
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
videojs('bvVideo1',{
|
||||
"width": 640,
|
||||
"height": 360,
|
||||
"poster": '//video2.bettervideo.com/video/PRO/JPG640x360/720.<%= @videolisting.videocode %>.jpg', // Video Preview URL goes here
|
||||
"plugins": {
|
||||
"errors": {},
|
||||
"bvSocial": {"reddit":false,"delicious":false},
|
||||
"bvReporting": {
|
||||
"secondaryGA":"UA-XXXXXXXX-X", /* Put your Google Analytics UID here */
|
||||
"secondaryLabel":"Interactive Video"
|
||||
},
|
||||
"bvThemeLoader": {}
|
||||
}
|
||||
}, function() { /* Player Ready Callback, 'this' => reference to this player */ } );
|
||||
</script>
|
||||
<% end %>
|
11
spec/features/better_video_external_request_spec.rb
Normal file
11
spec/features/better_video_external_request_spec.rb
Normal file
@ -0,0 +1,11 @@
|
||||
require 'spec_helper'
|
||||
require 'json'
|
||||
|
||||
feature 'External request' do
|
||||
it 'queries FactoryGirl contributors on Github' do
|
||||
uri = URI('http://servicestest.bettervideo.com/orders/MDS.OrdersWS.svc/addVideo')
|
||||
|
||||
response = JSON.parse(Net::HTTP.get(uri))
|
||||
expect(response['success']).to eq(true)
|
||||
end
|
||||
end
|
@ -29,3 +29,9 @@ end
|
||||
Capybara.javascript_driver = :webkit
|
||||
WebMock.disable_net_connect!(allow_localhost: true)
|
||||
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.before(:each) do
|
||||
stub_request(:any, /servicestest.bettervideo.com/).to_rack(FakeBetterVideo)
|
||||
end
|
||||
end
|
16
spec/support/fake_better_video.rb
Normal file
16
spec/support/fake_better_video.rb
Normal file
@ -0,0 +1,16 @@
|
||||
# spec/support/fake_github.rb
|
||||
require 'sinatra/base'
|
||||
|
||||
class FakeBetterVideo < Sinatra::Base
|
||||
get '/orders/MDS.OrdersWS.svc/addVideo' do
|
||||
json_response 200, 'bettervideo_0.json'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def json_response(response_code, file_name)
|
||||
content_type :json
|
||||
status response_code
|
||||
File.open(File.dirname(__FILE__) + '/fixtures/' + file_name, 'rb').read
|
||||
end
|
||||
end
|
7
spec/support/fixtures/bettervideo_0.json
Normal file
7
spec/support/fixtures/bettervideo_0.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"errorcode": "0",
|
||||
"errormessage": "Success",
|
||||
"listingcode": "242000",
|
||||
"success": true,
|
||||
"videocode": "242001"
|
||||
}
|
Loading…
Reference in New Issue
Block a user