diff --git a/Gemfile b/Gemfile index 185ce46..77ef190 100644 --- a/Gemfile +++ b/Gemfile @@ -67,3 +67,4 @@ gem 'skylight' gem 'slugtastic' gem 'squeel' gem 'unf' +gem 'webmock' diff --git a/Gemfile.lock b/Gemfile.lock index 148db88..9d8f549 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -99,6 +99,8 @@ GEM coffee-script-source execjs coffee-script-source (1.9.1.1) + crack (0.4.2) + safe_yaml (~> 1.0.0) database_cleaner (1.5.0) datetime_picker_rails (0.0.4) momentjs-rails (>= 2.8.1) @@ -280,6 +282,7 @@ GEM ruby-progressbar (1.7.5) ruby_parser (3.7.1) sexp_processor (~> 4.1) + safe_yaml (1.0.4) sass (3.4.19) sass-rails (5.0.4) railties (>= 4.0.0, < 5.0) @@ -330,6 +333,9 @@ GEM unf_ext (0.0.7.1) warden (1.2.3) rack (>= 1.0) + webmock (1.21.0) + addressable (>= 2.3.6) + crack (>= 0.3.2) websocket-driver (0.6.2) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.2) @@ -382,6 +388,7 @@ DEPENDENCIES squeel uglifier unf + webmock BUNDLED WITH 1.10.6 diff --git a/spec/features/visitor_navigates_site_spec.rb b/spec/features/visitor_navigates_site_spec.rb index e074523..70b9a3f 100644 --- a/spec/features/visitor_navigates_site_spec.rb +++ b/spec/features/visitor_navigates_site_spec.rb @@ -10,8 +10,10 @@ feature 'visitor navigates site' do end it 'increments the view counter when an image is displayed', js: true do + stub_request(:get, 'http://res.cloudinary.com/danbarber/image/upload/photo.jpg') + category = create(:category) - photo = create(:photo, featured: true, categories: [category]) + photo = create(:photo, image_cloudinary_id: 'photo', featured: true, categories: [category]) visit root_path diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7524347..474f04a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -4,6 +4,7 @@ require File.expand_path('../../config/environment', __FILE__) require 'rspec/rails' require 'capybara/rspec' require 'capybara/poltergeist' +require 'webmock/rspec' # For code coverage require 'simplecov' @@ -16,6 +17,8 @@ Capybara.javascript_driver = :poltergeist # in spec/support/ and its subdirectories. Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } +WebMock.disable_net_connect!(:allow_localhost => true) + RSpec.configure do |config| # ## Mock Framework #