pact 1.0.39 → 1.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +1 -17
- data/Gemfile.lock +2 -2
- data/README.md +18 -27
- data/bethtest.rb +30 -0
- data/documentation/faq.md +6 -36
- data/lib/pact/configuration.rb +0 -4
- data/lib/pact/consumer/consumer_contract_builder.rb +1 -1
- data/lib/pact/consumer_contract/active_support_support.rb +0 -4
- data/lib/pact/matchers/diff_decorator.rb +1 -1
- data/lib/pact/matchers/index_not_found.rb +12 -3
- data/lib/pact/matchers/matchers.rb +2 -1
- data/lib/pact/matchers/nested_json_diff_decorator.rb +48 -0
- data/lib/pact/matchers/plus_minus_diff_decorator.rb +92 -0
- data/lib/pact/matchers/unexpected_index.rb +13 -3
- data/lib/pact/matchers/unexpected_key.rb +12 -3
- data/lib/pact/provider/configuration.rb +31 -0
- data/lib/pact/provider/matchers.rb +4 -4
- data/lib/pact/provider/pact_spec_runner.rb +28 -35
- data/lib/pact/provider/print_missing_provider_states.rb +2 -2
- data/lib/pact/provider/rspec.rb +7 -16
- data/lib/pact/provider/world.rb +0 -6
- data/lib/pact/shared/key_not_found.rb +16 -3
- data/lib/pact/tasks/task_helper.rb +18 -15
- data/lib/pact/templates/provider_state.erb +1 -0
- data/lib/pact/version.rb +1 -1
- data/spec/lib/pact/matchers/matchers_spec.rb +9 -0
- data/spec/lib/pact/matchers/nested_json_diff_decorator_spec.rb +48 -0
- data/spec/lib/pact/matchers/plus_minus_diff_decorator_spec.rb +186 -0
- data/spec/lib/pact/provider/configuration_spec.rb +131 -102
- data/spec/lib/pact/verification_task_spec.rb +10 -0
- data/spec/support/pact_helper.rb +2 -5
- data/spec/support/stubbing.json +1 -1
- data/spec/support/test_app_fail.json +2 -29
- data/spec/support/test_app_pass.json +4 -4
- data/tasks/pact-test.rake +0 -8
- metadata +13 -22
- data/lib/pact/matchers/difference_indicator.rb +0 -26
- data/lib/pact/provider/rspec/formatter.rb +0 -63
- data/lib/pact/provider/rspec/silent_json_formatter.rb +0 -18
- data/spec/lib/pact/matchers/index_not_found_spec.rb +0 -21
- data/spec/lib/pact/matchers/unexpected_index_spec.rb +0 -20
- data/spec/lib/pact/matchers/unexpected_key_spec.rb +0 -20
- data/spec/lib/pact/shared/key_not_found_spec.rb +0 -20
- data/spec/lib/pact/tasks/task_helper_spec.rb +0 -80
@@ -1,80 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'pact/tasks/task_helper'
|
3
|
-
|
4
|
-
module Pact
|
5
|
-
describe TaskHelper do
|
6
|
-
include TaskHelper
|
7
|
-
|
8
|
-
let(:env_description) { "pact description set in ENV"}
|
9
|
-
let(:env_provider_state) { "provider state set in ENV"}
|
10
|
-
let(:env_criteria){ {:description=>/#{env_description}/, :provider_state=>/#{env_provider_state}/} }
|
11
|
-
let(:default_description) { "default description"}
|
12
|
-
let(:default_provider_state) { "default provider state"}
|
13
|
-
|
14
|
-
shared_context "PACT_DESCRIPTION is defined" do
|
15
|
-
before do
|
16
|
-
ENV.stub(:[])
|
17
|
-
ENV.stub(:[]).with("PACT_DESCRIPTION").and_return(env_description)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
shared_context 'PACT_PROVIDER_STATE is defined' do
|
22
|
-
before do
|
23
|
-
ENV.stub(:[])
|
24
|
-
ENV.stub(:[]).with("PACT_PROVIDER_STATE").and_return(env_provider_state)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
shared_context 'default description is defined' do
|
29
|
-
let(:default_description) { "default description"}
|
30
|
-
end
|
31
|
-
|
32
|
-
let(:defaults) { {:description => default_description, :provider_state => default_provider_state} }
|
33
|
-
|
34
|
-
describe "spec_criteria" do
|
35
|
-
|
36
|
-
context "when ENV variables are defined" do
|
37
|
-
before do
|
38
|
-
ENV.stub(:fetch).with("PACT_DESCRIPTION", anything).and_return(env_description)
|
39
|
-
ENV.stub(:fetch).with("PACT_PROVIDER_STATE", anything).and_return(env_provider_state)
|
40
|
-
end
|
41
|
-
|
42
|
-
context "when defaults are not passed in" do
|
43
|
-
it "returns the env vars as regexes" do
|
44
|
-
expect(spec_criteria).to eq(env_criteria)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context "when defaults are passed in" do
|
49
|
-
it "returns the env vars as regexes" do
|
50
|
-
expect(spec_criteria(defaults)).to eq(env_criteria)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context "when ENV variables are not defined" do
|
56
|
-
context "when defaults are passed in" do
|
57
|
-
it "returns the defaults as regexes" do
|
58
|
-
expect(spec_criteria(defaults)).to eq({:description=>/#{default_description}/, :provider_state=>/#{default_provider_state}/})
|
59
|
-
end
|
60
|
-
end
|
61
|
-
context "when defaults are not passed in" do
|
62
|
-
it "returns an empty hash" do
|
63
|
-
expect(spec_criteria).to eq({})
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
context "when provider state is an empty string" do
|
69
|
-
before do
|
70
|
-
ENV.stub(:fetch).with(anything, anything).and_return(nil)
|
71
|
-
ENV.stub(:fetch).with("PACT_PROVIDER_STATE", anything).and_return('')
|
72
|
-
end
|
73
|
-
|
74
|
-
it "returns a nil provider state so that it matches a nil provider state on the interaction" do
|
75
|
-
expect(spec_criteria[:provider_state]).to be_nil
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|