Ifd_Automation 2.9 → 2.9.1
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.
- checksums.yaml +4 -4
- data/lib/Ifd_Automation/REST_steps.rb +33 -33
- data/lib/Ifd_Automation/SOAP_steps.rb +31 -31
- data/lib/Ifd_Automation/assertion_helper.rb +97 -0
- data/lib/Ifd_Automation/auto_util.rb +161 -0
- data/lib/Ifd_Automation/database_helper.rb +78 -0
- data/lib/Ifd_Automation/database_steps.rb +44 -44
- data/lib/Ifd_Automation/dynamic_store_value_steps.rb +18 -18
- data/lib/Ifd_Automation/email_steps.rb +31 -31
- data/lib/Ifd_Automation/file_helper.rb +33 -0
- data/lib/Ifd_Automation/file_steps.rb +9 -9
- data/lib/Ifd_Automation/mail_helper.rb +56 -0
- data/lib/Ifd_Automation/require_libs.rb +9 -9
- data/lib/Ifd_Automation/rest_helper.rb +89 -0
- data/lib/Ifd_Automation/soap_helper.rb +57 -0
- data/lib/Ifd_Automation/ssh_helper.rb +37 -0
- data/lib/Ifd_Automation/ssh_steps.rb +15 -15
- data/lib/{helper → Ifd_Automation}/step_fallback.rb +0 -0
- data/lib/{helper → Ifd_Automation}/tolerance_for_selenium_sync_issues.rb +0 -0
- data/lib/Ifd_Automation/version.rb +1 -1
- data/lib/{helper → Ifd_Automation}/web_steps_helper.rb +419 -40
- data/project/Gemfile +1 -1
- data/project/features/TestSuite/WebGUI.feature +4 -4
- data/project/features/step_definitions/lib_steps/steps_definition.rb +4 -2
- data/project/features/step_definitions/repositories/project_object.yml +2 -1
- metadata +13 -13
- data/lib/helper/assertion_helper.rb +0 -100
- data/lib/helper/auto_util.rb +0 -164
- data/lib/helper/database_helper.rb +0 -81
- data/lib/helper/file_helper.rb +0 -36
- data/lib/helper/mail_helper.rb +0 -58
- data/lib/helper/rest_helper.rb +0 -91
- data/lib/helper/soap_helper.rb +0 -59
- data/lib/helper/ssh_helper.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e53a9c7bc74e4108633d2d23c83803221039dcdf61b6249a0ee55a2b7179d9b3
|
4
|
+
data.tar.gz: 8b4538fc6cbe166f45fc247caf8c03df3dfbc2b85c61bdc0168c847b70f188e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e62b53c005fe64c6cb50ac54b61cdbd34605b55290214ddf9fe25048eb01a7ebcac39efb86f6d6941e0fcdf2f0305376e7cf880753e95d9fef24e6aa6af8375a
|
7
|
+
data.tar.gz: 6406659ac3236c04bc7b21cd56c7d42e8b61424047bd9b3c9777599c85efca09356106d0ccb7c7813069a84ddde43d2ea32caa03ed96bbbf3c2ba906b85939f9
|
@@ -1,34 +1,34 @@
|
|
1
|
-
require 'httparty'
|
2
|
-
require 'jsonpath'
|
3
|
-
|
4
|
-
Given /^I set headers:$/ do |data|
|
5
|
-
|
6
|
-
end
|
7
|
-
|
8
|
-
When /^I send a REST (GET|PUT|POST|DELETE) request (?:for|to) "([^"]*)"(?: with the following:)?$/ do |*args|
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
Then /^I store the REST result at node "(.*)" as "(.*)"$/ do |json_path, var_name|
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
When /^I print the result of REST request$/ do
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
Then /^I should see REST response code "([^"]*)"$/ do |code|
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
Then /^the JSON response should be:$/ do |json|
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
# Example
|
30
|
-
# Then the JSON response at node "$..id" should have "1"
|
31
|
-
Then /^the JSON response at node "(.*)" should have "(.*)"$/ do |json_path, expected|
|
32
|
-
|
33
|
-
end
|
1
|
+
# require 'httparty'
|
2
|
+
# require 'jsonpath'
|
3
|
+
|
4
|
+
# Given /^I set headers:$/ do |data|
|
5
|
+
# IFD_Rest.set_headers(data)
|
6
|
+
# end
|
7
|
+
|
8
|
+
# When /^I send a REST (GET|PUT|POST|DELETE) request (?:for|to) "([^"]*)"(?: with the following:)?$/ do |*args|
|
9
|
+
# IFD_Rest.send_request(*args)
|
10
|
+
# end
|
11
|
+
|
12
|
+
# Then /^I store the REST result at node "(.*)" as "(.*)"$/ do |json_path, var_name|
|
13
|
+
# IFD_Rest.store_json_node_result(json_path, var_name)
|
14
|
+
# end
|
15
|
+
|
16
|
+
# When /^I print the result of REST request$/ do
|
17
|
+
# IFD_Rest.print_rest_code
|
18
|
+
# IFD_Rest.get_rest_body
|
19
|
+
# end
|
20
|
+
|
21
|
+
# Then /^I should see REST response code "([^"]*)"$/ do |code|
|
22
|
+
# IFD_Rest.verify_rest_response_code(code)
|
23
|
+
# end
|
24
|
+
|
25
|
+
# Then /^the JSON response should be:$/ do |json|
|
26
|
+
# IFD_Rest.verify_response_body_with_json(json)
|
27
|
+
# end
|
28
|
+
|
29
|
+
# # Example
|
30
|
+
# # Then the JSON response at node "$..id" should have "1"
|
31
|
+
# Then /^the JSON response at node "(.*)" should have "(.*)"$/ do |json_path, expected|
|
32
|
+
# IFD_Rest.verify_response_at_json_node(json_path, expected)
|
33
|
+
# end
|
34
34
|
|
@@ -1,38 +1,38 @@
|
|
1
|
-
require 'savon'
|
2
|
-
require 'jsonpath'
|
1
|
+
# require 'savon'
|
2
|
+
# require 'jsonpath'
|
3
3
|
|
4
|
-
# Example
|
5
|
-
# When I get SOAP operations list from 'http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx?wsdl'
|
6
|
-
When /^I get SOAP operations list from '(.*?)'$/ do |url|
|
7
|
-
|
8
|
-
end
|
4
|
+
# # Example
|
5
|
+
# # When I get SOAP operations list from 'http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx?wsdl'
|
6
|
+
# When /^I get SOAP operations list from '(.*?)'$/ do |url|
|
7
|
+
# IFD_Soap.get_soap_operation_list(url)
|
8
|
+
# end
|
9
9
|
|
10
|
-
# Example
|
11
|
-
# When I send SOAP request with operation name "verify_email" and XML file "soap.xml"
|
12
|
-
When /^I send SOAP request with operation name "(.*)" and XML file "(.*)"$/ do |operation_name, file_name|
|
13
|
-
|
14
|
-
end
|
10
|
+
# # Example
|
11
|
+
# # When I send SOAP request with operation name "verify_email" and XML file "soap.xml"
|
12
|
+
# When /^I send SOAP request with operation name "(.*)" and XML file "(.*)"$/ do |operation_name, file_name|
|
13
|
+
# IFD_Soap.send_soap_with_operation_and_xml(operation_name, file_name)
|
14
|
+
# end
|
15
15
|
|
16
|
-
# Example
|
17
|
-
# I send SOAP request with operation name "xr" and following data:
|
18
|
-
# """
|
19
|
-
# Sample XML
|
20
|
-
# """
|
21
|
-
When /^I send SOAP request with operation name "(.*)" and xml data "(.*)"$/ do |operation_name, xml|
|
22
|
-
|
23
|
-
end
|
16
|
+
# # Example
|
17
|
+
# # I send SOAP request with operation name "xr" and following data:
|
18
|
+
# # """
|
19
|
+
# # Sample XML
|
20
|
+
# # """
|
21
|
+
# When /^I send SOAP request with operation name "(.*)" and xml data "(.*)"$/ do |operation_name, xml|
|
22
|
+
# IFD_Soap.send_soap_with_operation_and_data(operation_name, xml)
|
23
|
+
# end
|
24
24
|
|
25
|
-
Then /^the status code should be "(.*)"$/ do |status_code|
|
26
|
-
|
27
|
-
end
|
25
|
+
# Then /^the status code should be "(.*)"$/ do |status_code|
|
26
|
+
# IFD_Soap.verify_response_code(status_code)
|
27
|
+
# end
|
28
28
|
|
29
|
-
# Example
|
30
|
-
# Then the SOAP response node should have "$..response_text" with text "Email Domain Not Found"
|
31
|
-
Then /^the SOAP response node should have "(.*?)" with text "(.*?)"$/ do |json_path, text|
|
32
|
-
|
33
|
-
end
|
29
|
+
# # Example
|
30
|
+
# # Then the SOAP response node should have "$..response_text" with text "Email Domain Not Found"
|
31
|
+
# Then /^the SOAP response node should have "(.*?)" with text "(.*?)"$/ do |json_path, text|
|
32
|
+
# IFD_Soap.verify_response_with_json_node(json_path, text)
|
33
|
+
# end
|
34
34
|
|
35
|
-
Then /^I print the SOAP response$/ do
|
36
|
-
|
37
|
-
end
|
35
|
+
# Then /^I print the SOAP response$/ do
|
36
|
+
# IFD_Soap.print_response
|
37
|
+
# end
|
38
38
|
|
@@ -0,0 +1,97 @@
|
|
1
|
+
#Assert two files, rows not in order and REMOVE 1 COLUMN OF ID
|
2
|
+
def do_assertion_csv_tab_non_order(expected_obj, actual_obj)
|
3
|
+
for i in (1..expected_obj.length - 1)
|
4
|
+
expected_row = expected_obj[i].drop(1).to_s.split("\t")
|
5
|
+
found = false
|
6
|
+
for j in (1..actual_obj.length - 1)
|
7
|
+
actual_row = actual_obj[j].drop(1).to_s.split("\t")
|
8
|
+
if (expected_row == actual_row)
|
9
|
+
found = true
|
10
|
+
break
|
11
|
+
end
|
12
|
+
end
|
13
|
+
assert(found, "Expected Record: [#{expected_obj[i].to_s}] is not included in reporting file")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Assert 2 values
|
18
|
+
def reg_compare sActual, regValue, isSpecialChar=false
|
19
|
+
begin
|
20
|
+
if !isSpecialChar
|
21
|
+
sActual = sActual.strip
|
22
|
+
regValue = regValue.strip.gsub("[", "\\[").gsub("]", "\\]").gsub("(", "\\(").gsub(")", "\\)").gsub(">", "\\>")
|
23
|
+
end
|
24
|
+
rescue StandardError => myStandardError
|
25
|
+
raise "\n>>> Error: #{myStandardError}"
|
26
|
+
end
|
27
|
+
|
28
|
+
# put_log "\nsActual:#{sActual}, regValue:#{regValue}"
|
29
|
+
if ((sActual.nil? and regValue.nil?) or (!sActual.nil? and sActual.empty? and !regValue.nil? and regValue.empty?))
|
30
|
+
return true
|
31
|
+
end
|
32
|
+
|
33
|
+
if ((sActual.nil? and !regValue.nil?) or (!sActual.nil? and regValue.nil?))
|
34
|
+
return false
|
35
|
+
end
|
36
|
+
|
37
|
+
if (!sActual.nil? and !sActual.empty?)
|
38
|
+
sCookActual = sActual.gsub(/\n|\r/, " ")
|
39
|
+
if (sCookActual == regValue or (isSpecialChar and sCookActual.include? regValue) or (!isSpecialChar and sCookActual =~ /^.*#{regValue}.*$/))
|
40
|
+
return true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
return false
|
45
|
+
end
|
46
|
+
|
47
|
+
def do_assertion_json(expected_obj, actual_obj, options = {})
|
48
|
+
# puts "\n\n actual_obj.class: #{actual_obj.class}"
|
49
|
+
# puts "\n\n expected_obj.class: #{expected_obj.class}"
|
50
|
+
|
51
|
+
if expected_obj.kind_of? Hash
|
52
|
+
# if options['isIncludedAssertion'].nil? or options['isIncludedAssertion'] == false
|
53
|
+
# do_assertion(expected_obj.keys.size, actual_obj.keys.size)
|
54
|
+
# end
|
55
|
+
expected_obj.keys.each do |key|
|
56
|
+
# puts "\n\n key: #{key}"
|
57
|
+
# puts "\n\n value: #{expected_obj[key]}"
|
58
|
+
# puts "\n\n value: #{actual_obj[key]}"
|
59
|
+
if actual_obj[key].nil?
|
60
|
+
raise "[%s] expected [%s] but actual value was nil." % [key, expected_obj[key].to_s]
|
61
|
+
else
|
62
|
+
do_assertion_json(expected_obj[key], actual_obj[key], options)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
elsif expected_obj.kind_of? Array
|
66
|
+
if options['isIncludedAssertion'].nil? or options['isIncludedAssertion'] == false
|
67
|
+
do_assertion_json(expected_obj.size, actual_obj.size)
|
68
|
+
end
|
69
|
+
for i in (0..expected_obj.length-1)
|
70
|
+
do_assertion_json(expected_obj[i], actual_obj[i], options)
|
71
|
+
end
|
72
|
+
else
|
73
|
+
begin
|
74
|
+
assert_string_equal(expected_obj.to_s, actual_obj.to_s)
|
75
|
+
rescue => e
|
76
|
+
raise("Assert fail. \n\n Expected: '#{expected_obj}' \n\n Got: '#{actual_obj}'. Detail info: #{e.message}")
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def assert_string_contain(expected, actual)
|
82
|
+
unless (actual.to_s).include? (expected.to_s)
|
83
|
+
raise ("*** ASSERTION ERROR: \nExpected: #{expected}. \nGot: #{actual}.")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def assert_string_equal(expected, actual)
|
88
|
+
if expected.to_s != actual.to_s
|
89
|
+
raise ("*** ASSERTION ERROR: \nExpected: #{expected}. \nGot: #{actual}.")
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def assert_string_not_equal(expected, actual)
|
94
|
+
if expected.to_s == actual.to_s
|
95
|
+
raise ("*** ASSERTION ERROR: \nExpected: #{expected}. \nGot: #{actual}.")
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,161 @@
|
|
1
|
+
#-----------------------------------------------------
|
2
|
+
# support define and bind variable dynamically
|
3
|
+
#-----------------------------------------------------
|
4
|
+
$dyn_vars = nil
|
5
|
+
|
6
|
+
# set value to a variable
|
7
|
+
def set_var(var_name, var_value)
|
8
|
+
if $dyn_vars == nil
|
9
|
+
$dyn_vars = binding
|
10
|
+
end
|
11
|
+
|
12
|
+
strEval = var_name + "=" + var_value
|
13
|
+
eval strEval, $dyn_vars
|
14
|
+
end
|
15
|
+
|
16
|
+
def check_dynamic_value value
|
17
|
+
if !value.is_a? Fixnum
|
18
|
+
if value.include? "params="
|
19
|
+
resolve_params value
|
20
|
+
else
|
21
|
+
bind_with_dyn_vars value
|
22
|
+
end
|
23
|
+
else
|
24
|
+
value
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
def resolve_params url
|
30
|
+
condition = url.match(/params='([^']*)'/)[0]
|
31
|
+
if condition
|
32
|
+
params_name = url.match(/params='([^']*)'/)[1]
|
33
|
+
params_value = $PARAMS["#{params_name.downcase}"].to_s.strip
|
34
|
+
if params_value.present?
|
35
|
+
url = url.gsub(condition, params_value)
|
36
|
+
else
|
37
|
+
raise "ERROR: no data found with given params #{params_name}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
url
|
41
|
+
end
|
42
|
+
|
43
|
+
# bind string with $dyn_vars context
|
44
|
+
def bind_with_dyn_vars(str)
|
45
|
+
if $dyn_vars == nil
|
46
|
+
$dyn_vars = binding
|
47
|
+
end
|
48
|
+
|
49
|
+
strEval = '"' + str + '"'
|
50
|
+
return eval strEval, $dyn_vars
|
51
|
+
end
|
52
|
+
|
53
|
+
# evaluate operation/statement with $dyn_vars context
|
54
|
+
def eval_with_dyn_vars(operation)
|
55
|
+
if $dyn_vars == nil
|
56
|
+
$dyn_vars = binding
|
57
|
+
end
|
58
|
+
|
59
|
+
eval operation, $dyn_vars
|
60
|
+
end
|
61
|
+
|
62
|
+
def bind_with_dyn_json_vars(json, bind_json)
|
63
|
+
if json.kind_of? Hash
|
64
|
+
json.each_pair do |k, v|
|
65
|
+
if v.kind_of? String
|
66
|
+
bind_json[bind_with_dyn_vars(k)] = bind_with_dyn_json_vars(v, bind_json)
|
67
|
+
elsif v.kind_of? Hash
|
68
|
+
temp = Hash.new
|
69
|
+
v.each_pair do |k1, v1|
|
70
|
+
temp[bind_with_dyn_vars(k1)] = bind_with_dyn_json_vars(v1, temp)
|
71
|
+
end
|
72
|
+
bind_json[bind_with_dyn_vars(k)] = temp
|
73
|
+
elsif v.kind_of? Array
|
74
|
+
temp1 = Array.new
|
75
|
+
v.each { |item|
|
76
|
+
temp2 = Hash.new
|
77
|
+
bind_with_dyn_json_vars(item, temp2)
|
78
|
+
temp1 << temp2
|
79
|
+
}
|
80
|
+
bind_json[bind_with_dyn_vars(k)] = temp1
|
81
|
+
end
|
82
|
+
end
|
83
|
+
elsif json.kind_of? Array
|
84
|
+
temp1 = Array.new
|
85
|
+
json.each { |item|
|
86
|
+
temp2 = Hash.new
|
87
|
+
bind_with_dyn_json_vars(item, temp2)
|
88
|
+
temp1 << temp2
|
89
|
+
}
|
90
|
+
return temp1
|
91
|
+
else
|
92
|
+
return bind_with_dyn_vars(json)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
def var_collect string_var
|
98
|
+
if string_var =~ /^.*{year}.*$/
|
99
|
+
string_var = replace_year(string_var)
|
100
|
+
end
|
101
|
+
|
102
|
+
if string_var =~ /^.*{month}.*$/
|
103
|
+
string_var = replace_month(string_var)
|
104
|
+
end
|
105
|
+
|
106
|
+
if string_var =~ /^.*{day}.*$/
|
107
|
+
string_var = replace_day(string_var)
|
108
|
+
end
|
109
|
+
|
110
|
+
if string_var =~ /^.*{store_value}.*$/
|
111
|
+
string_var = $context_value
|
112
|
+
end
|
113
|
+
|
114
|
+
return string_var
|
115
|
+
end
|
116
|
+
|
117
|
+
def replace_year str
|
118
|
+
t = Time.now()
|
119
|
+
return str.gsub("{year}", t.year.to_s)
|
120
|
+
end
|
121
|
+
|
122
|
+
def replace_month str
|
123
|
+
t = Time.now()
|
124
|
+
_month = t.month
|
125
|
+
if _month < 10
|
126
|
+
return str.gsub("{month}", "0#{_month.to_s}")
|
127
|
+
else
|
128
|
+
return str.gsub("{month}", "#{_month.to_s}")
|
129
|
+
end
|
130
|
+
return str
|
131
|
+
end
|
132
|
+
|
133
|
+
def replace_day str
|
134
|
+
t = Time.now()
|
135
|
+
_day = t.day
|
136
|
+
if _day < 10
|
137
|
+
return str.gsub("{day}", "0#{_day.to_s}")
|
138
|
+
else
|
139
|
+
return str.gsub("{day}", "#{_day.to_s}")
|
140
|
+
end
|
141
|
+
return str
|
142
|
+
end
|
143
|
+
|
144
|
+
def replace_pipe str_pipe
|
145
|
+
put_log ">>>> #{str_pipe}"
|
146
|
+
if str_pipe =~ /^.*{pipe}.*$/
|
147
|
+
return str_pipe.gsub("{pipe}", "|")
|
148
|
+
end
|
149
|
+
return str_pipe
|
150
|
+
end
|
151
|
+
|
152
|
+
def store_string_as_variable(string,variable)
|
153
|
+
# $context_value = bind_with_dyn_vars(string)
|
154
|
+
# set_var(variable, '$context_value')
|
155
|
+
require 'erb'
|
156
|
+
ERB.new(string, 0, "", "#{variable}").result(binding)
|
157
|
+
end
|
158
|
+
|
159
|
+
def print_variable(variable)
|
160
|
+
puts "VALUE OF #{variable}: #{eval_with_dyn_vars(variable)}"
|
161
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'tiny_tds'
|
2
|
+
require 'activerecord-sqlserver-adapter'
|
3
|
+
require 'active_record'
|
4
|
+
|
5
|
+
def new_cnn(connection_params)
|
6
|
+
begin
|
7
|
+
put_log ("Connecting to database...")
|
8
|
+
return ActiveRecord::Base.establish_connection(connection_params)
|
9
|
+
rescue Exception => e
|
10
|
+
raise e.message
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_database_connection(data)
|
15
|
+
unless data.hashes.empty?
|
16
|
+
data = data.hashes[0]
|
17
|
+
data = JSON.parse(data) unless data.is_a? Hash
|
18
|
+
|
19
|
+
data.each_pair do |k, v|
|
20
|
+
data[k] = check_dynamic_value(v)
|
21
|
+
end
|
22
|
+
@connection = new_cnn(data)
|
23
|
+
put_log "Connect to database successfully!" if @connection
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def close_database_connection
|
28
|
+
@connection.disconnect!
|
29
|
+
if !@connection.connected?
|
30
|
+
put_log "Disconnected to Database!"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def execute_select(script)
|
35
|
+
script = check_dynamic_value(script)
|
36
|
+
if @connection
|
37
|
+
@result = @connection.connection.exec_query(script)
|
38
|
+
else
|
39
|
+
raise "ERROR: Create connection to database first!"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def execute_script(script)
|
44
|
+
script = check_dynamic_value(script)
|
45
|
+
if @connection
|
46
|
+
@result = @connection.connection.execute(script)
|
47
|
+
else
|
48
|
+
raise "ERROR: Create connection to database first!"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def print_sql_result
|
53
|
+
if @result.present?
|
54
|
+
@result.each do |row|
|
55
|
+
p row
|
56
|
+
end
|
57
|
+
else
|
58
|
+
p "WARNING: No result from SQL statement"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def verify_sql_result_with_json(json)
|
63
|
+
expected = JSON.parse(json)
|
64
|
+
@result.each do |row|
|
65
|
+
assert_string_equal(expected,row)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def verify_sql_result_with_json_node(json_node, value)
|
70
|
+
@result.each do|row|
|
71
|
+
results = JsonPath.new(json_node).on(row).to_a.map(&:to_s)
|
72
|
+
assert_string_equal(results[0], value)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def store_sql_result_into_string(string)
|
77
|
+
set_var(string, @result)
|
78
|
+
end
|
@@ -1,44 +1,44 @@
|
|
1
|
-
Given /^I create connection to database with:$/ do |data|
|
2
|
-
|
3
|
-
end
|
4
|
-
|
5
|
-
When /^I close SQL connection$/ do
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
And /^I run sql script:$/ do |raw_data|
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
And /^I run sql select query script:$/ do |raw_data|
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
# Example
|
18
|
-
# When I run sql script "select * from users where email=#{id}"
|
19
|
-
And /^I run sql script "(.*)"$/ do |sql|
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
Then /^show me the result of SQL statement$/ do
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
# Example
|
28
|
-
# Then the result of SQL statement should be:
|
29
|
-
# """
|
30
|
-
# {"name": "quoc anh", "email": "anhpq.info@gmail.com"}
|
31
|
-
# """
|
32
|
-
Then /^the result of SQL statement should be:$/ do |json|
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
# Example
|
37
|
-
# Then the result of SQL statement should have "email" with value "anhpq.info@gmail.com"
|
38
|
-
Then /^the result of SQL statement should have "(.*)" with value "(.*)"$/ do |json_path, value|
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
When /^I store the result of SQL script as "(.*?)"$/ do |var_name|
|
43
|
-
|
44
|
-
end
|
1
|
+
# Given /^I create connection to database with:$/ do |data|
|
2
|
+
# IFD_DBConnection.create_database_connection(data)
|
3
|
+
# end
|
4
|
+
|
5
|
+
# When /^I close SQL connection$/ do
|
6
|
+
# IFD_DBConnection.close_database_connection
|
7
|
+
# end
|
8
|
+
|
9
|
+
# And /^I run sql script:$/ do |raw_data|
|
10
|
+
# IFD_DBConnection.execute_script(raw_data)
|
11
|
+
# end
|
12
|
+
|
13
|
+
# And /^I run sql select query script:$/ do |raw_data|
|
14
|
+
# IFD_DBConnection.execute_select(raw_data)
|
15
|
+
# end
|
16
|
+
|
17
|
+
# # Example
|
18
|
+
# # When I run sql script "select * from users where email=#{id}"
|
19
|
+
# And /^I run sql script "(.*)"$/ do |sql|
|
20
|
+
# IFD_DBConnection.execute_script(sql)
|
21
|
+
# end
|
22
|
+
|
23
|
+
# Then /^show me the result of SQL statement$/ do
|
24
|
+
# IFD_DBConnection.print_sql_result
|
25
|
+
# end
|
26
|
+
|
27
|
+
# # Example
|
28
|
+
# # Then the result of SQL statement should be:
|
29
|
+
# # """
|
30
|
+
# # {"name": "quoc anh", "email": "anhpq.info@gmail.com"}
|
31
|
+
# # """
|
32
|
+
# Then /^the result of SQL statement should be:$/ do |json|
|
33
|
+
# IFD_DBConnection.verify_sql_result_with_json(json)
|
34
|
+
# end
|
35
|
+
|
36
|
+
# # Example
|
37
|
+
# # Then the result of SQL statement should have "email" with value "anhpq.info@gmail.com"
|
38
|
+
# Then /^the result of SQL statement should have "(.*)" with value "(.*)"$/ do |json_path, value|
|
39
|
+
# IFD_DBConnection.verify_sql_result_with_json_node(json_path,value)
|
40
|
+
# end
|
41
|
+
|
42
|
+
# When /^I store the result of SQL script as "(.*?)"$/ do |var_name|
|
43
|
+
# IFD_DBConnection.store_sql_result_into_string(var_name)
|
44
|
+
# end
|
@@ -1,23 +1,23 @@
|
|
1
|
-
$result = nil
|
2
|
-
$context_value = nil
|
1
|
+
# $result = nil
|
2
|
+
# $context_value = nil
|
3
3
|
|
4
|
-
Given /^I get text on "(.*)" then store it as "(.*)"$/ do |object, temp|
|
5
|
-
|
6
|
-
end
|
4
|
+
# Given /^I get text on "(.*)" then store it as "(.*)"$/ do |object, temp|
|
5
|
+
# get_object_and_store_as_string(object,temp)
|
6
|
+
# end
|
7
7
|
|
8
|
-
When /^I store string "(.*?)" as "(.*?)"$/ do |str, var_name|
|
9
|
-
|
10
|
-
end
|
8
|
+
# When /^I store string "(.*?)" as "(.*?)"$/ do |str, var_name|
|
9
|
+
# store_string_as_variable(str,var_name)
|
10
|
+
# end
|
11
11
|
|
12
|
-
Given /^I print the value of "(.*)"$/ do |temp|
|
13
|
-
|
14
|
-
end
|
12
|
+
# Given /^I print the value of "(.*)"$/ do |temp|
|
13
|
+
# print_variable(temp)
|
14
|
+
# end
|
15
15
|
|
16
|
-
# get text for object
|
17
|
-
And /^I get text on "(.*?)" then store it into file "(.*)"$/ do |object, file_name|
|
18
|
-
|
19
|
-
end
|
16
|
+
# # get text for object
|
17
|
+
# And /^I get text on "(.*?)" then store it into file "(.*)"$/ do |object, file_name|
|
18
|
+
# get_object_and_store_to_file(object,file_name)
|
19
|
+
# end
|
20
20
|
|
21
|
-
When /^I create xml file and store as string "(.*)":$/ do |var_name, xml|
|
22
|
-
|
23
|
-
end
|
21
|
+
# When /^I create xml file and store as string "(.*)":$/ do |var_name, xml|
|
22
|
+
# store_string_as_variable(xml,var_name)
|
23
|
+
# end
|