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 if [ -f ../config/consul.yml ]; then # canvas is running in docker
docker-compose run --rm --no-deps \ docker-compose run --rm --no-deps \
-e RAILS_ENV=test \ -e RAILS_ENV=test \
-e RUN_API_CONTRACT_TESTS=1 \ web bundle exec rspec pact/spec \
web bundle exec rspec spec/contracts/service_providers \
--tag pact --format doc --tag pact --format doc
else else
RAILS_ENV=test RUN_API_CONTRACT_TESTS=1 \ RAILS_ENV=test \
bundle exec rspec spec/contracts/service_providers \ bundle exec rspec pact/spec \
--tag pact --format doc --tag pact --format doc
fi fi

View File

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

View File

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

View File

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

View File

@ -18,7 +18,7 @@
ENV["RAILS_ENV"] = ENV["RACK_ENV"]= "test" ENV["RAILS_ENV"] = ENV["RACK_ENV"]= "test"
require 'pact/provider/rspec' require 'pact/provider/rspec'
require_relative '../../pact_config' require_relative '../../../../pact/pact_config'
require_relative '../../../spec_helper' require_relative '../../../spec_helper'
require_relative 'provider_states_for_consumer' 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 # 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/>. # with this program. If not, see <http://www.gnu.org/licenses/>.
require_relative '../../pact_config' require_relative '../../../../pact/pact_config'
require_relative 'pact_setup' require_relative 'pact_setup'
PactConfig::Consumers::ALL.each do |consumer| PactConfig::Consumers::ALL.each do |consumer|

View File

@ -17,7 +17,7 @@
# #
require 'pact/messages' require 'pact/messages'
require_relative '../../pact_config' require_relative '../../../../pact/pact_config'
require_relative '../../../spec_helper' require_relative '../../../spec_helper'
Pact::Messages.pact_broker_url = PactConfig.broker_uri 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 # 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_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 Helpers
config.include Factories config.include Factories