pact_broker-client 1.40.0 → 1.45.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +21 -0
  3. data/.gitignore +1 -0
  4. data/CHANGELOG.md +57 -0
  5. data/Gemfile +4 -0
  6. data/README.md +39 -22
  7. data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +79 -280
  8. data/lib/pact_broker/client/backports.rb +9 -0
  9. data/lib/pact_broker/client/base_command.rb +98 -0
  10. data/lib/pact_broker/client/can_i_deploy.rb +57 -5
  11. data/lib/pact_broker/client/cli/broker.rb +23 -76
  12. data/lib/pact_broker/client/cli/custom_thor.rb +12 -0
  13. data/lib/pact_broker/client/cli/deployment_commands.rb +94 -0
  14. data/lib/pact_broker/client/cli/environment_commands.rb +70 -0
  15. data/lib/pact_broker/client/cli/pacticipant_commands.rb +53 -0
  16. data/lib/pact_broker/client/cli/record_deployment_long_desc.txt +0 -55
  17. data/lib/pact_broker/client/cli/version_selector_options_parser.rb +4 -0
  18. data/lib/pact_broker/client/colorize_notices.rb +31 -0
  19. data/lib/pact_broker/client/deployments.rb +4 -0
  20. data/lib/pact_broker/client/deployments/record_deployment.rb +38 -0
  21. data/lib/pact_broker/client/deployments/record_release.rb +99 -0
  22. data/lib/pact_broker/client/deployments/record_support_ended.rb +103 -0
  23. data/lib/pact_broker/client/deployments/record_undeployment.rb +127 -0
  24. data/lib/pact_broker/client/describe_text_formatter.rb +23 -0
  25. data/lib/pact_broker/client/environments.rb +6 -0
  26. data/lib/pact_broker/client/environments/create_environment.rb +31 -0
  27. data/lib/pact_broker/client/environments/delete_environment.rb +27 -0
  28. data/lib/pact_broker/client/environments/describe_environment.rb +26 -0
  29. data/lib/pact_broker/client/environments/environment_command.rb +66 -0
  30. data/lib/pact_broker/client/environments/list_environments.rb +30 -0
  31. data/lib/pact_broker/client/environments/text_formatter.rb +30 -0
  32. data/lib/pact_broker/client/environments/update_environment.rb +31 -0
  33. data/lib/pact_broker/client/generate_display_name.rb +27 -0
  34. data/lib/pact_broker/client/hal/entity.rb +31 -6
  35. data/lib/pact_broker/client/hal/http_client.rb +8 -2
  36. data/lib/pact_broker/client/hal/link.rb +8 -0
  37. data/lib/pact_broker/client/hal_client_methods.rb +1 -3
  38. data/lib/pact_broker/client/matrix.rb +4 -0
  39. data/lib/pact_broker/client/matrix/abbreviate_version_number.rb +15 -0
  40. data/lib/pact_broker/client/matrix/resource.rb +26 -1
  41. data/lib/pact_broker/client/matrix/text_formatter.rb +28 -17
  42. data/lib/pact_broker/client/pacticipants.rb +6 -0
  43. data/lib/pact_broker/client/pacticipants/create.rb +24 -34
  44. data/lib/pact_broker/client/pacticipants/describe.rb +33 -0
  45. data/lib/pact_broker/client/pacticipants/list.rb +34 -0
  46. data/lib/pact_broker/client/pacticipants/text_formatter.rb +41 -0
  47. data/lib/pact_broker/client/publish_pacts.rb +6 -2
  48. data/lib/pact_broker/client/string_refinements.rb +56 -0
  49. data/lib/pact_broker/client/version.rb +1 -1
  50. data/lib/pact_broker/client/versions.rb +4 -1
  51. data/lib/pact_broker/client/versions/describe.rb +3 -1
  52. data/lib/pact_broker/client/versions/formatter.rb +3 -1
  53. data/lib/pact_broker/client/versions/json_formatter.rb +5 -3
  54. data/lib/pact_broker/client/versions/text_formatter.rb +3 -1
  55. data/pact-broker-client.gemspec +2 -0
  56. data/script/approve-all.sh +6 -0
  57. data/script/publish-pact.sh +12 -9
  58. data/script/record-deployments-and-releases.sh +18 -0
  59. data/spec/fixtures/approvals/can_i_deploy_failure_dry_run.approved.txt +7 -0
  60. data/spec/fixtures/approvals/can_i_deploy_ignore.approved.txt +13 -0
  61. data/spec/fixtures/approvals/can_i_deploy_success_dry_run.approved.txt +7 -0
  62. data/spec/fixtures/approvals/describe_environment.approved.txt +7 -0
  63. data/spec/fixtures/approvals/describe_pacticipant.approved.txt +2 -0
  64. data/spec/fixtures/approvals/list_environments.approved.txt +3 -0
  65. data/spec/integration/describe_environment_spec.rb +31 -0
  66. data/spec/lib/pact_broker/client/can_i_deploy_spec.rb +109 -7
  67. data/spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb +19 -6
  68. data/spec/lib/pact_broker/client/cli/broker_publish_spec.rb +1 -1
  69. data/spec/lib/pact_broker/client/cli/broker_run_webhook_commands_spec.rb +3 -3
  70. data/spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb +21 -0
  71. data/spec/lib/pact_broker/client/deployments/record_deployment_spec.rb +204 -0
  72. data/spec/lib/pact_broker/client/deployments/record_support_ended_spec.rb +208 -0
  73. data/spec/lib/pact_broker/client/deployments/record_undeployment_spec.rb +219 -0
  74. data/spec/lib/pact_broker/client/environments/delete_environment_spec.rb +120 -0
  75. data/spec/lib/pact_broker/client/environments/describe_environment_spec.rb +89 -0
  76. data/spec/lib/pact_broker/client/environments/update_environment_spec.rb +167 -0
  77. data/spec/lib/pact_broker/client/generate_display_name_spec.rb +39 -0
  78. data/spec/lib/pact_broker/client/hal/entity_spec.rb +2 -2
  79. data/spec/lib/pact_broker/client/pacticipants/create_spec.rb +2 -2
  80. data/spec/pacts/pact_broker_client-pact_broker.json +88 -287
  81. data/spec/service_providers/create_environment_spec.rb +78 -0
  82. data/spec/service_providers/list_environments_spec.rb +77 -0
  83. data/spec/service_providers/pact_broker_client_matrix_ignore_spec.rb +98 -0
  84. data/spec/service_providers/pact_broker_client_register_repository_spec.rb +2 -2
  85. data/spec/service_providers/pacticipants_create_spec.rb +5 -4
  86. data/spec/service_providers/publish_pacts_spec.rb +5 -2
  87. data/spec/service_providers/record_deployment_spec.rb +17 -36
  88. data/spec/service_providers/record_release_spec.rb +132 -0
  89. data/spec/service_providers/record_undeployment_spec.rb +166 -0
  90. data/spec/spec_helper.rb +15 -2
  91. data/spec/support/approvals.rb +26 -0
  92. data/spec/support/shared_context.rb +8 -3
  93. data/tasks/pact.rake +21 -1
  94. metadata +104 -7
  95. data/lib/pact_broker/client/versions/record_deployment.rb +0 -109
  96. data/lib/pact_broker/client/versions/record_undeployment.rb +0 -102
  97. data/spec/lib/pact_broker/client/versions/record_deployment_spec.rb +0 -82
@@ -0,0 +1,127 @@
1
+ require 'pact_broker/client/base_command'
2
+
3
+ module PactBroker
4
+ module Client
5
+ module Deployments
6
+ class RecordUndeployment < PactBroker::Client::BaseCommand
7
+ def initialize(params, options, pact_broker_client_options)
8
+ super
9
+ @pacticipant_name = params.fetch(:pacticipant_name)
10
+ @environment_name = params.fetch(:environment_name)
11
+ @target = params.fetch(:target)
12
+ end
13
+
14
+ private
15
+
16
+ def do_call
17
+ if undeployed_versions_resources.empty?
18
+ PactBroker::Client::CommandResult.new(false, error_result_message)
19
+ else
20
+ PactBroker::Client::CommandResult.new(undeployed_versions_resources.all?(&:success?), result_message)
21
+ end
22
+ end
23
+
24
+ attr_reader :pacticipant_name, :environment_name, :target
25
+
26
+ def currently_deployed_versions_link
27
+ environment_resource._link("pb:currently-deployed-versions") or raise PactBroker::Client::Error.new(not_supported_message)
28
+ end
29
+
30
+ def currently_deployed_version_entities_for_pacticipant
31
+ @deployed_version_links ||= currently_deployed_versions_link.get!(pacticipant: pacticipant_name).embedded_entities!("deployedVersions")
32
+ end
33
+
34
+ def currently_deployed_version_entities_for_pacticipant_and_target
35
+ currently_deployed_version_entities_for_pacticipant.select do | entity |
36
+ entity.target == target
37
+ end
38
+ end
39
+
40
+ def undeployed_versions_resources
41
+ @undeployed_versions_resources ||= currently_deployed_version_entities_for_pacticipant_and_target.collect do | entity |
42
+ entity._link!("self").patch(currentlyDeployed: false)
43
+ end
44
+ end
45
+
46
+ def action
47
+ "undeployment"
48
+ end
49
+
50
+ def environment_resource
51
+ index_resource
52
+ ._link!("pb:environments")
53
+ .get!
54
+ ._links("pb:environments")
55
+ .find!(environment_name, "No environment found with name '#{environment_name}'")
56
+ .get!
57
+ end
58
+
59
+ def result_message
60
+ if json_output?
61
+ undeployed_versions_resources.collect{ | resource | resource.response.body }.to_a.to_json
62
+ else
63
+ undeployed_versions_resources.collect do | undeployed_versions_resource |
64
+ if undeployed_versions_resource.success?
65
+ green("#{success_result_text_message(undeployed_versions_resource)} in #{pact_broker_name}.")
66
+ else
67
+ red(undeployed_versions_resource.error_message)
68
+ end
69
+ end.join("\n")
70
+ end
71
+ end
72
+
73
+ def success_result_text_message(undeployed_versions_resource)
74
+ version = undeployed_versions_resource.embedded_entity{ | embedded_entity| embedded_entity && embedded_entity['version'] }
75
+ message = "Recorded #{action} of #{pacticipant_name}"
76
+ message = "#{message} version #{version.number}" if (version && version.number)
77
+ message = "#{message} from #{environment_name} environment"
78
+ message = "#{message} (target #{target})" if target
79
+ message
80
+ end
81
+
82
+ def error_result_message
83
+ if json_output?
84
+ error_message_as_json(error_text)
85
+ else
86
+ red(error_text)
87
+ end
88
+ end
89
+
90
+ def error_text
91
+ if pacticipant_does_not_exist?
92
+ "No pacticipant with name '#{pacticipant_name}' found."
93
+ else
94
+ if currently_deployed_version_entities_for_pacticipant.any?
95
+ target_does_not_match_message
96
+ else
97
+ "#{pacticipant_name} is not currently deployed to #{environment_name} environment. Cannot record undeployment."
98
+ end
99
+ end
100
+ end
101
+
102
+ def target_does_not_match_message
103
+ potential_targets = currently_deployed_version_entities_for_pacticipant.collect(&:target).collect { |target| target || "<no target>"}
104
+ if target
105
+ "#{pacticipant_name} is not currently deployed to target '#{target}' in #{environment_name} environment. Please specify one of the following targets to record the undeployment from: #{potential_targets.join(", ")}"
106
+ else
107
+ "Please specify one of the following targets to record the undeployment from: #{potential_targets.join(", ")}"
108
+ end
109
+ end
110
+
111
+ def not_supported_message
112
+ "This version of the Pact Broker does not support recording undeployments. Please upgrade to version 2.80.0 or later."
113
+ end
114
+
115
+ def pacticipant_does_not_exist?
116
+ index_resource._link("pb:pacticipant") && index_resource._link("pb:pacticipant").expand(pacticipant: pacticipant_name).get.does_not_exist?
117
+ end
118
+
119
+ def check_if_command_supported
120
+ unless index_resource.can?("pb:environments")
121
+ raise PactBroker::Client::Error.new(not_supported_message)
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,23 @@
1
+ require 'yaml'
2
+ require 'pact_broker/client/generate_display_name'
3
+
4
+ module PactBroker
5
+ module Client
6
+ class DescribeTextFormatter
7
+ extend GenerateDisplayName
8
+
9
+ def self.call(properties)
10
+ YAML.dump(displayify_keys(properties)).gsub("---\n", "")
11
+ end
12
+
13
+ def self.displayify_keys(thing)
14
+ case thing
15
+ when Hash then thing.each_with_object({}) { | (key, value), new_hash | new_hash[generate_display_name(key)] = displayify_keys(value) }
16
+ when Array then thing.collect{ | value | displayify_keys(value) }
17
+ else
18
+ thing
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,6 @@
1
+ require 'pact_broker/client/environments/create_environment'
2
+ require 'pact_broker/client/environments/delete_environment'
3
+ require 'pact_broker/client/environments/describe_environment'
4
+ require 'pact_broker/client/environments/list_environments'
5
+ require 'pact_broker/client/environments/update_environment'
6
+
@@ -0,0 +1,31 @@
1
+ require 'pact_broker/client/environments/environment_command'
2
+
3
+ module PactBroker
4
+ module Client
5
+ module Environments
6
+ class CreateEnvironment < PactBroker::Client::Environments::EnvironmentCommand
7
+
8
+ private
9
+
10
+ attr_reader :created_environment_resource
11
+
12
+ def do_call
13
+ @created_environment_resource = environments_link.post!(new_environment_body)
14
+ PactBroker::Client::CommandResult.new(created_environment_resource.success?, result_message)
15
+ end
16
+
17
+ def result_message
18
+ if json_output?
19
+ created_environment_resource.response.raw_body
20
+ else
21
+ ::Term::ANSIColor.green("Created #{params[:name]} environment in #{pact_broker_name} with UUID #{uuid}")
22
+ end
23
+ end
24
+
25
+ def uuid
26
+ created_environment_resource.uuid
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,27 @@
1
+ require 'pact_broker/client/environments/environment_command'
2
+
3
+ module PactBroker
4
+ module Client
5
+ module Environments
6
+ class DeleteEnvironment < PactBroker::Client::Environments::EnvironmentCommand
7
+ private
8
+
9
+ attr_reader :deletion_request_resource
10
+
11
+ def do_call
12
+ existing_environment_resource!
13
+ @deletion_request_resource = existing_environment_link.delete!
14
+ PactBroker::Client::CommandResult.new(deletion_request_resource.success?, result_message)
15
+ end
16
+
17
+ def result_message
18
+ if json_output?
19
+ deletion_request_resource.response.raw_body
20
+ else
21
+ ::Term::ANSIColor.green("Deleted environment #{existing_environment_resource.name} from #{pact_broker_name}")
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ require 'pact_broker/client/environments/environment_command'
2
+ require 'pact_broker/client/describe_text_formatter'
3
+
4
+ module PactBroker
5
+ module Client
6
+ module Environments
7
+ class DescribeEnvironment < PactBroker::Client::Environments::EnvironmentCommand
8
+ private
9
+
10
+ def do_call
11
+ existing_environment_resource!
12
+ PactBroker::Client::CommandResult.new(true, result_message)
13
+ end
14
+
15
+ def result_message
16
+ if json_output?
17
+ existing_environment_resource.response.raw_body
18
+ else
19
+ properties = existing_environment_resource.response.body.except("_links", "_embedded")
20
+ PactBroker::Client::DescribeTextFormatter.call(properties)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,66 @@
1
+ require 'pact_broker/client/base_command'
2
+
3
+ module PactBroker
4
+ module Client
5
+ module Environments
6
+ class EnvironmentCommand < PactBroker::Client::BaseCommand
7
+ NOT_SUPPORTED_MESSAGE = "This version of the Pact Broker does not support environments. Please upgrade to version 2.80.0 or later."
8
+
9
+ private
10
+
11
+ def new_environment_body
12
+ {
13
+ "name" => params[:name],
14
+ "displayName" => params[:display_name],
15
+ "production" => params[:production],
16
+ "contacts" => contacts
17
+ }.compact
18
+ end
19
+
20
+ def environments_link
21
+ index_resource._link!("pb:environments")
22
+ end
23
+
24
+ def existing_environment_link
25
+ index_resource
26
+ ._link!("pb:environment")
27
+ .expand(uuid: params[:uuid])
28
+ end
29
+
30
+ def existing_environment_resource
31
+ @existing_environment_resource ||= existing_environment_link.get
32
+ end
33
+
34
+ def existing_environment_resource!
35
+ existing_environment_resource.assert_success!
36
+ end
37
+
38
+ def existing_environment_body
39
+ @existing_environment_params ||= existing_environment_resource!
40
+ .response
41
+ .body
42
+ .except("uuid", "_links", "createdAt", "updatedAt")
43
+ end
44
+
45
+ def contacts
46
+ if params[:contact_name] || params[:contact_email_address]
47
+ contact = {}
48
+ contact["name"] = params[:contact_name] || "unknown"
49
+ if params[:contact_email_address]
50
+ contact["details"] = { "emailAddress" => params[:contact_email_address] }
51
+ end
52
+ [contact]
53
+ else
54
+ nil
55
+ end
56
+ end
57
+
58
+ def check_if_command_supported
59
+ unless index_resource.can?("pb:environments")
60
+ raise PactBroker::Client::Error.new(NOT_SUPPORTED_MESSAGE)
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,30 @@
1
+ require 'pact_broker/client/environments/environment_command'
2
+ require 'pact_broker/client/environments/text_formatter'
3
+
4
+ module PactBroker
5
+ module Client
6
+ module Environments
7
+ class ListEnvironments < PactBroker::Client::Environments::EnvironmentCommand
8
+ private
9
+
10
+ attr_reader :environments_resource
11
+
12
+ def do_call
13
+ PactBroker::Client::CommandResult.new(true, result_message)
14
+ end
15
+
16
+ def environments_resource
17
+ @environments_resource = environments_link.get!
18
+ end
19
+
20
+ def result_message
21
+ if json_output?
22
+ environments_resource.response.raw_body
23
+ else
24
+ PactBroker::Client::Environments::TextFormatter.call(environments_resource._embedded["environments"])
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ require 'table_print'
2
+ require 'ostruct'
3
+
4
+ module PactBroker
5
+ module Client
6
+ module Environments
7
+ class TextFormatter
8
+
9
+ def self.call(environments)
10
+ return "" if environments.size == 0
11
+
12
+ data = environments.collect do | environment |
13
+ OpenStruct.new(environment)
14
+ end.sort_by{ | environment | environment.name.downcase }
15
+
16
+ uuid_width = data.collect(&:uuid).collect(&:size).max
17
+
18
+ tp_options = [
19
+ { uuid: { width: uuid_width } },
20
+ { name: {} },
21
+ { displayName: { display_name: "Display name" } },
22
+ { production: {} }
23
+ ]
24
+
25
+ TablePrint::Printer.new(data, tp_options).table_print
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,31 @@
1
+ require 'pact_broker/client/environments/environment_command'
2
+
3
+ module PactBroker
4
+ module Client
5
+ module Environments
6
+ class UpdateEnvironment < PactBroker::Client::Environments::EnvironmentCommand
7
+
8
+ private
9
+
10
+ attr_reader :updated_environment_resource
11
+
12
+ def do_call
13
+ @updated_environment_resource = existing_environment_link.put!(request_body)
14
+ PactBroker::Client::CommandResult.new(updated_environment_resource.success?, result_message)
15
+ end
16
+
17
+ def request_body
18
+ @request_body ||= existing_environment_body.merge(new_environment_body)
19
+ end
20
+
21
+ def result_message
22
+ if json_output?
23
+ updated_environment_resource.response.raw_body
24
+ else
25
+ ::Term::ANSIColor.green("Updated #{request_body["name"]} environment in #{pact_broker_name}")
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,27 @@
1
+ require 'pact_broker/client/string_refinements'
2
+
3
+ module PactBroker
4
+ module Client
5
+ module GenerateDisplayName
6
+ using PactBroker::Client::StringRefinements
7
+
8
+ def self.call(name)
9
+ return nil if name.nil?
10
+ name
11
+ .to_s
12
+ .gsub(/([A-Z])([A-Z])([a-z])/,'\1 \2\3')
13
+ .gsub(/([a-z\d])([A-Z])(\S)/,'\1 \2\3')
14
+ .gsub(/(\S)([\-_\s\.])(\S)/, '\1 \3')
15
+ .gsub(/\s+/, " ")
16
+ .strip
17
+ .split(" ")
18
+ .collect{ |word| word.camelcase(true) }
19
+ .join(" ")
20
+ end
21
+
22
+ def generate_display_name(name)
23
+ GenerateDisplayName.call(name)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -8,7 +8,15 @@ module PactBroker
8
8
  module Client
9
9
  module Hal
10
10
  class RelationNotFoundError < ::PactBroker::Client::Error; end
11
- class ErrorResponseReturned < ::PactBroker::Client::Error; end
11
+ class EmbeddedEntityNotFoundError < ::PactBroker::Client::Error; end
12
+ class ErrorResponseReturned < ::PactBroker::Client::Error
13
+ attr_reader :entity
14
+
15
+ def initialize(message, entity)
16
+ super(message)
17
+ @entity = entity
18
+ end
19
+ end
12
20
 
13
21
  class Entity
14
22
  def initialize(href, data, http_client, response = nil)
@@ -92,7 +100,17 @@ module PactBroker
92
100
 
93
101
  def embedded_entity
94
102
  embedded_ent = yield @data["_embedded"]
95
- Entity.new(embedded_ent["_links"]["self"]["href"], embedded_ent, @client, response)
103
+ if embedded_ent
104
+ Entity.new(self_href(embedded_ent), embedded_ent, @client, response)
105
+ end
106
+ end
107
+
108
+ def embedded_entities!(key)
109
+ embedded_ents = (@data["_embedded"] && @data["_embedded"][key])
110
+ raise EmbeddedEntityNotFoundError.new("Could not find embedded entity with key '#{key}' in resource at #{@href}") unless embedded_ents
111
+ embedded_ents.collect do | embedded_ent |
112
+ Entity.new(self_href(embedded_ent), embedded_ent, @client, response)
113
+ end
96
114
  end
97
115
 
98
116
  def embedded_entities(key = nil)
@@ -102,7 +120,7 @@ module PactBroker
102
120
  yield @data["_embedded"]
103
121
  end
104
122
  embedded_ents.collect do | embedded_ent |
105
- Entity.new(embedded_ent["_links"]["self"]["href"], embedded_ent, @client, response)
123
+ Entity.new(self_href(embedded_ent), embedded_ent, @client, response)
106
124
  end
107
125
  end
108
126
 
@@ -139,6 +157,10 @@ module PactBroker
139
157
  def assert_success!(_ignored = nil)
140
158
  self
141
159
  end
160
+
161
+ def self_href(entity_hash)
162
+ entity_hash["_links"] && entity_hash["_links"]["self"] && entity_hash["_links"]["self"]["href"]
163
+ end
142
164
  end
143
165
 
144
166
  class ErrorEntity < Entity
@@ -158,14 +180,17 @@ module PactBroker
158
180
  false
159
181
  end
160
182
 
161
- def assert_success!(messages = {})
162
- default_message = "Error retrieving #{@href} status=#{response ? response.status: nil} #{response ? response.raw_body : ''}".strip
183
+ def error_message(messages = {})
184
+ default_message = "Error making request to #{@href} status=#{response ? response.status: nil} #{response ? response.raw_body : ''}".strip
163
185
  message = if response && messages[response.status]
164
186
  (messages[response.status] || "") + " (#{default_message})"
165
187
  else
166
188
  default_message
167
189
  end
168
- raise ErrorResponseReturned.new(message)
190
+ end
191
+
192
+ def assert_success!(messages = {})
193
+ raise ErrorResponseReturned.new(error_message(messages), self)
169
194
  end
170
195
  end
171
196
  end