cyberark / conjur-service-broker

Implementation of the Open Service Broker API for Conjur

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Eliminate UT deprecation warning re missing explicit mock config

diverdane opened this issue · comments

Is your feature request related to a problem? Please describe.

When we run the Service Broker UT, a deprecation warning is displayed involving the use of the :should
construct without having this explicitly enabled in rspec mocks configuration:

=====================================================================
Running tests
=====================================================================
1) Run rspec unit tests				     4) Select from a list of Cucumber scenarios to test
2) Run integration (non-E2E) Cucumber tests	     5) Run a bash shell in test container
3) Select from a list of Cucumber features to test   6) Exit and clean up development environment
Please select tests to run: 1
Deprecation Warnings:
Using `stub_chain` from rspec-mocks' old `:should` syntax without explicitly enabling the syntax is deprecated. Use the new `:expect` syntax or explicitly enable `:should` instead. Called from /app/spec/models/service_binding/conjur_v5_app_binding_spec.rb:34:in `block (3 levels) in <top (required)>'.

This can be fixed by adding explicit configuration, e.g.:

diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index fbbfe57..3a965d6 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,3 +1,12 @@
 require File.expand_path('../../config/environment', __FILE__)

 require 'rspec/rails'
+
+RSpec.configure do |config|
+  config.mock_with :rspec do |mocks|
+    mocks.syntax = [:should, :expect]
+  end
+  config.expect_with :rspec do |expectations|
+    expectations.syntax = [:should, :expect]
+  end
+end

Describe the solution you would like

Deprecation warning is eliminated from UT output.

Describe alternatives you have considered

None.

Additional context

To reproduce the problem:

##########################
# Clone Conjur service broker repo
##########################
cd
mkdir -p cyberark
cd cyberark
git clone https://github.com/cyberark/conjur-service-broker
cd conjur-service-broker

##########################
# Create a branch for this fix
# (222 is this issue number, we include this by convention)
##########################
git checkout -b 222-fix-ut-deprecation

##########################
# Build production and development images
##########################
./dev/build
./dev/build_dev

##########################
# Start up the development environment
##########################
./dev/start

##########################
# You should see the menu shown above
# (this issue's description.)
# Select '1' and you should see the deprecation warning
##########################

To add the fix, select 5 in the dev env menu to start up a bash shell, then patch in the fix
mentioned above (put the patch in a file ut_deprec_fix.txt), e.g.

patch -p1 < ut_deprec_fix.txt

Then enter exit to get back to the main menu:

exit

and select 1 to re-run the UT.