-
-
Notifications
You must be signed in to change notification settings - Fork 178
/
Copy pathcan_i_deploy_spec.rb
43 lines (36 loc) · 1.47 KB
/
can_i_deploy_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require "pact_broker/domain"
PACTICIPANT_LIMIT = 10
VERSION_LIMIT = 10
PACTICIPANTS = PactBroker::Domain::Pacticipant.order(Sequel.desc(:id)).limit(PACTICIPANT_LIMIT).all
RSpec.describe "regression tests" do
def can_i_deploy(pacticipant_name, version_number, to_tag)
get("/can-i-deploy", { pacticipant: pacticipant_name, version: version_number, to: to_tag }, { "HTTP_ACCEPT" => "application/hal+json" })
end
PACTICIPANTS.each do | pacticipant |
describe pacticipant.name do
versions = PactBroker::Domain::Version.where(pacticipant_id: pacticipant.id).order(Sequel.desc(:order)).limit(VERSION_LIMIT)
versions.each do | version |
describe "version #{version.number}" do
it "has the same results for can-i-deploy" do
can_i_deploy_response = can_i_deploy(pacticipant.name, version.number, "prod")
results = {
request: {
name: "can-i-deploy",
params: {
pacticipant_name: pacticipant.name,
version_number: version.number,
to_tag: "prod"
}
},
response: {
status: can_i_deploy_response.status,
body: JSON.parse(can_i_deploy_response.body)
}
}
Approvals.verify(results, :name => "regression_can_i_deploy_#{pacticipant.name}_version_#{version.number}", format: :json)
end
end
end
end
end
end