Ifd_Automation 2.6 → 2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/bin/generate.rb +21 -3
  3. data/bin/helper.rb +5 -4
  4. data/lib/Ifd_Automation/require_libs.rb +9 -6
  5. data/lib/Ifd_Automation/version.rb +1 -1
  6. data/lib/helper/{assertion_helpers.rb → assertion_helper.rb} +5 -5
  7. data/lib/helper/auto_util.rb +164 -0
  8. data/lib/helper/database_helper.rb +81 -0
  9. data/lib/helper/file_helper.rb +36 -0
  10. data/lib/helper/mail_helper.rb +58 -0
  11. data/lib/helper/rest_helper.rb +91 -0
  12. data/lib/helper/soap_helper.rb +59 -0
  13. data/lib/helper/ssh_helper.rb +39 -0
  14. data/lib/helper/web_steps_helper.rb +447 -0
  15. data/project/Dockerfile +20 -0
  16. data/project/Gemfile.lock +176 -0
  17. data/project/README.md +60 -0
  18. data/project/cucumber.yml +6 -0
  19. data/project/docker-compose.yml +7 -0
  20. data/project/features/TestData/globalData.yml +3 -1
  21. data/project/features/TestSuite/WebGUI.feature +16 -2
  22. data/project/features/step_definitions/IFD_Libraries/REST_steps.rb +34 -0
  23. data/project/features/step_definitions/IFD_Libraries/SOAP_steps.rb +38 -0
  24. data/project/features/step_definitions/IFD_Libraries/database_steps.rb +44 -0
  25. data/{lib/Ifd_Automation/dynamic_store_vavue_steps.rb → project/features/step_definitions/IFD_Libraries/dynamic_store_value_steps.rb} +8 -10
  26. data/project/features/step_definitions/IFD_Libraries/email_steps.rb +36 -0
  27. data/project/features/step_definitions/IFD_Libraries/file_steps.rb +11 -0
  28. data/project/features/step_definitions/IFD_Libraries/ssh_steps.rb +20 -0
  29. data/{lib/Ifd_Automation → project/features/step_definitions/IFD_Libraries}/web_steps.rb +18 -8
  30. data/project/features/step_definitions/lib_steps/actionwords.rb +14 -10
  31. data/project/features/step_definitions/lib_steps/steps.rb +6 -0
  32. data/project/features/step_definitions/repositories/project_object.yml +2 -6
  33. data/project/features/support/env.rb +18 -18
  34. data/project/features/support/hooks.rb +22 -59
  35. metadata +45 -17
  36. data/lib/Ifd_Automation/REST_steps.rb +0 -90
  37. data/lib/Ifd_Automation/SOAP_steps.rb +0 -68
  38. data/lib/Ifd_Automation/database_steps.rb +0 -80
  39. data/lib/Ifd_Automation/email_steps.rb +0 -72
  40. data/lib/Ifd_Automation/file_steps.rb +0 -24
  41. data/lib/Ifd_Automation/ssh_steps.rb +0 -38
  42. data/lib/helper/auto_utils.rb +0 -67
  43. data/lib/helper/connection_helpers.rb +0 -15
  44. data/lib/helper/core.rb +0 -646
  45. data/lib/helper/mail_helpers.rb +0 -17
  46. data/lib/helper/web_steps_helpers.rb +0 -176
  47. data/project/features/step_definitions/lib_steps/test.rb +0 -6
@@ -0,0 +1,36 @@
1
+ require 'action_mailer'
2
+ # Example:
3
+ #
4
+ # Then I send an email with:
5
+ # """
6
+ # From: from@example.com
7
+ # Reply-To: reply-to@example.com
8
+ # To: anh.pham@infodation.vn
9
+ # Subject: SUBJECT
10
+ # Attachments: globalData.yml
11
+
12
+ # BODY
13
+ # """
14
+ #
15
+ Then /^I send an e?mail with:$/ do |raw_data|
16
+ IFD_Email.send_email(raw_data)
17
+ end
18
+
19
+ # Example:
20
+ #
21
+ # Then I should receive an email with:
22
+ # """
23
+ # From: from@example.com
24
+ # Reply-To: reply-to@example.com
25
+ # To: anh.pham@infodation.vn
26
+ # Subject: SUBJECT
27
+ # Attachments: globalData.yml
28
+
29
+ # BODY
30
+ # """
31
+ #
32
+
33
+ Then /^I should receive an e?mail with:$/ do |raw_data|
34
+ IFD_Email.verify_receive_email(raw_data)
35
+ end
36
+
@@ -0,0 +1,11 @@
1
+ Then /^I delete test file "(.*)"$/ do |file_name|
2
+ IFD_File.delete_file(file_name)
3
+ end
4
+
5
+ Given /^I read data from file "(.*)"$/ do |file_name|
6
+ IFD_File.read_file(file_name)
7
+ end
8
+
9
+ Given /I execute file "(.*)" from windows server "(.*)"/ do |filename, file_location|
10
+ IFD_File.execute_windows_file(filename, file_location)
11
+ end
@@ -0,0 +1,20 @@
1
+ When /^I SSH to "([^\"]*)" with the following credentials:$/ do |hostname, table|
2
+ IFD_Ssh.connect_to_server_with_credential(hostname, table)
3
+ end
4
+
5
+ When /^I run SSH command "([^\"]*)"$/ do |command|
6
+ IFD_Ssh.exec_command(command)
7
+ end
8
+
9
+
10
+ Then /^show me the SSH output result$/ do
11
+ IFD_Ssh.print_output
12
+ end
13
+
14
+ Then /^I should see "([^\"]*)" in the SSH output$/ do |string|
15
+ IFD_Ssh.verify_output(string)
16
+ end
17
+
18
+ When /^I store the result of SSH as "(.*?)"$/ do |var_name|
19
+ IFD_Ssh.store_result_string(var_name)
20
+ end
@@ -1,8 +1,7 @@
1
- require_relative 'require_libs'
2
1
 
3
2
  # Navigate to a particular page
4
3
  Given(/^I am on the "([^"]*)" page$/) do |url|
5
- url = check_dynamic_value url
4
+ url = Utils.check_dynamic_value(url)
6
5
  execute_openbrowser(url)
7
6
  end
8
7
 
@@ -13,17 +12,17 @@ end
13
12
 
14
13
  # Finds a button or link by id, text or value and clicks it
15
14
  And /^I click on "([^\"]*)"$/ do |object|
16
- execute_click(object)
15
+ execute_click(object)
17
16
  end
18
17
 
19
18
  # double click on web element
20
19
  Then /^I double click on element "(.*?)"$/ do |element|
21
- double_click(element)
20
+ double_click(element)
22
21
  end
23
22
 
24
23
  # Fill in a text box or text area with a value
25
24
  And /^I set text on "(.*?)" with "(.*?)"$/ do |object, text|
26
- text = check_dynamic_value text
25
+ text = Utils.check_dynamic_value text
27
26
  execute_settext(object, text)
28
27
  end
29
28
 
@@ -54,7 +53,7 @@ end
54
53
 
55
54
  # check property for object
56
55
  Then /^I check property "(.*?)" with "(.*?)" has( | not)? value "(.*?)"$/ do |object, property, negate, value|
57
- value = bind_with_dyn_vars value
56
+ value = Utils.bind_with_dyn_vars value
58
57
  execute_checkproperty(object, property, negate, value)
59
58
  end
60
59
 
@@ -63,12 +62,10 @@ Then(/^I should see alert text as "(.*?)"$/) do |actual_value|
63
62
  check_alert_text(actual_value)
64
63
  end
65
64
 
66
- # NEW
67
65
  Given /^I move mouse to element "(.*)" and click$/ do |object|
68
66
  execute_mousehoverandclick(object)
69
67
  end
70
68
 
71
- # NEW
72
69
  And /^remove attribute "(.*)" on object "(.*)"$/ do |attr, object|
73
70
  remove_element_attribute object, attr
74
71
  end
@@ -77,3 +74,16 @@ end
77
74
  And /^I set state on "(.*?)" with "(.*?)"$/ do |object, state|
78
75
  execute_setstate(object, state)
79
76
  end
77
+
78
+ And /I resize window screen to "(.*)","(.*)"/ do |x,y|
79
+ resize_window_screen(x,y)
80
+ end
81
+
82
+ And /I verify object "(.*)" with "(.*)" has value "(.*)"/ do |object,style,expected_value|
83
+ actual_value = get_computed_style(object,style)
84
+ IFD_Assertion.assert_string_equal(expected_value,actual_value)
85
+ end
86
+
87
+ Then /^I should( not)? see page title as (.*)$/ do |present, title|
88
+ check_title(title, present.empty?)
89
+ end
@@ -1,12 +1,16 @@
1
1
  module Actionwords
2
- def login_to_system_with_user_and_pass(url,user,pass)
3
- steps %Q{
4
- * I am on the "#{url}" page
5
- * I click on "header.button_cookie"
6
- * I click on "header.button_login"
7
- * I set text on "login.textbox_username" with "#{user}"
8
- * I set text on "login.textbox_password" with "#{pass}"
9
- * I click on "login.button_login"
10
- }
11
- end
2
+
3
+ def login_to_system
4
+ step %{I am on the "params='login_page'" page}
5
+ step %{I set text on "textbox_username" with "params='login_user'"}
6
+ step %{I set text on "textbox_password" with "params='login_pass'"}
7
+ step %{I click on "aa"}
8
+ end
9
+ #
10
+ # def send_soap_with_operation_and_data(operation,data)
11
+ #
12
+ # # @response = IFD_Soap.call_and_fail_gracefully(@SOAPclient, operation.downcase.to_sym, xml: Utils.eval_with_dyn_vars(data) )
13
+ # p Utils.eval_with_dyn_vars(data)
14
+ # end
15
+
12
16
  end
@@ -0,0 +1,6 @@
1
+ require_relative 'actionwords'
2
+ World(Actionwords)
3
+
4
+ Given /I log in to the system/ do
5
+ login_to_system
6
+ end
@@ -1,6 +1,2 @@
1
- header.button_login: {css_selector: '#login-from>h2>a>button'}
2
- header.button_cookie: {css_selector: '#btn-give-cookie-consent'}
3
- login.textbox_username: {css_selector: '#login_user'}
4
- login.textbox_password: {css_selector: '#login_pass'}
5
- login.label_message_error: {css_selector: '.ifd-message-error'}
6
- login.button_login: {css_selector: '#wp-submit'}
1
+ textbox_username: {css_selector: '#userField'}
2
+ textbox_password: {css_selector: '#passwordField'}
@@ -14,12 +14,12 @@ require 'yaml'
14
14
  require 'selenium-webdriver'
15
15
  require 'Ifd_Automation'
16
16
 
17
- if ENV["browser"].nil?
18
- raise "ERROR***: MISSING BROWSER... Supported Browsers: Chrome/Firefox."
17
+ if ENV["BROWSER"].nil?
18
+ raise "ERROR***: MISSING BROWSER... Supported Browsers: Chrome/Firefox. Example: 'BROWSER=chrome'"
19
19
  end
20
20
 
21
- $_CFWEB['Default Browser'] = ENV["browser"].downcase
22
- $_CFWEB['Wait Time'] = ENV["wait_time"] || 30
21
+ $_CFWEB['Default Browser'] = ENV["BROWSER"].downcase
22
+ $_CFWEB['Wait Time'] = ENV["wait_time"] || 10
23
23
  $_CFWEB['Print Log'] = ENV["print_log"]
24
24
  $_CFWEB['Maximize Browser'] = ENV["maximize_browser"] || true
25
25
  $SEND_EMAIL_USERNAME = $PARAMS["send_email_username"]
@@ -46,13 +46,10 @@ Mail.defaults do
46
46
  }
47
47
  end
48
48
  Capybara.configure do |config|
49
- # config.app_host = $_CFWEB['Page Address']
50
49
  config.default_max_wait_time = $_CFWEB['Wait Time']
51
- # config.run_server = false
52
50
  config.default_driver = :selenium
53
51
  config.default_selector = :css
54
52
  config.ignore_hidden_elements = true
55
- #config.visible_text_only = true
56
53
  end
57
54
 
58
55
  def register_selenium_remote_driver(browser)
@@ -79,6 +76,8 @@ def register_selenium_remote_driver(browser)
79
76
  url: "http://#{ENV["SELENIUM_SERVER"]}:4444/wd/hub",
80
77
  desired_capabilities: caps)
81
78
  end
79
+ else
80
+ raise "ERROR: Browser: #{browser} is not supported"
82
81
  end
83
82
  end
84
83
 
@@ -99,7 +98,7 @@ def register_selenium_local_driver(browser)
99
98
  args << "--test-type" #to fix the error of chrome "you are using an unsupported command-line flag ignore-certificate-errors"
100
99
  Capybara::Selenium::Driver.new(app, :browser => browser.to_sym, :prefs => prefs, :args => args)
101
100
  else
102
- puts("Not support browser...")
101
+ raise "ERROR: Browser: #{browser} is not supported"
103
102
  end
104
103
  end
105
104
  end
@@ -107,7 +106,7 @@ end
107
106
  case ENV["SELENIUM"]
108
107
  when "remote"
109
108
  if ENV["SELENIUM_SERVER"].nil?
110
- raise "ERROR***: MISSING SELENIUM_SERVER IP..."
109
+ raise "ERROR***: MISSING SELENIUM_SERVER IP... Example: 'SELENIUM_SERVER=localhost'"
111
110
  else
112
111
  register_selenium_remote_driver($_CFWEB['Default Browser'])
113
112
  end
@@ -116,12 +115,13 @@ case ENV["SELENIUM"]
116
115
  end
117
116
 
118
117
  # Available execution environment variables
119
- # - ENV["SELENIUM"] = remote
120
- # - ENV["SELENIUM_SERVER"] = 10.0.0.1
121
- # - ENV["browser"] = "chrome"/"firefox"
122
- # - ENV["wait_time"] = 30
123
- # - ENV["print_log"] = true/false
124
- # - ENV["maximize_browser"] = true/false
125
- # - ENV["recordVideo"]
126
- # - ENV["name"]
127
- # - ENV["build"]
118
+ # - SELENIUM = remote
119
+ # - SELENIUM_SERVER = 10.0.0.1
120
+ # - BROWSER = "chrome"/"firefox"
121
+ # - wait_time = 30
122
+ # - print_log = true/false
123
+ # - maximize_browser = true/false
124
+ # - recordVideo
125
+ # - name
126
+ # - build
127
+ # - save_screenshot
@@ -1,59 +1,22 @@
1
- # #Only run IE browser
2
- # Before('@IE') do
3
- # $_Old_Default_Browser = $_CFWEB['Default Browser']
4
- # $_CFWEB['Default Browser'] = 'IE'
5
- # end
6
- # After('@IE') do
7
- # $_CFWEB['Default Browser'] = $_Old_Default_Browser
8
- # end
9
- #
10
- # #Only run Chrome browser
11
- # Before('@CH') do
12
- # $_Old_Default_Browser = $_CFWEB['Default Browser']
13
- # $_CFWEB['Default Browser'] = 'CH'
14
- # end
15
- # After('@CH') do
16
- # $_CFWEB['Default Browser'] = $_Old_Default_Browser
17
- # end
18
- #
19
- # #Only run Firefox browser
20
- # Before('@FF') do
21
- # $_Old_Default_Browser = $_CFWEB['Default Browser']
22
- # $_CFWEB['Default Browser'] = 'FF'
23
- # end
24
- # After('@FF') do
25
- # $_CFWEB['Default Browser'] = $_Old_Default_Browser
26
- # end
27
- #
28
- # Before do
29
- # begin
30
- # browser = Capybara.current_session.driver.browser
31
- # browser.manage.delete_all_cookies
32
- # rescue StandardError => myStandardError
33
- # put_log "\n>>> Error: #{myStandardError}"
34
- # end
35
- # end
36
- #
37
- # # After do |scenario|
38
- # # file_name = 'failed_%s.png' % rand(1000).to_s
39
- # # page.save_screenshot($screenshot+file_name) if scenario.failed?
40
- # # begin
41
- # # Capybara.page.driver.quit
42
- # # Capybara.send(:session_pool).delete_if { |key, value| key =~ /selenium/i }
43
- # # rescue StandardError => myStandardError
44
- # # put_log "\n>>> Error: #{myStandardError}"
45
- # # end
46
- # # end
47
- # #
48
- # # at_exit do
49
- # # end
50
- #
51
- # AfterConfiguration do |config|
52
- # end
53
- #
54
- # Around do |scenario, block|
55
- # block.call
56
- # end
57
- #
58
- # AfterStep do |scenario|
59
- # end
1
+
2
+ Before do
3
+ begin
4
+ browser = Capybara.current_session.driver.browser
5
+ browser.manage.delete_all_cookies
6
+ rescue StandardError => myStandardError
7
+ raise "\n>>> Error: #{myStandardError}"
8
+ end
9
+ end
10
+
11
+ After do |scenario|
12
+ if ENV['save_screenshot'] == "true"
13
+ file_name = 'failed_%s.png' % rand(1000).to_s
14
+ page.save_screenshot($screenshot+file_name) if scenario.failed?
15
+ begin
16
+ Capybara.page.driver.quit
17
+ Capybara.send(:session_pool).delete_if { |key, value| key =~ /selenium/i }
18
+ rescue StandardError => myStandardError
19
+ raise "\n>>> Error: #{myStandardError}"
20
+ end
21
+ end
22
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Ifd_Automation
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.6'
4
+ version: '2.7'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anh Pham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-02 00:00:00.000000000 Z
11
+ date: 2018-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver
@@ -220,6 +220,26 @@ dependencies:
220
220
  - - ">="
221
221
  - !ruby/object:Gem::Version
222
222
  version: 3.7.0
223
+ - !ruby/object:Gem::Dependency
224
+ name: parallel_tests
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: '2.7'
230
+ - - ">="
231
+ - !ruby/object:Gem::Version
232
+ version: 2.7.1
233
+ type: :runtime
234
+ prerelease: false
235
+ version_requirements: !ruby/object:Gem::Requirement
236
+ requirements:
237
+ - - "~>"
238
+ - !ruby/object:Gem::Version
239
+ version: '2.7'
240
+ - - ">="
241
+ - !ruby/object:Gem::Version
242
+ version: 2.7.1
223
243
  description: Behavior driven development (BDD) approach to write automation test script
224
244
  to test GUI, RESTful, SOAP, Database, eMail.
225
245
  email:
@@ -236,29 +256,37 @@ files:
236
256
  - bin/helper.rb
237
257
  - bin/setup
238
258
  - lib/Ifd_Automation.rb
239
- - lib/Ifd_Automation/REST_steps.rb
240
- - lib/Ifd_Automation/SOAP_steps.rb
241
259
  - lib/Ifd_Automation/all_steps.rb
242
- - lib/Ifd_Automation/database_steps.rb
243
- - lib/Ifd_Automation/dynamic_store_vavue_steps.rb
244
- - lib/Ifd_Automation/email_steps.rb
245
- - lib/Ifd_Automation/file_steps.rb
246
260
  - lib/Ifd_Automation/require_libs.rb
247
- - lib/Ifd_Automation/ssh_steps.rb
248
261
  - lib/Ifd_Automation/version.rb
249
- - lib/Ifd_Automation/web_steps.rb
250
- - lib/helper/assertion_helpers.rb
251
- - lib/helper/auto_utils.rb
252
- - lib/helper/connection_helpers.rb
253
- - lib/helper/core.rb
254
- - lib/helper/mail_helpers.rb
255
- - lib/helper/web_steps_helpers.rb
262
+ - lib/helper/assertion_helper.rb
263
+ - lib/helper/auto_util.rb
264
+ - lib/helper/database_helper.rb
265
+ - lib/helper/file_helper.rb
266
+ - lib/helper/mail_helper.rb
267
+ - lib/helper/rest_helper.rb
268
+ - lib/helper/soap_helper.rb
269
+ - lib/helper/ssh_helper.rb
270
+ - lib/helper/web_steps_helper.rb
271
+ - project/Dockerfile
256
272
  - project/Gemfile
273
+ - project/Gemfile.lock
274
+ - project/README.md
275
+ - project/cucumber.yml
276
+ - project/docker-compose.yml
257
277
  - project/features/Screenshot/sample.jpg
258
278
  - project/features/TestData/globalData.yml
259
279
  - project/features/TestSuite/WebGUI.feature
280
+ - project/features/step_definitions/IFD_Libraries/REST_steps.rb
281
+ - project/features/step_definitions/IFD_Libraries/SOAP_steps.rb
282
+ - project/features/step_definitions/IFD_Libraries/database_steps.rb
283
+ - project/features/step_definitions/IFD_Libraries/dynamic_store_value_steps.rb
284
+ - project/features/step_definitions/IFD_Libraries/email_steps.rb
285
+ - project/features/step_definitions/IFD_Libraries/file_steps.rb
286
+ - project/features/step_definitions/IFD_Libraries/ssh_steps.rb
287
+ - project/features/step_definitions/IFD_Libraries/web_steps.rb
260
288
  - project/features/step_definitions/lib_steps/actionwords.rb
261
- - project/features/step_definitions/lib_steps/test.rb
289
+ - project/features/step_definitions/lib_steps/steps.rb
262
290
  - project/features/step_definitions/repositories/project_object.yml
263
291
  - project/features/support/env.rb
264
292
  - project/features/support/hooks.rb
@@ -1,90 +0,0 @@
1
- require_relative 'require_libs'
2
- require 'httparty'
3
- require 'jsonpath'
4
-
5
- Given /^I set headers:$/ do |data|
6
- unless data.hashes.empty?
7
- data = data.hashes[0]
8
- data = JSON.parse(data) unless data.is_a? Hash
9
-
10
- data.each_pair do |k, v|
11
- data[k] = check_dynamic_value(v)
12
- end
13
- @header = data
14
- end
15
- p "HEADER: #{@header}"
16
- end
17
-
18
- When /^I send a REST (GET|PUT|POST|DELETE) request (?:for|to) "([^"]*)"(?: with the following:)?$/ do |*args|
19
- request_type = args.shift.downcase
20
- url = check_dynamic_value(args.shift)
21
- put_log "Request URL: #{url}"
22
- json_payload = args.shift
23
- if json_payload
24
- payload = Hash.new
25
- JSON.parse(json_payload).each do |k1, v1|
26
- payload[check_dynamic_value(k1)] = check_dynamic_value(v1)
27
- end
28
- payload = payload.to_json
29
- end
30
- put_log "Data Body from #{request_type} method: #{payload}"
31
-
32
- if (payload.nil? && request_type == 'get' && @header.nil?)
33
- @response = Request.get(url)
34
- elsif (payload.nil? && request_type == 'get')
35
- @response = Request.get(url, {headers: @header})
36
- elsif (payload.nil? && request_type == 'delete' && @header.nil?)
37
- @response = Request.delete(url)
38
- elsif (payload.nil? && request_type == 'delete')
39
- @response = Request.delete(url, {headers: @header})
40
- elsif (payload && request_type == 'get' && @header.nil?)
41
- @response = Request.get(url, {body: payload})
42
- elsif (payload && request_type == 'get')
43
- @response = Request.get(url, {body: payload, headers: @header})
44
- elsif (payload && request_type == 'post' && @header.nil?)
45
- @response = Request.post(url, {body: payload})
46
- elsif (payload && request_type == 'post')
47
- @response = Request.post(url, {body: payload, headers: @header})
48
- elsif (payload && request_type == 'put' && @header.nil?)
49
- @response = Request.put(url, {body: payload})
50
- elsif (payload && request_type == 'put')
51
- @response = Request.put(url, {body: payload, headers: @header})
52
- end
53
- end
54
-
55
- Then /^I store the REST result at node "(.*)" as "(.*)"$/ do |json_path, var_name|
56
- $context_value = JsonPath.new(json_path).on(@response.body).to_a.map(&:to_s)[0]
57
- set_var(var_name, '$context_value')
58
- end
59
-
60
- When /^I print the result of REST request$/ do
61
- puts "REST RESULT code: #{getRestResult.code}"
62
- puts "REST RESULT body: #{getRestResult.body}"
63
- end
64
-
65
- Then /^I should see REST response code "([^"]*)"$/ do |code|
66
- Assertion.assert_string_equal(code, getRestResult.code.to_s)
67
- end
68
-
69
- Then /^the JSON response should be:$/ do |json|
70
- Assertion.assert_string_equal(json, getRestResult.body.to_s)
71
- end
72
-
73
- # Example
74
- # Then the JSON response at node "$..id" should have "1"
75
- Then /^the JSON response at node "(.*)" should have "(.*)"$/ do |json_path, expected|
76
- result = JsonPath.new(json_path).on(getRestResult.body).to_a.map(&:to_s)
77
- Assertion.assert_string_equal(expected, result[0])
78
- end
79
-
80
- class Request
81
- include HTTParty
82
- default_options.update(verify: false)
83
- end
84
-
85
- def getRestResult
86
- if @response.nil?
87
- p "WARNING***: MISSING STEPS: Please send a REST request to get response first."
88
- end
89
- @response
90
- end