pact 1.0.15 → 1.0.18
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +29 -0
- data/Gemfile +0 -1
- data/Gemfile.lock +23 -6
- data/README.md +64 -19
- data/Rakefile +2 -2
- data/example/animal-service/spec/service_consumers/provider_states_for_zoo_app.rb +5 -2
- data/lib/pact/consumer/consumer_contract_builder.rb +2 -2
- data/lib/pact/consumer/mock_service/app.rb +2 -2
- data/lib/pact/consumer/mock_service_interaction_expectation.rb +5 -1
- data/lib/pact/consumer_contract/active_support_support.rb +29 -0
- data/lib/pact/consumer_contract/consumer_contract.rb +30 -6
- data/lib/pact/consumer_contract/interaction.rb +7 -1
- data/lib/pact/consumer_contract/request.rb +2 -2
- data/lib/pact/consumer_contract/service_consumer.rb +5 -1
- data/lib/pact/consumer_contract/service_provider.rb +5 -1
- data/lib/pact/matchers/matchers.rb +1 -1
- data/lib/pact/provider/pact_spec_runner.rb +100 -72
- data/lib/pact/provider/rspec.rb +17 -33
- data/lib/pact/provider/verification_report.rb +5 -1
- data/lib/pact/shared/request.rb +7 -3
- data/lib/pact/something_like.rb +5 -1
- data/lib/pact/tasks/task_helper.rb +9 -0
- data/lib/pact/tasks/verification_task.rb +74 -73
- data/lib/pact/term.rb +15 -1
- data/lib/pact/version.rb +1 -1
- data/lib/tasks/pact.rake +4 -2
- data/pact.gemspec +2 -1
- data/spec/features/production_spec.rb +1 -0
- data/spec/integration/consumer_spec.rb +1 -0
- data/spec/lib/pact/consumer_contract/active_support_support_spec.rb +43 -0
- data/spec/lib/pact/consumer_contract/consumer_contract_spec.rb +1 -1
- data/spec/lib/pact/consumer_contract/interaction_spec.rb +3 -3
- data/spec/lib/pact/matchers/matchers_spec.rb +10 -1
- data/spec/lib/pact/verification_task_spec.rb +102 -79
- data/spec/spec_helper.rb +11 -0
- data/tasks/pact-test.rake +1 -1
- data/tasks/spec.rake +8 -0
- metadata +40 -23
- data/lib/pact/json_warning.rb +0 -32
- data/spec/lib/pact/json_warning_spec.rb +0 -39
data/lib/pact/json_warning.rb
DELETED
@@ -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
|