pact_broker 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.gitignore +2 -0
- data/CHANGELOG.md +5 -0
- data/README.md +2 -1
- data/Rakefile +1 -3
- data/db/migrations/07_increase_json_content_length.rb +6 -1
- data/db/migrations/08_create_latest_pact_view.rb +7 -5
- data/db/migrations/14_add_timestamps_to_pact_views.rb +28 -0
- data/lib/pact_broker/api.rb +0 -4
- data/lib/pact_broker/api/decorators/latest_pact_decorator.rb +4 -1
- data/lib/pact_broker/api/decorators/pact_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/pact_version_decorator.rb +3 -4
- data/lib/pact_broker/api/decorators/pact_versions_decorator.rb +4 -4
- data/lib/pact_broker/api/decorators/pacticipant_decorator.rb +3 -2
- data/lib/pact_broker/api/decorators/tag_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/timestamps.rb +24 -0
- data/lib/pact_broker/api/decorators/webhook_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/webhooks_decorator.rb +4 -4
- data/lib/pact_broker/api/renderers/html_pact_renderer.rb +16 -4
- data/lib/pact_broker/api/resources/base_resource.rb +0 -1
- data/lib/pact_broker/api/resources/group.rb +11 -6
- data/lib/pact_broker/api/resources/index.rb +5 -6
- data/lib/pact_broker/api/resources/latest_pact.rb +8 -5
- data/lib/pact_broker/api/resources/latest_pacts.rb +3 -3
- data/lib/pact_broker/api/resources/pact.rb +9 -5
- data/lib/pact_broker/api/resources/pact_webhooks.rb +9 -5
- data/lib/pact_broker/api/resources/pacticipant.rb +10 -5
- data/lib/pact_broker/api/resources/relationships.rb +3 -3
- data/lib/pact_broker/api/resources/tag.rb +8 -7
- data/lib/pact_broker/api/resources/webhook.rb +1 -1
- data/lib/pact_broker/api/resources/webhook_execution.rb +1 -1
- data/lib/pact_broker/app.rb +8 -57
- data/lib/pact_broker/logging.rb +1 -0
- data/lib/pact_broker/models/pact.rb +6 -8
- data/lib/pact_broker/repositories/pact.rb +29 -0
- data/lib/pact_broker/repositories/pact_content.rb +0 -0
- data/lib/pact_broker/repositories/pact_repository.rb +66 -21
- data/lib/pact_broker/repositories/tag_repository.rb +1 -1
- data/lib/pact_broker/repositories/version_repository.rb +2 -1
- data/lib/pact_broker/services/pact_service.rb +14 -16
- data/lib/pact_broker/ui.rb +2 -0
- data/lib/pact_broker/ui/app.rb +81 -0
- data/lib/pact_broker/ui/controllers/groups.rb +1 -1
- data/lib/pact_broker/version.rb +1 -1
- data/lib/rack/pact_broker/convert_file_extension_to_accept_header.rb +44 -0
- data/pact_broker.gemspec +1 -0
- data/public/javascripts/highlight.pack.js +1 -0
- data/public/stylesheets/github-json.css +127 -0
- data/public/stylesheets/pact.css +4 -0
- data/spec/fixtures/consumer-provider.json +21 -0
- data/spec/integration/app_spec.rb +165 -0
- data/spec/integration/endpoints/pact_put_spec.rb +43 -0
- data/spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb +42 -0
- data/spec/lib/pact_broker/api/decorators/pact_version_decorator_spec.rb +5 -0
- data/spec/lib/pact_broker/api/decorators/pacticipant_decorator_spec.rb +2 -1
- data/spec/lib/pact_broker/api/decorators/webhook_decorator_spec.rb +9 -2
- data/spec/lib/pact_broker/api/renderers/html_pact_renderer_spec.rb +14 -3
- data/spec/lib/pact_broker/repositories/pact_repository_spec.rb +88 -4
- data/spec/lib/pact_broker/repositories/tag_repository_spec.rb +2 -0
- data/spec/lib/pact_broker/repositories/version_repository_spec.rb +20 -2
- data/spec/lib/pact_broker/services/pacticipant_service_spec.rb +1 -1
- data/spec/service_consumers/pact_helper.rb +2 -17
- data/spec/spec_helper.rb +4 -22
- data/spec/support/database_cleaner.rb +18 -0
- data/spec/support/fixture_helpers.rb +10 -0
- data/spec/support/provider_state_builder.rb +4 -15
- metadata +82 -47
@@ -0,0 +1,43 @@
|
|
1
|
+
describe "pacts/provider/:provider/consumer/:consumer/version/:version" do
|
2
|
+
describe "PUT" do
|
3
|
+
|
4
|
+
let(:pact_content) { load_fixture('consumer-provider.json') }
|
5
|
+
let(:path) { "/pacts/provider/A%20Provider/consumer/A%20Consumer/version/1.2.3" }
|
6
|
+
let(:response_body_json) { JSON.parse(subject.body) }
|
7
|
+
|
8
|
+
subject { put path, pact_content, {'CONTENT_TYPE' => 'application/json' }; last_response }
|
9
|
+
|
10
|
+
context "when the pact does not exist" do
|
11
|
+
it "returns a 201 Created" do
|
12
|
+
expect(subject.status).to be 201
|
13
|
+
end
|
14
|
+
|
15
|
+
it "returns a json body" do
|
16
|
+
expect(subject.headers['Content-Type']).to eq "application/json"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns the pact in the body" do
|
20
|
+
expect(response_body_json).to include JSON.parse(pact_content)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "when the pact does exist" do
|
25
|
+
|
26
|
+
before do
|
27
|
+
ProviderStateBuilder.new.create_pact_with_hierarchy "A Consumer", "1.2.3", "A Provider"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns a 200 Success" do
|
31
|
+
expect(subject.status).to be 200
|
32
|
+
end
|
33
|
+
|
34
|
+
it "returns a json body" do
|
35
|
+
expect(subject.headers['Content-Type']).to eq "application/json"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns the pact in the body" do
|
39
|
+
expect(response_body_json).to include JSON.parse(pact_content)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'pact_broker/api/decorators/latest_pact_decorator'
|
3
|
+
|
4
|
+
module PactBroker
|
5
|
+
|
6
|
+
module Api
|
7
|
+
|
8
|
+
module Decorators
|
9
|
+
|
10
|
+
describe LatestPactDecorator do
|
11
|
+
|
12
|
+
let(:pact) { RepresentablePact.new(ProviderStateBuilder.new.create_pact_with_hierarchy 'Consumer', '1.2.3', 'Provider') }
|
13
|
+
let(:base_url) { 'http://example.org' }
|
14
|
+
|
15
|
+
subject { JSON.parse LatestPactDecorator.new(pact).to_json(base_url: base_url), symbolize_names: true}
|
16
|
+
|
17
|
+
it "includes the createdAt date" do
|
18
|
+
expect(subject[:createdAt]).to_not be_nil
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when the updatedAt is the same as the createdAt" do
|
22
|
+
it "does not include the updatedAt date" do
|
23
|
+
expect(subject[:updatedAt]).to be_nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "when the updatedAt is not the same as the createdAt" do
|
28
|
+
let(:pact) do
|
29
|
+
pact = ProviderStateBuilder.new.create_pact_with_hierarchy 'Consumer', '1.2.3', 'Provider'
|
30
|
+
pact.updated_at = pact.created_at + 1
|
31
|
+
RepresentablePact.new(pact)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "includes the updatedAt date" do
|
35
|
+
expect(subject[:updatedAt]).to_not be_nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -43,6 +43,11 @@ module PactBroker
|
|
43
43
|
expect(subject[:_embedded][:consumerVersion][:_links][:self][:href]).to eq "http://example.org/pacticipants/Consumer/versions/1234"
|
44
44
|
end
|
45
45
|
|
46
|
+
it "includes timestamps" do
|
47
|
+
expect(subject[:createdAt]).to_not be_nil
|
48
|
+
expect(subject[:updatedAt]).to_not be_nil
|
49
|
+
end
|
50
|
+
|
46
51
|
end
|
47
52
|
end
|
48
53
|
end
|
@@ -16,8 +16,9 @@ module PactBroker
|
|
16
16
|
|
17
17
|
subject { JSON.parse PacticipantRepresenter.new(pacticipant).to_json, symbolize_names: true }
|
18
18
|
|
19
|
-
it "includes
|
19
|
+
it "includes timestamps" do
|
20
20
|
expect(subject[:createdAt]).to eq created_at.xmlschema
|
21
|
+
expect(subject[:updatedAt]).to eq updated_at.xmlschema
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
@@ -22,6 +22,8 @@ module PactBroker
|
|
22
22
|
|
23
23
|
let(:consumer) { Models::Pacticipant.new(name: 'Consumer') }
|
24
24
|
let(:provider) { Models::Pacticipant.new(name: 'Provider') }
|
25
|
+
let(:created_at) { DateTime.now }
|
26
|
+
let(:updated_at) { created_at + 1 }
|
25
27
|
|
26
28
|
let(:webhook) do
|
27
29
|
Models::Webhook.new(
|
@@ -29,8 +31,8 @@ module PactBroker
|
|
29
31
|
uuid: 'some-uuid',
|
30
32
|
consumer: consumer,
|
31
33
|
provider: provider,
|
32
|
-
created_at:
|
33
|
-
updated_at:
|
34
|
+
created_at: created_at,
|
35
|
+
updated_at: updated_at)
|
34
36
|
end
|
35
37
|
|
36
38
|
subject { WebhookDecorator.new(webhook) }
|
@@ -83,6 +85,11 @@ module PactBroker
|
|
83
85
|
expect(parsed_json[:_links][:execute][:href]).to eq 'http://example.org/webhooks/some-uuid/execute'
|
84
86
|
end
|
85
87
|
|
88
|
+
it "includes timestamps" do
|
89
|
+
expect(parsed_json[:createdAt]).to eq created_at.xmlschema
|
90
|
+
expect(parsed_json[:updatedAt]).to eq updated_at.xmlschema
|
91
|
+
end
|
92
|
+
|
86
93
|
context "when the headers are empty" do
|
87
94
|
let(:headers) { nil }
|
88
95
|
it "does not include the headers" do
|
@@ -6,8 +6,17 @@ module PactBroker
|
|
6
6
|
module Renderers
|
7
7
|
describe HtmlPactRenderer do
|
8
8
|
|
9
|
+
before do
|
10
|
+
ENV['BACKUP_TZ'] = ENV['TZ']
|
11
|
+
ENV['TZ'] = "Australia/Melbourne"
|
12
|
+
end
|
13
|
+
|
14
|
+
after do
|
15
|
+
ENV['TZ'] = ENV['BACKUP_TZ']
|
16
|
+
end
|
17
|
+
|
9
18
|
let(:consumer) { double('consumer', name: 'Consumer')}
|
10
|
-
let(:created_at) { DateTime.
|
19
|
+
let(:created_at) { DateTime.new(2014, 02, 27) }
|
11
20
|
let(:json_content) { load_fixture('renderer_pact.json') }
|
12
21
|
let(:pact) { double('pact', json_content: json_content, updated_at: created_at, consumer_version_number: '1.2.3', consumer: consumer)}
|
13
22
|
let(:pact_url) { '/pact/url' }
|
@@ -22,12 +31,14 @@ module PactBroker
|
|
22
31
|
it "renders the pact as HTML" do
|
23
32
|
expect(subject).to include("<html>")
|
24
33
|
expect(subject).to include("</html>")
|
25
|
-
expect(subject).to include(
|
26
|
-
expect(subject).to include(
|
34
|
+
expect(subject).to include("<link rel='stylesheet'")
|
35
|
+
expect(subject).to include("href='/stylesheets/github.css'")
|
27
36
|
expect(subject).to include('<pre><code')
|
28
37
|
expect(subject).to include('"method":')
|
29
38
|
expect(subject).to match /<h\d>.*Some Consumer/
|
30
39
|
expect(subject).to match /<h\d>.*Some Provider/
|
40
|
+
expect(subject).to include("Date published:")
|
41
|
+
expect(subject).to include("27/02/2014 11:00AM +11:00")
|
31
42
|
end
|
32
43
|
end
|
33
44
|
|
@@ -5,6 +5,90 @@ module PactBroker
|
|
5
5
|
module Repositories
|
6
6
|
describe PactRepository do
|
7
7
|
|
8
|
+
describe "create" do
|
9
|
+
let(:consumer) { PacticipantRepository.new.create name: 'Consumer' }
|
10
|
+
let(:provider) { PacticipantRepository.new.create name: 'Provider' }
|
11
|
+
let(:version) { VersionRepository.new.create number: '1.2.3', pacticipant_id: consumer.id }
|
12
|
+
let(:json_content) { {some: 'json'}.to_json }
|
13
|
+
|
14
|
+
subject { PactRepository.new.create version_id: version.id, provider_id: provider.id, json_content: json_content}
|
15
|
+
|
16
|
+
it "saves the pact" do
|
17
|
+
expect{subject}.to change{ Pact.count }.by(1)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "returns a Pact::Model" do
|
21
|
+
expect(subject).to be_instance_of(PactBroker::Models::Pact)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "sets all the Pact::Model attributes" do
|
25
|
+
expect(subject.consumer).to eq consumer
|
26
|
+
expect(subject.provider).to eq provider
|
27
|
+
expect(subject.consumer_version_number).to eq '1.2.3'
|
28
|
+
expect(subject.consumer_version).to eq version
|
29
|
+
expect(subject.json_content).to eq json_content
|
30
|
+
expect(subject.created_at).to be_instance_of(DateTime)
|
31
|
+
expect(subject.updated_at).to be_instance_of(DateTime)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "update" do
|
36
|
+
|
37
|
+
let(:existing_pact) do
|
38
|
+
ProviderStateBuilder.new.create_pact_with_hierarchy "A Consumer", "1.2.3", "A Provider"
|
39
|
+
end
|
40
|
+
|
41
|
+
before do
|
42
|
+
::DB::PACT_BROKER_DB[:pacts]
|
43
|
+
.where(id: existing_pact.id)
|
44
|
+
.update(
|
45
|
+
created_at: created_at,
|
46
|
+
updated_at: updated_at)
|
47
|
+
end
|
48
|
+
|
49
|
+
let(:created_at) { DateTime.new(2014, 3, 2) }
|
50
|
+
let(:updated_at) { DateTime.new(2014, 3, 4) }
|
51
|
+
|
52
|
+
let(:json_content) { {some: 'json'}.to_json }
|
53
|
+
|
54
|
+
subject { PactRepository.new.update existing_pact.id, json_content: json_content }
|
55
|
+
|
56
|
+
context "when the attributes have changed" do
|
57
|
+
|
58
|
+
it "updates the existing content" do
|
59
|
+
expect(subject.json_content).to eq json_content
|
60
|
+
end
|
61
|
+
|
62
|
+
it "updates the updated_at timestamp" do
|
63
|
+
expect(subject.updated_at).to_not eq updated_at
|
64
|
+
end
|
65
|
+
|
66
|
+
it "does not update the created_at timestamp" do
|
67
|
+
expect(subject.created_at).to eq created_at
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
context "when the attributes have not changed" do
|
73
|
+
before do
|
74
|
+
::DB::PACT_BROKER_DB[:pacts]
|
75
|
+
.where(id: existing_pact.id)
|
76
|
+
.update(
|
77
|
+
json_content: json_content)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "does not update the updated_at timestamp" do
|
81
|
+
expect(subject.updated_at).to eq updated_at
|
82
|
+
end
|
83
|
+
|
84
|
+
it "does not update the created_at timestamp" do
|
85
|
+
expect(subject.created_at).to eq created_at
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
8
92
|
describe "#find_all_pacts_between" do
|
9
93
|
let(:consumer_name) { 'Consumer' }
|
10
94
|
let(:provider_name) { 'Provider' }
|
@@ -81,8 +165,9 @@ module PactBroker
|
|
81
165
|
expect(latest_prod_pact.consumer_version.number).to eq("1.2.3")
|
82
166
|
end
|
83
167
|
|
84
|
-
|
85
|
-
|
168
|
+
it "has timestamps" do
|
169
|
+
expect(latest_prod_pact.created_at).to be_instance_of(DateTime)
|
170
|
+
expect(latest_prod_pact.updated_at).to be_instance_of(DateTime)
|
86
171
|
end
|
87
172
|
end
|
88
173
|
|
@@ -116,7 +201,6 @@ module PactBroker
|
|
116
201
|
expect(pacts[0].provider.name).to eq("Pricing Service")
|
117
202
|
expect(pacts[0].provider.id).to_not be nil
|
118
203
|
expect(pacts[0].consumer_version.number).to eq("1.4.0")
|
119
|
-
expect(pacts[0].consumer_version_number).to eq("1.4.0")
|
120
204
|
|
121
205
|
expect(pacts[1].consumer_version.pacticipant.name).to eq("Contract Email Service")
|
122
206
|
expect(pacts[1].consumer.name).to eq("Contract Email Service")
|
@@ -124,7 +208,7 @@ module PactBroker
|
|
124
208
|
expect(pacts[1].consumer_version.number).to eq("2.7.0")
|
125
209
|
end
|
126
210
|
|
127
|
-
|
211
|
+
it "includes the timestamps - need to update view" do
|
128
212
|
pacts = PactRepository.new.find_latest_pacts
|
129
213
|
|
130
214
|
expect(pacts[0].updated_at).to be_instance_of DateTime
|
@@ -37,6 +37,8 @@ module PactBroker
|
|
37
37
|
expect(find_tag.name).to eq tag_name
|
38
38
|
expect(find_tag.version.number).to eq version_number
|
39
39
|
expect(find_tag.version.pacticipant.name).to eq pacticipant_name
|
40
|
+
expect(find_tag.created_at).to be_instance_of(DateTime)
|
41
|
+
expect(find_tag.updated_at).to be_instance_of(DateTime)
|
40
42
|
end
|
41
43
|
|
42
44
|
end
|
@@ -5,10 +5,27 @@ module PactBroker
|
|
5
5
|
module Repositories
|
6
6
|
describe VersionRepository do
|
7
7
|
|
8
|
+
let(:pacticipant_name) { "test_pacticipant" }
|
9
|
+
let(:version_number) { "1.2.3" }
|
10
|
+
|
11
|
+
describe "#create" do
|
12
|
+
context "when a previous version exists" do
|
13
|
+
|
14
|
+
let!(:existing_order) do
|
15
|
+
ProviderStateBuilder.new.create_version_with_hierarchy pacticipant_name, version_number
|
16
|
+
end
|
17
|
+
|
18
|
+
subject { VersionRepository.new.create pacticipant_id: existing_order.pacticipant_id, number: "1.2.4" }
|
19
|
+
|
20
|
+
it "sets the order to the previous version's order plus one" do
|
21
|
+
expect(subject.order).to eq existing_order.order + 1
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
8
27
|
describe "#find_by_pacticipant_name_and_number" do
|
9
28
|
|
10
|
-
let(:pacticipant_name) { "test_pacticipant" }
|
11
|
-
let(:version_number) { "1.2.3" }
|
12
29
|
|
13
30
|
subject { described_class.new.find_by_pacticipant_name_and_number pacticipant_name, version_number }
|
14
31
|
|
@@ -21,6 +38,7 @@ module PactBroker
|
|
21
38
|
it "returns the version" do
|
22
39
|
expect(subject.number).to eq version_number
|
23
40
|
expect(subject.pacticipant.name).to eq pacticipant_name
|
41
|
+
expect(subject.order).to eq 0
|
24
42
|
end
|
25
43
|
end
|
26
44
|
|
@@ -1,27 +1,12 @@
|
|
1
1
|
require './spec/spec_helper'
|
2
2
|
require 'pact/provider/rspec'
|
3
|
-
require 'sequel'
|
4
|
-
require 'db'
|
5
|
-
require 'pact_broker/api'
|
6
|
-
require 'uri'
|
7
|
-
require_relative 'provider_states_for_pact_broker_client'
|
8
|
-
|
9
|
-
require 'pact_broker/api/resources/pact'
|
10
3
|
|
11
|
-
|
12
|
-
config.logger.level = Logger::DEBUG
|
13
|
-
#config.diff_format = :plus_and_minus
|
14
|
-
end
|
4
|
+
require_relative 'provider_states_for_pact_broker_client'
|
15
5
|
|
16
6
|
Pact.service_provider "Pact Broker" do
|
17
|
-
# app { PactBroker::API }
|
18
7
|
|
19
8
|
honours_pact_with "Pact Broker Client" do
|
20
|
-
pact_uri "
|
9
|
+
pact_uri "https://raw.githubusercontent.com/bethesque/pact_broker-client/master/spec/pacts/pact_broker_client-pact_broker.json"
|
21
10
|
end
|
22
11
|
|
23
|
-
# honours_pact_with "Pact Broker Client", :ref => :head do
|
24
|
-
# pact_uri URI.encode("http://rea-pact-broker.biq.vpc.realestate.com.au/pacts/provider/Pact Broker/consumer/Pact Broker Client/latest")
|
25
|
-
# end
|
26
|
-
|
27
12
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,45 +4,27 @@ RACK_ENV = 'test'
|
|
4
4
|
$: << File.expand_path("../../", __FILE__)
|
5
5
|
require 'rack/test'
|
6
6
|
require 'db'
|
7
|
-
require 'support/provider_state_builder'
|
8
|
-
require 'support/shared_examples_for_responses'
|
9
7
|
require 'pact_broker/api'
|
10
8
|
require 'rspec/its'
|
11
9
|
|
10
|
+
Dir.glob("./spec/support/**/*.rb") { |file| require file }
|
11
|
+
|
12
12
|
YAML::ENGINE.yamler = 'psych'
|
13
13
|
I18n.config.enforce_available_locales = false
|
14
14
|
|
15
|
-
def load_fixture(file_name)
|
16
|
-
File.read(File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', file_name)))
|
17
|
-
end
|
18
|
-
|
19
|
-
def load_json_fixture(file_name)
|
20
|
-
require 'json'
|
21
|
-
JSON.parse(load_fixture(file_name))
|
22
|
-
end
|
23
|
-
|
24
15
|
RSpec.configure do | config |
|
25
16
|
config.before :suite do
|
26
17
|
raise "Wrong environment!!! Don't run this script!! ENV['RACK_ENV'] is #{ENV['RACK_ENV']} and RACK_ENV is #{RACK_ENV}" if ENV['RACK_ENV'] != 'test' || RACK_ENV != 'test'
|
27
18
|
PactBroker::DB.connection = DB::PACT_BROKER_DB
|
28
19
|
end
|
29
20
|
|
30
|
-
|
31
|
-
config.before :each do
|
32
|
-
# TODO: Change this to transactional!
|
33
|
-
DB::PACT_BROKER_DB[:webhook_headers].truncate
|
34
|
-
DB::PACT_BROKER_DB[:webhooks].truncate
|
35
|
-
DB::PACT_BROKER_DB[:pacts].truncate
|
36
|
-
DB::PACT_BROKER_DB[:tags].truncate
|
37
|
-
DB::PACT_BROKER_DB[:versions].truncate
|
38
|
-
DB::PACT_BROKER_DB[:pacticipants].truncate
|
39
|
-
end
|
40
|
-
|
41
21
|
config.include Rack::Test::Methods
|
42
22
|
config.mock_with :rspec do |mocks|
|
43
23
|
mocks.verify_partial_doubles = true
|
44
24
|
end
|
45
25
|
|
26
|
+
config.include FixtureHelpers
|
27
|
+
|
46
28
|
def app
|
47
29
|
PactBroker::API
|
48
30
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'database_cleaner'
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.before(:suite) do
|
5
|
+
if defined?(::DB)
|
6
|
+
DatabaseCleaner.strategy = :transaction
|
7
|
+
DatabaseCleaner.clean_with :truncation
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
config.before(:each) do
|
12
|
+
DatabaseCleaner.start if defined?(::DB)
|
13
|
+
end
|
14
|
+
|
15
|
+
config.after(:each) do
|
16
|
+
DatabaseCleaner.clean if defined?(::DB)
|
17
|
+
end
|
18
|
+
end
|