@@ -24,28 +24,34 @@ module ClassMethods
2424 def honour_pactfile pact_source , pact_json , options
2525 pact_uri = pact_source . uri
2626 Pact . configuration . output_stream . puts "INFO: Reading pact at #{ pact_uri } "
27- if pact_uri . metadata [ :notices ]
28- pact_uri . metadata [ :notices ] . before_verification_notices_text . each do | text |
29- Pact . configuration . output_stream . puts ( "DEBUG: #{ text } " )
30- end
31- end
32-
33- Pact . configuration . output_stream . puts "DEBUG: Filtering interactions by: #{ options [ :criteria ] } " if options [ :criteria ] && options [ :criteria ] . any?
3427 consumer_contract = Pact ::ConsumerContract . from_json ( pact_json )
3528 suffix = pact_uri . metadata [ :pending ] ? " [PENDING]" : ""
29+
3630 ::RSpec . describe "Verifying a pact between #{ consumer_contract . consumer . name } and #{ consumer_contract . provider . name } #{ suffix } " , pactfile_uri : pact_uri do
37- honour_consumer_contract consumer_contract , options . merge ( pact_json : pact_json , pact_uri : pact_uri , pact_source : pact_source , consumer_contract : consumer_contract )
31+ honour_consumer_contract consumer_contract , options . merge (
32+ pact_json : pact_json ,
33+ pact_uri : pact_uri ,
34+ pact_source : pact_source ,
35+ consumer_contract : consumer_contract ,
36+ criteria : options [ :criteria ]
37+ )
3838 end
3939 end
4040
4141 def honour_consumer_contract consumer_contract , options = { }
42- describe_consumer_contract consumer_contract , options . merge ( consumer : consumer_contract . consumer . name )
42+ describe_consumer_contract consumer_contract , options . merge ( consumer : consumer_contract . consumer . name , pact_context : InteractionContext . new )
4343 end
4444
4545 private
4646
4747 def describe_consumer_contract consumer_contract , options
48- consumer_interactions ( consumer_contract , options ) . each do |interaction |
48+ consumer_interactions ( consumer_contract , options ) . tap { |interactions |
49+ if interactions . empty?
50+ # If there are no interactions, the documentation formatter never fires to print this out,
51+ # so print it out here.
52+ Pact . configuration . output_stream . puts "DEBUG: All interactions for #{ options [ :pact_uri ] } have been filtered out by criteria: #{ options [ :criteria ] } " if options [ :criteria ] && options [ :criteria ] . any?
53+ end
54+ } . each do |interaction |
4955 describe_interaction_with_provider_state interaction , options
5056 end
5157 end
@@ -54,7 +60,7 @@ def consumer_interactions(consumer_contract, options)
5460 if options [ :criteria ] . nil?
5561 consumer_contract . interactions
5662 else
57- consumer_contract . find_interactions options [ :criteria ]
63+ consumer_contract . find_interactions ( options [ :criteria ] )
5864 end
5965 end
6066
@@ -84,14 +90,19 @@ def describe_interaction interaction, options
8490 pact_uri : options [ :pact_uri ] ,
8591 pact_source : options [ :pact_source ] ,
8692 pact_ignore_failures : options [ :pact_uri ] . metadata [ :pending ] || options [ :ignore_failures ] ,
87- pact_consumer_contract : options [ :consumer_contract ]
93+ pact_consumer_contract : options [ :consumer_contract ] ,
94+ pact_criteria : options [ :criteria ]
8895 }
8996
9097 describe description_for ( interaction ) , metadata do
9198
9299 interaction_context = InteractionContext . new
100+ pact_context = options [ :pact_context ]
93101
94102 before do | example |
103+ pact_context . run_once :before do
104+ ::RSpec . configuration . reporter . message "THIS IS A PACT"
105+ end
95106 interaction_context . run_once :before do
96107 Pact . configuration . logger . info "Running example '#{ Pact ::RSpec . full_description ( example ) } '"
97108 set_up_provider_states interaction . provider_states , options [ :consumer ]
0 commit comments