diff --git a/Gemfile b/Gemfile index bde9506..90c7c74 100644 --- a/Gemfile +++ b/Gemfile @@ -52,6 +52,7 @@ group :test do gem 'simplecov', "~> 0.7.1" gem 'timecop' gem 'webmock' + gem 'sinatra' end group :production do diff --git a/Gemfile.lock b/Gemfile.lock index e855f6f..5791661 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 diff --git a/app/views/videolistings/show.html.erb b/app/views/videolistings/show.html.erb index f195c49..ef3ef46 100644 --- a/app/views/videolistings/show.html.erb +++ b/app/views/videolistings/show.html.erb @@ -29,23 +29,7 @@ - @@ -63,5 +47,20 @@ var clip = new ZeroClipboard($("#clip_button")); }); - + <% end %> \ No newline at end of file diff --git a/spec/features/better_video_external_request_spec.rb b/spec/features/better_video_external_request_spec.rb new file mode 100644 index 0000000..b10e8c3 --- /dev/null +++ b/spec/features/better_video_external_request_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 52c3322..2ecbeab 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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 \ No newline at end of file diff --git a/spec/support/fake_better_video.rb b/spec/support/fake_better_video.rb new file mode 100644 index 0000000..a6f8e7c --- /dev/null +++ b/spec/support/fake_better_video.rb @@ -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 \ No newline at end of file diff --git a/spec/support/fixtures/bettervideo_0.json b/spec/support/fixtures/bettervideo_0.json new file mode 100644 index 0000000..49ce122 --- /dev/null +++ b/spec/support/fixtures/bettervideo_0.json @@ -0,0 +1,7 @@ +{ + "errorcode": "0", + "errormessage": "Success", + "listingcode": "242000", + "success": true, + "videocode": "242001" +} \ No newline at end of file