bugsnag-maze-runner 7.33.1 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/bin/maze-runner +9 -1
  3. data/bin/purge-projects +66 -0
  4. data/lib/features/steps/app_automator_steps.rb +9 -3
  5. data/lib/features/steps/header_steps.rb +13 -9
  6. data/lib/features/steps/multipart_request_steps.rb +10 -10
  7. data/lib/features/steps/network_steps.rb +7 -24
  8. data/lib/features/steps/payload_steps.rb +21 -21
  9. data/lib/features/steps/query_parameter_steps.rb +3 -3
  10. data/lib/features/steps/request_assertion_steps.rb +11 -18
  11. data/lib/features/steps/trace_steps.rb +0 -8
  12. data/lib/features/steps/value_steps.rb +9 -9
  13. data/lib/features/support/cucumber_types.rb +20 -0
  14. data/lib/features/support/internal_hooks.rb +0 -2
  15. data/lib/maze/api/appium/file_manager.rb +1 -1
  16. data/lib/maze/appium_server.rb +2 -2
  17. data/lib/maze/client/appium/bb_client.rb +1 -1
  18. data/lib/maze/client/appium/bb_devices.rb +1 -1
  19. data/lib/maze/client/appium/bs_devices.rb +7 -9
  20. data/lib/maze/client/bb_api_client.rb +46 -9
  21. data/lib/maze/client/bb_client_utils.rb +1 -61
  22. data/lib/maze/client/selenium/bb_client.rb +1 -6
  23. data/lib/maze/client/selenium/bs_browsers.yml +11 -11
  24. data/lib/maze/configuration.rb +0 -6
  25. data/lib/maze/logger.rb +29 -1
  26. data/lib/maze/option/parser.rb +39 -14
  27. data/lib/maze/option/processor.rb +2 -5
  28. data/lib/maze/option/validator.rb +3 -7
  29. data/lib/maze/option.rb +2 -6
  30. data/lib/maze/repeaters/request_repeater.rb +1 -1
  31. data/lib/maze/schemas/trace_validator.rb +0 -2
  32. data/lib/maze/server.rb +13 -3
  33. data/lib/maze/servlets/servlet.rb +13 -10
  34. data/lib/maze/servlets/trace_servlet.rb +15 -0
  35. data/lib/maze/terminating_server.rb +1 -1
  36. data/lib/maze.rb +1 -1
  37. metadata +5 -3
  38. data/lib/maze/plugins/cucumber_report_plugin.rb +0 -101
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c0fe6adceef2d36fc8b8f708724e5d84c34d98faf6c117f66fa25d7435a2a5b
4
- data.tar.gz: 47c7bdf5d1e073fa728058cdb89ef91beef450d4b24eb5c5b0ed225d8dd89450
3
+ metadata.gz: 1a8fe53083056182a02bfe2c64ef7e5f16a94dc9a2cf7908e07be82d630aa7ca
4
+ data.tar.gz: 232d9f91e5c489994e6b63a3f09f7b21edad67c01d88270b4365707cb5808c1c
5
5
  SHA512:
6
- metadata.gz: 5731f8dc95636f088b60f7c7d43643f86888d9488d9b3668290f62f12c59eba98c15f0247a3503e099471c0a5cf439f26603a37804476d003fec86040b489e8c
7
- data.tar.gz: 384e4a79f84d08fd9917e2e2ad4943a13c0ad8098bee5a58e060f1b2f138f24df700d449d758a5666f8250f93ca6d7cc4a05e545b25d4ae38565b8ea70d32334
6
+ metadata.gz: 9a4dd6596a3dd44a6090d7c84155e3e30f2cff5b530a5b765df9e4fedce1aa153c6120604b555e44b3933dd5567479dc0b509b84ba5be8624b6e735b7d3316c0
7
+ data.tar.gz: 501886299af0b042122474462a4fa92ac920d64122da62129bf35f8a624786dd158c88572ae4dafdbc66e023536193a6adb5979fdbd0a319fea9ca0e9ea680dd
data/bin/maze-runner CHANGED
@@ -84,7 +84,6 @@ require_relative '../lib/maze/driver/appium'
84
84
  require_relative '../lib/maze/driver/browser'
85
85
 
86
86
  require_relative '../lib/maze/plugins/bugsnag_reporting_plugin'
87
- require_relative '../lib/maze/plugins/cucumber_report_plugin'
88
87
  require_relative '../lib/maze/plugins/error_code_plugin'
89
88
  require_relative '../lib/maze/plugins/global_retry_plugin'
90
89
  require_relative '../lib/maze/plugins/datadog_metrics_plugin'
@@ -117,6 +116,15 @@ class MazeRunnerEntry
117
116
  @args << '--strict-undefined' << '--strict-pending' << '--no-strict-flaky'
118
117
  end
119
118
 
119
+ # Expand by default
120
+ if @args.include?('--no-expand')
121
+ # Just remove it
122
+ @args = @args - ["--no-expand"]
123
+ else
124
+ # Expand
125
+ @args << "--expand"
126
+ end
127
+
120
128
  # Load internal steps and helper functions
121
129
  load_dir = File.expand_path(File.dirname(File.dirname(__FILE__))).freeze
122
130
  paths = Dir.glob("#{load_dir}/lib/features/**/*.rb")
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../lib/maze'
5
+ require_relative '../lib/maze/client/bb_api_client'
6
+ require_relative '../lib/maze/logger'
7
+ require_relative '../lib/maze/helper'
8
+ require 'optimist'
9
+ require 'uri'
10
+ require 'net/http'
11
+
12
+ class PurgeProjectEntry
13
+ def start(_args)
14
+ p = Optimist::Parser.new do
15
+ text 'Purge anonymous projects from BitBar'
16
+ text ''
17
+ text 'Requires BITBAR_API_KEY'
18
+ text ''
19
+ text 'Usage [OPTIONS]'
20
+ text ''
21
+ opt :help,
22
+ 'Print this help.'
23
+ opt :api_key,
24
+ "BitBar API Key",
25
+ :type => :string
26
+ end
27
+
28
+ opts = Optimist::with_standard_exception_handling p do
29
+ p.parse ARGV
30
+ end
31
+
32
+ api_key = opts[:api_key] || ENV['BITBAR_API_KEY']
33
+
34
+ if api_key.nil?
35
+ $logger.warn "API KEY has not been provided or BITBAR_API_KEY has not been set"
36
+ Optimist::with_standard_exception_handling p do
37
+ raise Optimist::HelpNeeded
38
+ end
39
+ end
40
+
41
+ $logger.info "Getting list of anonymous project from BitBar"
42
+
43
+ api_client = Maze::Client::BitBarApiClient.new(api_key)
44
+
45
+ project_list = api_client.get_projects /Project \d+/
46
+
47
+ if project_list.nil?
48
+ $logger.info "No projects to process"
49
+ else
50
+ $logger.info "#{project_list.count} projects to process"
51
+
52
+ project_list.each do |name, id|
53
+ $logger.info "Processing #{name}"
54
+ res = api_client.delete_project id
55
+ if res.code == "204"
56
+ $logger.info "#{name} deleted"
57
+ else
58
+ $logger.warn "Failed to delete #{name}"
59
+ raise res.body
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ PurgeProjectEntry.new.start(ARGV)
@@ -58,6 +58,12 @@ When('I send the keys {string} to the element {string}') do |keys, element_id|
58
58
  Maze.driver.send_keys_to_element(element_id, keys)
59
59
  end
60
60
 
61
+ # Set the device orientation to either portrait or landscape
62
+ # Requires a running Appium driver
63
+ When('I set the device orientation to {orientation}') do |orientation|
64
+ Maze.driver.set_rotation orientation
65
+ end
66
+
61
67
  # Tests that the given payload value is correct for the target BrowserStack platform.
62
68
  # This step will assume the expected and payload values are strings.
63
69
  # If the step is invoked when a remote BrowserStack device is not in use this step will fail.
@@ -73,7 +79,7 @@ end
73
79
  # @step_input request_type [String] The type of request (error, session, build, etc)
74
80
  # @step_input field_path [String] The field to test
75
81
  # @step_input platform_values [DataTable] A table of acceptable values for each platform
76
- Then('the {word} payload field {string} equals the platform-dependent string:') do |request_type, field_path, platform_values|
82
+ Then('the {request_type} payload field {string} equals the platform-dependent string:') do |request_type, field_path, platform_values|
77
83
  test_string_platform_values(request_type, field_path, platform_values)
78
84
  end
79
85
 
@@ -100,7 +106,7 @@ end
100
106
  # @step_input request_type [String] The type of request (error, session, build, etc)
101
107
  # @step_input field_path [String] The field to test
102
108
  # @step_input platform_values [DataTable] A table of acceptable values for each platform
103
- Then('the {word} payload field {string} equals the platform-dependent numeric:') do |request_type, field_path, platform_values|
109
+ Then('the {request_type} payload field {string} equals the platform-dependent numeric:') do |request_type, field_path, platform_values|
104
110
  test_numeric_platform_values(request_type, field_path, platform_values)
105
111
  end
106
112
 
@@ -127,7 +133,7 @@ end
127
133
  # @step_input request_type [String] The type of request (error, session, build, etc)
128
134
  # @step_input field_path [String] The field to test
129
135
  # @step_input platform_values [DataTable] A table of acceptable values for each platform
130
- Then('the {word} payload field {string} equals the platform-dependent boolean:') do |request_type, field_path, platform_values|
136
+ Then('the {request_type} payload field {string} equals the platform-dependent boolean:') do |request_type, field_path, platform_values|
131
137
  test_boolean_platform_values(request_type, field_path, platform_values)
132
138
  end
133
139
 
@@ -6,20 +6,24 @@
6
6
  #
7
7
  # @step_input request_type [String] The type of request (error, session, build, etc)
8
8
  # @step_input header_name [String] The header to test
9
- Then('the {word} {string} header is not null') do |request_type, header_name|
9
+ Then('the {request_type} {string} header is present') do |request_type, header_name|
10
10
  Maze.check.not_nil(Maze::Server.list_for(request_type).current[:request][header_name],
11
11
  "The #{request_type} '#{header_name}' header should not be null")
12
+
13
+ request = Maze::Server.list_for(request_type).current[:request]
14
+ Maze.check.true(request.header.key?(header_name.downcase),
15
+ "The #{request_type} '#{header_name}' header should be present")
12
16
  end
13
17
 
14
18
  # Tests that a request header is null
15
19
  #
16
20
  # @step_input request_type [String] The type of request (error, session, build, etc)
17
21
  # @step_input header_name [String] The header to test
18
- Then('the {word} {string} header is null') do |request_type, header_name|
22
+ Then('the {request_type} {string} header is not present') do |request_type, header_name|
19
23
  request = Maze::Server.list_for(request_type).current[:request]
20
24
 
21
- Maze.check.nil(request[header_name],
22
- "The #{request_type} '#{header_name}' header should be null")
25
+ Maze.check.false(request.header.key?(header_name.downcase),
26
+ "The #{request_type} '#{header_name}' header should not be present")
23
27
  end
24
28
 
25
29
  # Tests that request header equals a string
@@ -27,7 +31,7 @@ end
27
31
  # @step_input request_type [String] The type of request (error, session, build, etc)
28
32
  # @step_input header_name [String] The header to test
29
33
  # @step_input header_value [String] The string it should match
30
- Then('the {word} {string} header equals {string}') do |request_type, header_name, header_value|
34
+ Then('the {request_type} {string} header equals {string}') do |request_type, header_name, header_value|
31
35
  Maze.check.not_nil(Maze::Server.list_for(request_type).current[:request][header_name],
32
36
  "The #{request_type} '#{header_name}' header wasn't present in the request")
33
37
  Maze.check.equal(header_value, Maze::Server.list_for(request_type).current[:request][header_name])
@@ -38,7 +42,7 @@ end
38
42
  # @step_input request_type [String] The type of request (error, session, build, etc)
39
43
  # @step_input header_name [String] The header to test
40
44
  # @step_input regex_string [String] The regex to match with
41
- Then('the {word} {string} header matches the regex {string}') do |request_type, header_name, regex_string|
45
+ Then('the {request_type} {string} header matches the regex {string}') do |request_type, header_name, regex_string|
42
46
  regex = Regexp.new(regex_string)
43
47
  value = Maze::Server.list_for(request_type).current[:request][header_name]
44
48
  Maze.check.match(regex, value)
@@ -49,7 +53,7 @@ end
49
53
  # @step_input request_type [String] The type of request (error, session, build, etc)
50
54
  # @step_input header_name [String] The header to test
51
55
  # @step_input header_values [DataTable] A parsed data table
52
- Then('the {word} {string} header equals one of:') do |request_type, header_name, header_values|
56
+ Then('the {request_type} {string} header equals one of:') do |request_type, header_name, header_values|
53
57
  Maze.check.include(header_values.raw.flatten, Maze::Server.list_for(request_type).current[:request][header_name])
54
58
  end
55
59
 
@@ -57,7 +61,7 @@ end
57
61
  #
58
62
  # @step_input request_type [String] The type of request (error, session, build, etc)
59
63
  # @step_input header_name [String] The header to test
60
- Then('the {word} {string} header is a timestamp') do |request_type, header_name|
64
+ Then('the {request_type} {string} header is a timestamp') do |request_type, header_name|
61
65
  header = Maze::Server.list_for(request_type).current[:request][header_name]
62
66
  Maze.check.match(TIMESTAMP_REGEX, header)
63
67
  end
@@ -65,7 +69,7 @@ end
65
69
  # Checks that the Bugsnag-Integrity header is a SHA1 or simple digest
66
70
  #
67
71
  # @step_input request_type [String] The type of request (error, session, build, etc)
68
- When('the {word} Bugsnag-Integrity header is valid') do |request_type|
72
+ When('the {request_type} Bugsnag-Integrity header is valid') do |request_type|
69
73
  Maze.check.true(Maze::Helper.valid_bugsnag_integrity_header(Maze::Server.list_for(request_type).current),
70
74
  'Invalid Bugsnag-Integrity header detected')
71
75
  end
@@ -22,7 +22,7 @@ end
22
22
  # Verifies that any type of request contains multipart form-data
23
23
  #
24
24
  # @step_input request_type [String] The type of request (error, session, build, etc)
25
- Then('the {word} request is valid multipart form-data') do |request_type|
25
+ Then('the {request_type} request is valid multipart form-data') do |request_type|
26
26
  list = Maze::Server.list_for request_type
27
27
  valid_multipart_form_data?(list.current)
28
28
  end
@@ -30,7 +30,7 @@ end
30
30
  # Verifies all requests of a given type contain multipart form-data
31
31
  #
32
32
  # @step_input request_type [String] The type of request (error, session, build, etc)
33
- Then('all {word} requests are valid multipart form-data') do |request_type|
33
+ Then('all {request_type} requests are valid multipart form-data') do |request_type|
34
34
  list = Maze::Server.list_for request_type
35
35
  list.all.all? { |request| valid_multipart_form_data?(request) }
36
36
  end
@@ -39,7 +39,7 @@ end
39
39
  #
40
40
  # @step_input request_type [String] The type of request (error, session, build, etc)
41
41
  # @step_input part_count [Integer] The number of expected fields
42
- Then('the {word} multipart request has {int} fields') do |request_type, part_count|
42
+ Then('the {request_type} multipart request has {int} fields') do |request_type, part_count|
43
43
  list = Maze::Server.list_for request_type
44
44
  parts = list.current[:body]
45
45
  Maze.check.equal(part_count, parts.size)
@@ -48,7 +48,7 @@ end
48
48
  # Tests a given type of multipart request has at least one field.
49
49
  #
50
50
  # @step_input request_type [String] The type of request (error, session, build, etc)
51
- Then('the {word} multipart request has a non-empty body') do |request_type|
51
+ Then('the {request_type} multipart request has a non-empty body') do |request_type|
52
52
  list = Maze::Server.list_for request_type
53
53
  parts = list.current[:body]
54
54
  Maze.check.true(parts.size.positive?, "Multipart request payload contained #{parts.size} fields")
@@ -73,7 +73,7 @@ end
73
73
  #
74
74
  # @step_input request_type [String] The type of request (error, session, build, etc)
75
75
  # @step_input json_path [String] Path to a JSON file relative to maze-runner root
76
- Then('the {word} multipart body does not match the JSON file in {string}') do |request_type, json_path|
76
+ Then('the {request_type} multipart body does not match the JSON file in {string}') do |request_type, json_path|
77
77
  Maze.check.true(File.exist?(json_path), "'#{json_path}' does not exist")
78
78
  payload_list = Maze::Server.list_for request_type
79
79
  raw_payload_value = payload_list.current[:body]
@@ -88,7 +88,7 @@ end
88
88
  #
89
89
  # @step_input request_type [String] The type of request (error, session, build, etc)
90
90
  # @step_input json_path [String] Path to a JSON file relative to maze-runner root
91
- Then('the {word} multipart body matches the JSON file in {string}') do |request_type, json_path|
91
+ Then('the {request_type} multipart body matches the JSON file in {string}') do |request_type, json_path|
92
92
  Maze.check.true(File.exist?(json_path), "'#{json_path}' does not exist")
93
93
  payload_list = Maze::Server.list_for request_type
94
94
  raw_payload_value = payload_list.current[:body]
@@ -104,7 +104,7 @@ end
104
104
  # @step_input request_type [String] The type of request (error, session, build, etc)
105
105
  # @step_input field_path [String] Path to the tested element
106
106
  # @step_input json_path [String] Path to a JSON file relative to maze-runner root
107
- Then('the {word} multipart field {string} matches the JSON file in {string}') do |request_type, field_path, json_path|
107
+ Then('the {request_type} multipart field {string} matches the JSON file in {string}') do |request_type, field_path, json_path|
108
108
  Maze.check.true(File.exist?(json_path), "'#{json_path}' does not exist")
109
109
  payload_list = Maze::Server.list_for request_type
110
110
  payload_value = JSON.parse(payload_list.current[:body][field_path].to_s)
@@ -117,7 +117,7 @@ end
117
117
  #
118
118
  # @step_input request_type [String] The type of request (error, session, build, etc)
119
119
  # @step_input part_key [String] The key to the multipart element
120
- Then('the field {string} for multipart {word} is not null') do |part_key, request_type|
120
+ Then('the field {string} for multipart {request_type} is not null') do |part_key, request_type|
121
121
  parts = Maze::Server.list_for(request_type).current[:body]
122
122
  Maze.check.not_nil(parts[part_key], "The field '#{part_key}' should not be null")
123
123
  end
@@ -126,7 +126,7 @@ end
126
126
  #
127
127
  # @step_input part_key [String] The key to the multipart element
128
128
  # @step_input request_type [String] The type of request (error, session, build, etc)
129
- Then('the field {string} for multipart {word} is null') do |part_key, request_type|
129
+ Then('the field {string} for multipart {request_type} is null') do |part_key, request_type|
130
130
  parts = Maze::Server.list_for(request_type).current[:body]
131
131
  Maze.check.nil(parts[part_key], "The field '#{part_key}' should be null")
132
132
  end
@@ -136,7 +136,7 @@ end
136
136
  # @step_input part_key [String] The key to the multipart element
137
137
  # @step_input request_type [String] The type of request (error, session, build, etc)
138
138
  # @step_input expected_value [String] The string to match against
139
- Then('the field {string} for multipart {word} equals {string}') do |part_key, request_type, expected_value|
139
+ Then('the field {string} for multipart {request_type} equals {string}') do |part_key, request_type, expected_value|
140
140
  parts = Maze::Server.list_for(request_type).current[:body]
141
141
  Maze.check.equal(parts[part_key], expected_value)
142
142
  end
@@ -8,16 +8,6 @@ When('I wait for the host {string} to open port {string}') do |host, port|
8
8
  Maze::Network.wait_for_port(host, port)
9
9
  end
10
10
 
11
- # Sets the HTTP status code to be used for the next set of requests for a given connection type
12
- #
13
- # @step_input http_verb [String] The type of request this code will be used for
14
- # @step_input status_codes [String] A comma separated list of status codes to return
15
- When('I set the HTTP status code for the next {string} requests to {string}') do |http_verb, status_codes|
16
- raise("Invalid HTTP verb: #{http_verb}") unless Maze::Server::ALLOWED_HTTP_VERBS.include?(http_verb)
17
- codes = status_codes.split(',').map(&:strip)
18
- Maze::Server.set_status_code_generator(create_defaulting_generator(codes, Maze::Server::DEFAULT_STATUS_CODE), http_verb)
19
- end
20
-
21
11
  # Sets the HTTP status code to be used for all subsequent requests for a given connection type
22
12
  #
23
13
  # @step_input http_verb [String] The type of request this code will be used for
@@ -27,13 +17,13 @@ When('I set the HTTP status code for {string} requests to {int}') do |http_verb,
27
17
  Maze::Server.set_status_code_generator(Maze::Generator.new([status_code].cycle), http_verb)
28
18
  end
29
19
 
30
- # Sets the HTTP status code to be used for the next request for a given connection type
20
+ # Sets the HTTP status code to be used for the next set of requests for a given connection type
31
21
  #
32
22
  # @step_input http_verb [String] The type of request this code will be used for
33
- # @step_input status_code [Integer] The status code to return
34
- When('I set the HTTP status code for the next {string} request to {int}') do |http_verb, status_code|
23
+ # @step_input status_codes [String] One or more status codes to return, separated by commas
24
+ When('I set the HTTP status code for the next {string} request(s) to {int_array}') do |http_verb, status_codes|
35
25
  raise("Invalid HTTP verb: #{http_verb}") unless Maze::Server::ALLOWED_HTTP_VERBS.include?(http_verb)
36
- Maze::Server.set_status_code_generator(create_defaulting_generator([status_code], Maze::Server::DEFAULT_STATUS_CODE), http_verb)
26
+ Maze::Server.set_status_code_generator(create_defaulting_generator(status_codes, Maze::Server::DEFAULT_STATUS_CODE), http_verb)
37
27
  end
38
28
 
39
29
  # Sets the HTTP status code to be used for all subsequent POST requests
@@ -43,18 +33,11 @@ When('I set the HTTP status code to {int}') do |status_code|
43
33
  step %{I set the HTTP status code for "POST" requests to #{status_code}}
44
34
  end
45
35
 
46
- # Sets the HTTP status code to be used for the next POST request
47
- #
48
- # @step_input status_code [Integer] The status code to return
49
- When('I set the HTTP status code for the next request to {int}') do |status_code|
50
- step %{I set the HTTP status code for the next "POST" request to #{status_code}}
51
- end
52
-
53
36
  # Sets the HTTP status code to be used for the next set of POST requests
54
37
  #
55
- # @step_input status_codes [String] A comma separated list of status codes to return
56
- When('I set the HTTP status code for the next requests to {string}') do |status_codes|
57
- step %{I set the HTTP status code for the next "POST" requests to "#{status_codes}"}
38
+ # @step_input status_codes [String] One or more status codes to return, separated by commas
39
+ When('I set the HTTP status code for the next request(s) to {int_array}') do |status_codes|
40
+ step %{I set the HTTP status code for the next "POST" requests to #{status_codes.join ','}}
58
41
  end
59
42
 
60
43
  # Sets the sampling probability to be used for all subsequent trace responses
@@ -6,7 +6,7 @@
6
6
  #
7
7
  # @step_input request_type [String] The type of request (error, session, build, etc)
8
8
  # @step_input fixture_path [String] Path to a JSON fixture
9
- Then('the {word} payload body does not match the JSON fixture in {string}') do |request_type, fixture_path|
9
+ Then('the {request_type} payload body does not match the JSON fixture in {string}') do |request_type, fixture_path|
10
10
  payload_value = Maze::Server.list_for(request_type).current[:body]
11
11
  expected_value = JSON.parse(open(fixture_path, &:read))
12
12
  result = Maze::Compare.value(expected_value, payload_value)
@@ -17,7 +17,7 @@ end
17
17
  #
18
18
  # @step_input request_type [String] The type of request (error, session, build, etc)
19
19
  # @step_input fixture_path [String] Path to a JSON fixture
20
- Then('the {word} payload body matches the JSON fixture in {string}') do |request_type, fixture_path|
20
+ Then('the {request_type} payload body matches the JSON fixture in {string}') do |request_type, fixture_path|
21
21
  payload_value = Maze::Server.list_for(request_type).current[:body]
22
22
  expected_value = JSON.parse(open(fixture_path, &:read))
23
23
  result = Maze::Compare.value(expected_value, payload_value)
@@ -30,7 +30,7 @@ end
30
30
  # @step_input request_type [String] The type of request (error, session, build, etc)
31
31
  # @step_input field_path [String] Path to the tested element
32
32
  # @step_input fixture_path [String] Path to a JSON fixture
33
- Then('the {word} payload field {string} matches the JSON fixture in {string}') \
33
+ Then('the {request_type}(|a b) payload field {string} matches the JSON fixture in {string}') \
34
34
  do |request_type, field_path, fixture_path|
35
35
  list = Maze::Server.list_for(request_type)
36
36
  payload_value = Maze::Helper.read_key_path(list.current[:body], field_path)
@@ -44,7 +44,7 @@ end
44
44
  #
45
45
  # @step_input request_type [String] The type of request (error, session, build, etc)
46
46
  # @step_input field_path [String] Path to the tested element
47
- Then('the {word} payload field {string} is true') do |request_type, field_path|
47
+ Then('the {request_type} payload field {string} is true') do |request_type, field_path|
48
48
  list = Maze::Server.list_for(request_type)
49
49
  Maze.check.true(Maze::Helper.read_key_path(list.current[:body], field_path))
50
50
  end
@@ -53,7 +53,7 @@ end
53
53
  #
54
54
  # @step_input request_type [String] The type of request (error, session, build, etc)
55
55
  # @step_input field_path [String] Path to the tested element
56
- Then('the {word} payload field {string} is false') do |request_type, field_path|
56
+ Then('the {request_type} payload field {string} is false') do |request_type, field_path|
57
57
  list = Maze::Server.list_for(request_type)
58
58
  Maze.check.false(Maze::Helper.read_key_path(list.current[:body], field_path))
59
59
  end
@@ -62,7 +62,7 @@ end
62
62
  #
63
63
  # @step_input request_type [String] The type of request (error, session, build, etc)
64
64
  # @step_input field_path [String] Path to the tested element
65
- Then('the {word} payload field {string} is null') do |request_type, field_path|
65
+ Then('the {request_type} payload field {string} is null') do |request_type, field_path|
66
66
  list = Maze::Server.list_for(request_type)
67
67
  Maze.check.nil(Maze::Helper.read_key_path(list.current[:body], field_path))
68
68
  end
@@ -71,7 +71,7 @@ end
71
71
  #
72
72
  # @step_input request_type [String] The type of request (error, session, build, etc)
73
73
  # @step_input field_path [String] Path to the tested element
74
- Then('the {word} payload field {string} is not null') do |request_type, field_path|
74
+ Then('the {request_type} payload field {string} is not null') do |request_type, field_path|
75
75
  list = Maze::Server.list_for(request_type)
76
76
  Maze.check.not_nil(Maze::Helper.read_key_path(list.current[:body], field_path))
77
77
  end
@@ -81,7 +81,7 @@ end
81
81
  # @step_input request_type [String] The type of request (error, session, build, etc)
82
82
  # @step_input field_path [String] Path to the tested element
83
83
  # @step_input int_value [Integer] The value to test against
84
- Then('the {word} payload field {string} equals {int}') do |request_type, field_path, int_value|
84
+ Then('the {request_type} payload field {string} equals {int}') do |request_type, field_path, int_value|
85
85
  Maze.check.equal(int_value,
86
86
  Maze::Helper.read_key_path(Maze::Server.list_for(request_type).current[:body], field_path))
87
87
  end
@@ -91,7 +91,7 @@ end
91
91
  # @step_input request_type [String] The type of request (error, session, build, etc)
92
92
  # @step_input field_path [String] Path to the tested element
93
93
  # @step_input float_value [Float] The value to test against
94
- Then('the {word} payload field {string} equals {float}') do |request_type, field_path, float_value|
94
+ Then('the {request_type} payload field {string} equals {float}') do |request_type, field_path, float_value|
95
95
  Maze.check.equal(float_value,
96
96
  Maze::Helper.read_key_path(Maze::Server.list_for(request_type).current[:body], field_path))
97
97
  end
@@ -102,7 +102,7 @@ end
102
102
  # @step_input field_path [String] Path to the tested element
103
103
  # @step_input float_value [Float] The value to test against
104
104
  # @step_input places [Int] The number of decimal places to round the actual value to first
105
- Then('the {word} payload field {string} equals {float} to {int} decimal place(s)') do |request_type, field_path, float_value, places|
105
+ Then('the {request_type} payload field {string} equals {float} to {int} decimal place(s)') do |request_type, field_path, float_value, places|
106
106
  body = Maze::Server.list_for(request_type).current[:body]
107
107
  rounded_value = Maze::Helper.read_key_path(body, field_path).round places
108
108
  Maze.check.equal(float_value,
@@ -114,7 +114,7 @@ end
114
114
  # @step_input request_type [String] The type of request (error, session, build, etc)
115
115
  # @step_input field_path [String] The payload element to test
116
116
  # @step_input env_var [String] The environment variable to test against
117
- Then('the {word} payload field {string} equals the environment variable {string}') \
117
+ Then('the {request_type} payload field {string} equals the environment variable {string}') \
118
118
  do |request_type, field_path, env_var|
119
119
  environment_value = ENV[env_var]
120
120
  Maze.check.false(environment_value.nil?, "The environment variable #{env_var} must not be nil")
@@ -129,7 +129,7 @@ end
129
129
  # @step_input request_type [String] The type of request (error, session, build, etc)
130
130
  # @step_input field_path [String] The payload element to test
131
131
  # @step_input int_value [Integer] The value to compare against
132
- Then('the {word} payload field {string} is greater than {int}') do |request_type, field_path, int_value|
132
+ Then('the {request_type} payload field {string} is greater than {int}') do |request_type, field_path, int_value|
133
133
  list = Maze::Server.list_for(request_type)
134
134
  value = Maze::Helper.read_key_path(list.current[:body], field_path)
135
135
  Maze.check.kind_of Integer, value
@@ -141,7 +141,7 @@ end
141
141
  # @step_input request_type [String] The type of request (error, session, build, etc)
142
142
  # @step_input field_path [String] The payload element to test
143
143
  # @step_input int_value [Integer] The value to compare against
144
- Then('the {word} payload field {string} is less than {int}') do |request_type, field_path, int_value|
144
+ Then('the {request_type} payload field {string} is less than {int}') do |request_type, field_path, int_value|
145
145
  list = Maze::Server.list_for(request_type)
146
146
  value = Maze::Helper.read_key_path(list.current[:body], field_path)
147
147
  Maze.check.kind_of Integer, value
@@ -154,7 +154,7 @@ end
154
154
  # @step_input request_type [String] The type of request (error, session, build, etc)
155
155
  # @step_input field_path [String] The payload element to test
156
156
  # @step_input string_value [String] The string to test against
157
- Then('the {word} payload field {string} equals {string}') do |request_type, field_path, string_value|
157
+ Then('the {request_type} payload field {string} equals {string}') do |request_type, field_path, string_value|
158
158
  list = Maze::Server.list_for(request_type)
159
159
  Maze.check.equal(string_value, Maze::Helper.read_key_path(list.current[:body], field_path))
160
160
  end
@@ -164,7 +164,7 @@ end
164
164
  # @step_input request_type [String] The type of request (error, session, build, etc)
165
165
  # @step_input field_path [String] The payload element to test
166
166
  # @step_input string_value [String] The string to test against
167
- Then('the {word} payload field {string} starts with {string}') do |request_type, field_path, string_value|
167
+ Then('the {request_type} payload field {string} starts with {string}') do |request_type, field_path, string_value|
168
168
  list = Maze::Server.list_for(request_type)
169
169
  value = Maze::Helper.read_key_path(list.current[:body], field_path)
170
170
  Maze.check.kind_of String, value
@@ -179,7 +179,7 @@ end
179
179
  # @step_input request_type [String] The type of request (error, session, build, etc)
180
180
  # @step_input field_path [String] The payload element to test
181
181
  # @step_input string_value [String] The string to test against
182
- Then('the {word} payload field {string} ends with {string}') do |request_type, field_path, string_value|
182
+ Then('the {request_type} payload field {string} ends with {string}') do |request_type, field_path, string_value|
183
183
  list = Maze::Server.list_for(request_type)
184
184
  value = Maze::Helper.read_key_path(list.current[:body], field_path)
185
185
  Maze.check.kind_of String, value
@@ -194,7 +194,7 @@ end
194
194
  # @step_input request_type [String] The type of request (error, session, build, etc)
195
195
  # @step_input field [String] The payload element to test
196
196
  # @step_input count [Integer] The value expected
197
- Then('the {word} payload field {string} is an array with {int} elements') do |request_type, field, count|
197
+ Then('the {request_type} payload field {string} is an array with {int} elements') do |request_type, field, count|
198
198
  list = Maze::Server.list_for(request_type)
199
199
  value = Maze::Helper.read_key_path(list.current[:body], field)
200
200
  Maze.check.kind_of Array, value
@@ -205,7 +205,7 @@ end
205
205
  #
206
206
  # @step_input request_type [String] The type of request (error, session, build, etc)
207
207
  # @step_input field [String] The payload element to test
208
- Then('the {word} payload field {string} is a non-empty array') do |request_type, field|
208
+ Then('the {request_type} payload field {string} is a non-empty array') do |request_type, field|
209
209
  list = Maze::Server.list_for(request_type)
210
210
  value = Maze::Helper.read_key_path(list.current[:body], field)
211
211
  Maze.check.kind_of Array, value
@@ -217,7 +217,7 @@ end
217
217
  # @step_input request_type [String] The type of request (error, session, build, etc)
218
218
  # @step_input field [String] The payload element to test
219
219
  # @step_input regex [String] The regex to test against
220
- Then('the {word} payload field {string} matches the regex {string}') do |request_type, field, regex_string|
220
+ Then('the {request_type} payload field {string} matches the regex {string}') do |request_type, field, regex_string|
221
221
  regex = Regexp.new(regex_string)
222
222
  list = Maze::Server.list_for(request_type)
223
223
  value = Maze::Helper.read_key_path(list.current[:body], field)
@@ -228,7 +228,7 @@ end
228
228
  #
229
229
  # @step_input request_type [String] The type of request (error, session, build, etc)
230
230
  # @step_input field [String] The payload element to test
231
- Then('the {word} payload field {string} is a parsable timestamp in seconds') do |request_type, field|
231
+ Then('the {request_type} payload field {string} is a parsable timestamp in seconds') do |request_type, field|
232
232
  list = Maze::Server.list_for(request_type)
233
233
  value = Maze::Helper.read_key_path(list.current[:body], field)
234
234
  begin
@@ -245,7 +245,7 @@ end
245
245
  # @step_input request_type [String] The type of request (error, session, build, etc)
246
246
  # @step_input key_path [String] The path to the tested array
247
247
  # @step_input element_key_path [String] The key for the expected element inside the array
248
- Then('each element in {word} payload field {string} has {string}') do |request_type, key_path, element_key_path|
248
+ Then('each element in {request_type} payload field {string} has {string}') do |request_type, key_path, element_key_path|
249
249
  list = Maze::Server.list_for(request_type)
250
250
  value = Maze::Helper.read_key_path(list.current[:body], key_path)
251
251
  Maze.check.kind_of Array, value
@@ -7,7 +7,7 @@
7
7
  # @step_input request_type [String] The type of request (error, session, build, etc)
8
8
  # @step_input parameter_name [String] The parameter to test
9
9
  # @step_input parameter_value [String] The expected value
10
- Then('the {word} {string} query parameter equals {string}') do |request_type, parameter_name, parameter_value|
10
+ Then('the {request_type} {string} query parameter equals {string}') do |request_type, parameter_name, parameter_value|
11
11
  Maze.check.equal(parameter_value,
12
12
  Maze::Helper.parse_querystring(Maze::Server.list_for(request_type).current)[parameter_name][0])
13
13
  end
@@ -16,7 +16,7 @@ end
16
16
  #
17
17
  # @step_input request_type [String] The type of request (error, session, build, etc)
18
18
  # @step_input parameter_name [String] The parameter to test
19
- Then('the {word} {string} query parameter is not null') do |request_type, parameter_name|
19
+ Then('the {request_type} {string} query parameter is not null') do |request_type, parameter_name|
20
20
  Maze.check.not_nil(Maze::Helper.parse_querystring(Maze::Server.list_for(request_type).current)[parameter_name][0],
21
21
  "The '#{parameter_name}' query parameter should not be null")
22
22
  end
@@ -25,7 +25,7 @@ end
25
25
  #
26
26
  # @step_input request_type [String] The type of request (error, session, build, etc)
27
27
  # @step_input parameter_name [String] The parameter to test
28
- Then('the {word} {string} query parameter is a timestamp') do |request_type, parameter_name|
28
+ Then('the {request_type} {string} query parameter is a timestamp') do |request_type, parameter_name|
29
29
  param = Maze::Helper.parse_querystring(Maze::Server.list_for(request_type).current)[parameter_name][0]
30
30
  Maze.check.match(TIMESTAMP_REGEX, param)
31
31
  end
@@ -49,12 +49,12 @@ def assert_received_requests(request_count, list, list_name, precise = true)
49
49
  end
50
50
 
51
51
  #
52
- # Error request assertions
52
+ # Request assertions
53
53
  #
54
54
  # Shortcut to waiting to receive a single request of the given type
55
55
  #
56
56
  # @step_input request_type [String] The type of request (error, session, build, etc)
57
- Then('I wait to receive a(n) {word}') do |request_type|
57
+ Then('I wait to receive a(n) {request_type}') do |request_type|
58
58
  step "I wait to receive 1 #{request_type}"
59
59
  end
60
60
 
@@ -65,7 +65,7 @@ end
65
65
  #
66
66
  # @step_input request_type [String] The type of request (error, session, build, etc)
67
67
  # @step_input request_count [Integer] The amount of requests expected
68
- Then('I wait to receive {int} {word}') do |request_count, request_type|
68
+ Then('I wait to receive {int} {request_type}') do |request_count, request_type|
69
69
  list = Maze::Server.list_for(request_type)
70
70
  assert_received_requests request_count, list, request_type
71
71
  list.sort_by_sent_at! request_count
@@ -78,7 +78,7 @@ end
78
78
  #
79
79
  # @step_input request_type [String] The type of request (error, session, build, etc)
80
80
  # @step_input request_count [Integer] The amount of requests expected
81
- Then('I wait to receive at least {int} {word}') do |request_count, request_type|
81
+ Then('I wait to receive at least {int} {request_type}') do |request_count, request_type|
82
82
  list = Maze::Server.list_for(request_type)
83
83
  assert_received_requests request_count, list, request_type, false
84
84
  end
@@ -87,7 +87,7 @@ end
87
87
  #
88
88
  # @step_input request_type [String] The type of request (error, session, build, etc)
89
89
  # @step_input field_path [String] The field to sort by
90
- Then('I sort the {word} by the payload field {string}') do |request_type, field_path|
90
+ Then('I sort the {request_type} by the payload field {string}') do |request_type, field_path|
91
91
  list = Maze::Server.list_for(request_type)
92
92
  list.sort_by! field_path
93
93
  end
@@ -97,31 +97,24 @@ end
97
97
  #
98
98
  # @step_input min_received [Integer] The minimum amount of requests required to pass
99
99
  # @step_input request_type [String] The type of request (error, session, build, etc)
100
- Then('I have received at least {int} {word}') do |min_received, request_type|
100
+ Then('I have received at least {int} {request_type}') do |min_received, request_type|
101
101
  list = Maze::Server.list_for(request_type)
102
102
  Maze.check.operator(list.size_remaining, :>=, min_received, "Actually received #{list.size_remaining} #{request_type} requests")
103
103
  end
104
104
 
105
105
  # Assert that the test Server hasn't received any requests - of a specific, or any, type.
106
106
  #
107
- # @step_input request_type [String] The type of request ('error', 'session', build, etc), or 'requests' to assert on all
108
- # request types.
109
- Then('I should receive no {word}') do |request_type|
107
+ # @step_input request_type [String] The type of request ('error', 'session', 'trace', sampling request', etc)
108
+ Then('I should receive no {request_type}') do |request_type|
110
109
  sleep Maze.config.receive_no_requests_wait
111
- if request_type == 'requests'
112
- # Assert that the test Server hasn't received any requests at all.
113
- Maze.check.equal(0, Maze::Server.errors.size_remaining, "#{Maze::Server.errors.size_remaining} errors received")
114
- Maze.check.equal(0, Maze::Server.sessions.size_remaining, "#{Maze::Server.sessions.size_remaining} sessions received")
115
- else
116
- list = Maze::Server.list_for(request_type)
117
- Maze.check.equal(0, list.size_remaining, "#{list.size_remaining} #{request_type} received")
118
- end
110
+ list = Maze::Server.list_for(request_type)
111
+ Maze.check.equal(0, list.size_remaining, "#{list.size_remaining} #{request_type} received")
119
112
  end
120
113
 
121
114
  # Moves to the next request
122
115
  #
123
116
  # @step_input request_type [String] The type of request (error, session, build, etc)
124
- Then('I discard the oldest {word}') do |request_type|
117
+ Then('I discard the oldest {request_type}') do |request_type|
125
118
  raise "No #{request_type} to discard" if Maze::Server.list_for(request_type).current.nil?
126
119
 
127
120
  Maze::Server.list_for(request_type).next