diff --git a/Gemfile b/Gemfile index 8de1eb0e..b6f17f24 100644 --- a/Gemfile +++ b/Gemfile @@ -87,6 +87,7 @@ group :test do gem 'shoulda-matchers', '~> 3.1' gem 'faker' gem "factory_bot_rails" + gem 'webmock' # Ruby linting. gem 'rubocop' diff --git a/Gemfile.lock b/Gemfile.lock index 9b8cdf27..661d30be 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -40,6 +40,8 @@ GEM i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) + addressable (2.5.2) + public_suffix (>= 2.0.2, < 4.0) arel (7.1.4) ast (2.4.0) autoprefixer-rails (8.6.4) @@ -68,6 +70,8 @@ GEM simplecov (>= 0.7) term-ansicolor thor + crack (0.4.3) + safe_yaml (~> 1.0.0) crass (1.0.4) diff-lcs (1.3) docile (1.3.1) @@ -91,6 +95,7 @@ GEM ffi (1.9.25) globalid (0.4.1) activesupport (>= 4.2.0) + hashdiff (0.3.7) hashie (3.5.7) http-cookie (1.0.3) domain_name (~> 0.5) @@ -168,6 +173,7 @@ GEM pg (0.21.0) popper_js (1.12.9) powerpack (0.1.2) + public_suffix (3.0.3) puma (3.11.4) pyu-ruby-sasl (0.0.3.3) rack (2.0.5) @@ -239,6 +245,7 @@ GEM unicode-display_width (~> 1.0, >= 1.0.1) ruby-progressbar (1.9.0) rubyntlm (0.6.2) + safe_yaml (1.0.4) sass (3.5.6) sass-listen (~> 4.0.0) sass-listen (4.0.0) @@ -297,6 +304,10 @@ GEM activemodel (>= 5.0) bindex (>= 0.4.0) railties (>= 5.0) + webmock (3.4.2) + addressable (>= 2.3.6) + crack (>= 0.3.2) + hashdiff websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.3) @@ -344,6 +355,7 @@ DEPENDENCIES tzinfo-data uglifier (>= 1.3.0) web-console (>= 3.3.0) + webmock BUNDLED WITH - 1.16.3 + 1.16.4 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2f2e3d00..bd82a506 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -22,6 +22,11 @@ Coveralls.wear! require 'faker' require 'factory_bot_rails' +require 'webmock/rspec' + +# For testing, disable connections to external servers +WebMock.disable_net_connect!(allow_localhost: true) + # This file was generated by the `rails generate rspec:install` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause @@ -38,6 +43,22 @@ require 'factory_bot_rails' # # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| + # rspec webmock config goes here. To prevent tests from defaulting to + # external servers, api stubbing is used to simulate external server + # responses + config.before(:each) do + stub_request(:any, /#{ENV['BIGBLUEBUTTON_ENDPOINT']}/) + .with( + headers: + { + 'Accept': '*/*', + 'Accept-Encoding': 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent': 'Ruby', + } + ) + .to_return(status: 200, body: "", headers: {}) + end + # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest # assertions if you prefer.