spec: Move generic consumer tests into pact folder

This also moves the pact_config.rb file into the pact folder.

The line filtering :pact tests has been removed from spec_helper.rb,
since rspec won't try to run them anyway now that they aren't in the
spec folder.

Change-Id: I1d8f27f4f30aa2cdc85e570deb7e0aa2cdb89c66
Reviewed-on: https://gerrit.instructure.com/152144
Reviewed-by: Michael Hargiss <mhargiss@instructure.com>
Tested-by: Jenkins
Product-Review: Tucker McKnight <tmcknight@instructure.com>
QA-Review: Tucker McKnight <tmcknight@instructure.com>
This commit is contained in:
Tucker McKnight 2018-05-31 16:58:07 -06:00
parent 7f301937ea
commit 72bc724fb3
13 changed files with 14 additions and 20 deletions

View File

@ -5,11 +5,10 @@ set -e
if [ -f ../config/consul.yml ]; then # canvas is running in docker
docker-compose run --rm --no-deps \
-e RAILS_ENV=test \
-e RUN_API_CONTRACT_TESTS=1 \
web bundle exec rspec spec/contracts/service_providers \
web bundle exec rspec pact/spec \
--tag pact --format doc
else
RAILS_ENV=test RUN_API_CONTRACT_TESTS=1 \
bundle exec rspec spec/contracts/service_providers \
RAILS_ENV=test \
bundle exec rspec pact/spec \
--tag pact --format doc
fi

View File

@ -16,7 +16,7 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
require 'pact/consumer/rspec'
require_relative '../pact_config'
require_relative 'pact_config'
# see https://github.com/realestate-com-au/pact/blob/master/documentation/configuration.md
Pact.configure do |config|
@ -27,9 +27,6 @@ Pact.configure do |config|
config.pactfile_write_order = :chronological
end
# Only load this code block when running API contract tests, otherwise the Pact
# mock server will cause the canvas specs to fail.
if ENV.fetch('RUN_API_CONTRACT_TESTS', '0') == '1'
Pact.service_consumer PactConfig::Consumers::GENERIC_CONSUMER do
has_pact_with PactConfig::Providers::CANVAS_LMS_API do
mock_service :canvas_lms_api do
@ -38,4 +35,3 @@ if ENV.fetch('RUN_API_CONTRACT_TESTS', '0') == '1'
end
end
end
end

View File

@ -17,7 +17,7 @@
require 'httparty'
require 'json'
require_relative '../../../../pact_config'
require_relative '../../../pact_config'
module Helper
module ApiClient

View File

@ -17,7 +17,7 @@
require 'httparty'
require 'json'
require_relative '../../../../pact_config'
require_relative '../../../pact_config'
module Helper
module ApiClient

View File

@ -18,7 +18,7 @@
ENV["RAILS_ENV"] = ENV["RACK_ENV"]= "test"
require 'pact/provider/rspec'
require_relative '../../pact_config'
require_relative '../../../../pact/pact_config'
require_relative '../../../spec_helper'
require_relative 'provider_states_for_consumer'

View File

@ -15,7 +15,7 @@
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
require_relative '../../pact_config'
require_relative '../../../../pact/pact_config'
require_relative 'pact_setup'
PactConfig::Consumers::ALL.each do |consumer|

View File

@ -17,7 +17,7 @@
#
require 'pact/messages'
require_relative '../../pact_config'
require_relative '../../../../pact/pact_config'
require_relative '../../../spec_helper'
Pact::Messages.pact_broker_url = PactConfig.broker_uri

View File

@ -320,7 +320,6 @@ RSpec.configure do |config|
# The Pact specs have prerequisite setup steps so we exclude them by default
config.filter_run_excluding :pact_live_events if ENV.fetch('RUN_LIVE_EVENTS_CONTRACT_TESTS', '0') == '0'
config.filter_run_excluding :pact if ENV.fetch('RUN_API_CONTRACT_TESTS', '0') == '0'
config.include Helpers
config.include Factories