pact 1.0.15 → 1.0.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/CHANGELOG.md +29 -0
  2. data/Gemfile +0 -1
  3. data/Gemfile.lock +23 -6
  4. data/README.md +64 -19
  5. data/Rakefile +2 -2
  6. data/example/animal-service/spec/service_consumers/provider_states_for_zoo_app.rb +5 -2
  7. data/lib/pact/consumer/consumer_contract_builder.rb +2 -2
  8. data/lib/pact/consumer/mock_service/app.rb +2 -2
  9. data/lib/pact/consumer/mock_service_interaction_expectation.rb +5 -1
  10. data/lib/pact/consumer_contract/active_support_support.rb +29 -0
  11. data/lib/pact/consumer_contract/consumer_contract.rb +30 -6
  12. data/lib/pact/consumer_contract/interaction.rb +7 -1
  13. data/lib/pact/consumer_contract/request.rb +2 -2
  14. data/lib/pact/consumer_contract/service_consumer.rb +5 -1
  15. data/lib/pact/consumer_contract/service_provider.rb +5 -1
  16. data/lib/pact/matchers/matchers.rb +1 -1
  17. data/lib/pact/provider/pact_spec_runner.rb +100 -72
  18. data/lib/pact/provider/rspec.rb +17 -33
  19. data/lib/pact/provider/verification_report.rb +5 -1
  20. data/lib/pact/shared/request.rb +7 -3
  21. data/lib/pact/something_like.rb +5 -1
  22. data/lib/pact/tasks/task_helper.rb +9 -0
  23. data/lib/pact/tasks/verification_task.rb +74 -73
  24. data/lib/pact/term.rb +15 -1
  25. data/lib/pact/version.rb +1 -1
  26. data/lib/tasks/pact.rake +4 -2
  27. data/pact.gemspec +2 -1
  28. data/spec/features/production_spec.rb +1 -0
  29. data/spec/integration/consumer_spec.rb +1 -0
  30. data/spec/lib/pact/consumer_contract/active_support_support_spec.rb +43 -0
  31. data/spec/lib/pact/consumer_contract/consumer_contract_spec.rb +1 -1
  32. data/spec/lib/pact/consumer_contract/interaction_spec.rb +3 -3
  33. data/spec/lib/pact/matchers/matchers_spec.rb +10 -1
  34. data/spec/lib/pact/verification_task_spec.rb +102 -79
  35. data/spec/spec_helper.rb +11 -0
  36. data/tasks/pact-test.rake +1 -1
  37. data/tasks/spec.rake +8 -0
  38. metadata +40 -23
  39. data/lib/pact/json_warning.rb +0 -32
  40. data/spec/lib/pact/json_warning_spec.rb +0 -39
@@ -1,32 +0,0 @@
1
- require 'logger'
2
- require 'json/add/regexp'
3
-
4
- module Pact
5
- module JsonWarning
6
- def check_for_active_support_json
7
- return if @already_warned
8
-
9
- # Active support clobbers the as_json methods defined in the json/add directory of the json gem.
10
- # These methods are required to serialize and deserialize the Regexp and Symbol classes properly.
11
- # You can potentially fix this by making sure the json gem is required AFTER the active_support/json gem
12
- # OR if you don't use the json part of activesupport you could only require the parts of active support you really need
13
- # OR you can only use strings in your pacts.
14
- # Good luck.
15
-
16
- # If someone knows how to make sure the pact gem uses the json gem as_json methods when activesupport/json is used in the calling code,
17
- # without breaking the calling code, which may depend on activesupport/json... then please fix this.
18
- # Note: we can probably do this in Ruby 2.0 with refinements, but for now, we're all stuck on 1.9 :(
19
-
20
- if as_json_clobbered?
21
- Logger.new($stderr).warn("It appears you are using ActiveSupport json in your project. You are now in rubygems hell. Please see Pact::JsonWarning for more info.")
22
- @already_warned = true
23
- end
24
- end
25
-
26
- private
27
-
28
- def as_json_clobbered?
29
- !Regexp.new('').as_json.is_a?(Hash)
30
- end
31
- end
32
- end
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Pact
4
-
5
- describe JsonWarning do
6
-
7
- class TestContract
8
- include JsonWarning
9
- end
10
-
11
- let(:logger) { double }
12
-
13
- before do
14
- Logger.stub(new: logger)
15
- @contract = TestContract.new
16
- end
17
-
18
- context 'when as_json has been clobbered' do
19
- before { @contract.stub(as_json_clobbered?: true) }
20
-
21
- it 'logs a single warning' do
22
- logger.should_receive(:warn).once
23
- @contract.check_for_active_support_json
24
- @contract.check_for_active_support_json
25
- end
26
- end
27
-
28
- context 'when as_json has NOT been clobbered' do
29
- before { @contract.stub(as_json_clobbered?: false) }
30
-
31
- it 'does not log a warning' do
32
- logger.should_not_receive(:warn)
33
- @contract.check_for_active_support_json
34
- end
35
- end
36
-
37
- end
38
-
39
- end