Fixed #272 Mocked up external server requests (#286)

* <Partially filled out the stub request>

* <Mocked requests to external servers>

* <Fixed style>

* Deleting rename.js

Accidentally slipped its way into the commit
This commit is contained in:
John Ma 2018-10-04 14:16:12 -04:00 committed by Jesus Federico
parent 5c3fd15323
commit daaf305c30
3 changed files with 35 additions and 1 deletions

View File

@ -87,6 +87,7 @@ group :test do
gem 'shoulda-matchers', '~> 3.1' gem 'shoulda-matchers', '~> 3.1'
gem 'faker' gem 'faker'
gem "factory_bot_rails" gem "factory_bot_rails"
gem 'webmock'
# Ruby linting. # Ruby linting.
gem 'rubocop' gem 'rubocop'

View File

@ -40,6 +40,8 @@ GEM
i18n (>= 0.7, < 2) i18n (>= 0.7, < 2)
minitest (~> 5.1) minitest (~> 5.1)
tzinfo (~> 1.1) tzinfo (~> 1.1)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
arel (7.1.4) arel (7.1.4)
ast (2.4.0) ast (2.4.0)
autoprefixer-rails (8.6.4) autoprefixer-rails (8.6.4)
@ -68,6 +70,8 @@ GEM
simplecov (>= 0.7) simplecov (>= 0.7)
term-ansicolor term-ansicolor
thor thor
crack (0.4.3)
safe_yaml (~> 1.0.0)
crass (1.0.4) crass (1.0.4)
diff-lcs (1.3) diff-lcs (1.3)
docile (1.3.1) docile (1.3.1)
@ -91,6 +95,7 @@ GEM
ffi (1.9.25) ffi (1.9.25)
globalid (0.4.1) globalid (0.4.1)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
hashdiff (0.3.7)
hashie (3.5.7) hashie (3.5.7)
http-cookie (1.0.3) http-cookie (1.0.3)
domain_name (~> 0.5) domain_name (~> 0.5)
@ -168,6 +173,7 @@ GEM
pg (0.21.0) pg (0.21.0)
popper_js (1.12.9) popper_js (1.12.9)
powerpack (0.1.2) powerpack (0.1.2)
public_suffix (3.0.3)
puma (3.11.4) puma (3.11.4)
pyu-ruby-sasl (0.0.3.3) pyu-ruby-sasl (0.0.3.3)
rack (2.0.5) rack (2.0.5)
@ -239,6 +245,7 @@ GEM
unicode-display_width (~> 1.0, >= 1.0.1) unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.9.0) ruby-progressbar (1.9.0)
rubyntlm (0.6.2) rubyntlm (0.6.2)
safe_yaml (1.0.4)
sass (3.5.6) sass (3.5.6)
sass-listen (~> 4.0.0) sass-listen (~> 4.0.0)
sass-listen (4.0.0) sass-listen (4.0.0)
@ -297,6 +304,10 @@ GEM
activemodel (>= 5.0) activemodel (>= 5.0)
bindex (>= 0.4.0) bindex (>= 0.4.0)
railties (>= 5.0) railties (>= 5.0)
webmock (3.4.2)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
websocket-driver (0.6.5) websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0) websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3) websocket-extensions (0.1.3)
@ -344,6 +355,7 @@ DEPENDENCIES
tzinfo-data tzinfo-data
uglifier (>= 1.3.0) uglifier (>= 1.3.0)
web-console (>= 3.3.0) web-console (>= 3.3.0)
webmock
BUNDLED WITH BUNDLED WITH
1.16.3 1.16.4

View File

@ -22,6 +22,11 @@ Coveralls.wear!
require 'faker' require 'faker'
require 'factory_bot_rails' 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 # 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`. # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause # 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 # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config| 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 # rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest # assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer. # assertions if you prefer.