Skip to content

Commit 4ac42ec

Browse files
committed
feat: load pact/v2 into namespace
1 parent 4595015 commit 4ac42ec

3 files changed

Lines changed: 22 additions & 14 deletions

File tree

.rspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
--color
22
--format progress
3-
--require spec_helper

lib/pact.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
require 'pact/support'
2-
require 'pact/version'
3-
require 'pact/configuration'
4-
require 'pact/consumer'
5-
require 'pact/provider'
6-
require 'pact/consumer_contract'
1+
2+
# Selective loading of pact v1 and v2 based on environment variables
3+
if ENV['PACT_RUBY_V1_ENABLE'] != 'false'
4+
require 'pact/support'
5+
require 'pact/version'
6+
require 'pact/configuration'
7+
require 'pact/consumer'
8+
require 'pact/provider'
9+
require 'pact/consumer_contract'
10+
end
11+
if ENV['PACT_RUBY_V2_ENABLE'] == 'true'
12+
require 'pact/v2'
13+
end

tasks/spec.rake

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
RSpec::Core::RakeTask.new(:spec)
2-
1+
RSpec::Core::RakeTask.new(:spec) do |t|
2+
t.pattern = 'spec/**/*_spec.rb'
3+
t.exclude_pattern = 'spec/pact/**/*_spec.rb,spec/v2/**/*_spec.rb'
4+
end
35
# Need to run this in separate process because left over state from
46
# testing the actual pact framework messes up the tests that actually
57
# use pact.
6-
RSpec::Core::RakeTask.new('spec:provider') do | task |
7-
task.pattern = "spec/service_providers/**/*_test.rb"
8+
RSpec::Core::RakeTask.new('spec:provider') do |task|
9+
task.pattern = 'spec/service_providers/**/*_test.rb'
810
end
911

1012
task :set_active_support_on do
11-
ENV["LOAD_ACTIVE_SUPPORT"] = 'true'
13+
ENV['LOAD_ACTIVE_SUPPORT'] = 'true'
1214
end
1315

14-
desc "This is to ensure that the gem still works even when active support JSON is loaded."
15-
task :spec_with_active_support => [:set_active_support_on] do
16+
desc 'This is to ensure that the gem still works even when active support JSON is loaded.'
17+
task spec_with_active_support: [:set_active_support_on] do
1618
Rake::Task['spec'].execute
1719
end

0 commit comments

Comments
 (0)