theotokos 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/net/soap_net.rb +52 -50
- data/lib/report/chart_factory.rb +62 -60
- data/lib/report/console.rb +79 -77
- data/lib/report/html.rb +48 -46
- data/lib/report/json.rb +17 -15
- data/lib/report/reporter.rb +62 -60
- data/lib/version.rb +1 -1
- data/test/unit/report/test_json.rb +1 -1
- metadata +8 -8
data/README.md
CHANGED
@@ -4,7 +4,7 @@ Theotokos
|
|
4
4
|
[![Build Status](https://travis-ci.org/aureliano/theotokos.png?branch=master)](https://travis-ci.org/aureliano/theotokos)
|
5
5
|
|
6
6
|
### Overview
|
7
|
-
Theotokos is a gem for web service testing.
|
7
|
+
Theotokos is a gem for web service testing. It provides an easy way to create test suites by using YAML as modeling language. It aims to avoid code implementation of web service tests as much as possible. So that non-programmers can design a simple model file and let Theotokos do the job.
|
8
8
|
|
9
9
|
### Get ready
|
10
10
|
Install by Rubygems `gem install theotokos`
|
data/lib/net/soap_net.rb
CHANGED
@@ -1,58 +1,60 @@
|
|
1
|
-
module
|
1
|
+
module Theotokos
|
2
|
+
module Net
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
def self.send_request(options)
|
6
|
-
logger = AppLogger.create_logger self
|
7
|
-
client = _savon_client options[:wsdl], options[:ws_config], options[:ws_security]
|
8
|
-
service = options[:service].to_s.gsub(/(.)([A-Z])/,'\1_\2').downcase # snake_case
|
9
|
-
xml = success = nil
|
10
|
-
|
11
|
-
begin
|
12
|
-
logger.debug "Send request to service '#{service}'"
|
13
|
-
response = client.call service.to_sym, :message => options[:params]
|
14
|
-
xml = Nokogiri::XML(response.xml, nil, "UTF-8").to_xml
|
15
|
-
success = true
|
16
|
-
rescue Exception => ex
|
17
|
-
return { :success => false, :xml => Nokogiri::XML(ex.http.body, nil, "UTF-8").to_xml } if ex.instance_of? Savon::SOAPFault
|
18
|
-
|
19
|
-
xml = Nokogiri::XML::Builder.new do |xml|
|
20
|
-
xml.error do
|
21
|
-
xml.message ex.to_s
|
22
|
-
xml.backtrace ex.backtrace.join("\n ")
|
23
|
-
end
|
24
|
-
end.to_xml
|
25
|
-
success = false
|
26
|
-
end
|
27
|
-
|
28
|
-
logger.debug "Success on request? #{success}"
|
29
|
-
{ :success => success, :xml => xml }
|
30
|
-
end
|
4
|
+
class SoapNet
|
31
5
|
|
32
|
-
|
33
|
-
|
34
|
-
|
6
|
+
def self.send_request(options)
|
7
|
+
logger = AppLogger.create_logger self
|
8
|
+
client = _savon_client options[:wsdl], options[:ws_config], options[:ws_security]
|
9
|
+
service = options[:service].to_s.gsub(/(.)([A-Z])/,'\1_\2').downcase # snake_case
|
10
|
+
xml = success = nil
|
11
|
+
|
12
|
+
begin
|
13
|
+
logger.debug "Send request to service '#{service}'"
|
14
|
+
response = client.call service.to_sym, :message => options[:params]
|
15
|
+
xml = Nokogiri::XML(response.xml, nil, "UTF-8").to_xml
|
16
|
+
success = true
|
17
|
+
rescue Exception => ex
|
18
|
+
return { :success => false, :xml => Nokogiri::XML(ex.http.body, nil, "UTF-8").to_xml } if ex.instance_of? Savon::SOAPFault
|
19
|
+
|
20
|
+
xml = Nokogiri::XML::Builder.new do |xml|
|
21
|
+
xml.error do
|
22
|
+
xml.message ex.to_s
|
23
|
+
xml.backtrace ex.backtrace.join("\n ")
|
24
|
+
end
|
25
|
+
end.to_xml
|
26
|
+
success = false
|
27
|
+
end
|
28
|
+
|
29
|
+
logger.debug "Success on request? #{success}"
|
30
|
+
{ :success => success, :xml => xml }
|
31
|
+
end
|
35
32
|
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
def self._savon_client(wsdl_url, ws_config, ws_security)
|
34
|
+
logger = AppLogger.create_logger self
|
35
|
+
logger.debug "Prepare web service app client"
|
36
|
+
|
37
|
+
params = {}
|
38
|
+
params[:env_namespace] = ws_config.env_namespace if ws_config.env_namespace
|
39
|
+
params[:namespaces] = ws_config.namespaces if ws_config.namespaces
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
41
|
+
params[:ssl_verify_mode] = ws_config.ssl_verify_mode if ws_config.ssl_verify_mode
|
42
|
+
params[:ssl_version] = ws_config.ssl_version if ws_config.ssl_version
|
43
|
+
params[:ssl_cert_file] = ws_config.ssl_cert_file if ws_config.ssl_cert_file
|
44
|
+
params[:ssl_cert_key_file] = ws_config.ssl_cert_key_file if ws_config.ssl_cert_key_file
|
45
|
+
params[:ssl_ca_cert_file] = ws_config.ssl_ca_cert_file if ws_config.ssl_ca_cert_file
|
46
|
+
params[:ssl_cert_key_password] = ws_config.ssl_cert_key_password if ws_config.ssl_cert_key_password
|
47
|
+
|
48
|
+
logger.debug "Client config params for requesting service: #{params}"
|
49
|
+
logger.debug "WS-Security params: #{ws_security}" if (!ws_security.nil? && !ws_security.empty?)
|
50
|
+
|
51
|
+
Savon.client(params) do
|
52
|
+
wsdl wsdl_url
|
53
|
+
wsse_auth ws_security['login'], ws_security['password'], :digest if (!ws_security.nil? && !ws_security.empty?)
|
54
|
+
end
|
53
55
|
end
|
56
|
+
|
54
57
|
end
|
55
|
-
|
58
|
+
|
56
59
|
end
|
57
|
-
|
58
60
|
end
|
data/lib/report/chart_factory.rb
CHANGED
@@ -1,68 +1,70 @@
|
|
1
|
-
module
|
1
|
+
module Theotokos
|
2
|
+
module Report
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
def self.success_failure_chart(opt)
|
6
|
-
total = opt[:total_success].to_i + opt[:total_failures].to_f
|
7
|
-
success = ((opt[:total_success].to_i * 100) / total).to_f.round 2
|
8
|
-
failures = ((opt[:total_failures].to_i * 100) / total).to_f.round 2
|
4
|
+
class ChartFactory
|
9
5
|
|
10
|
-
|
11
|
-
|
6
|
+
def self.success_failure_chart(opt)
|
7
|
+
total = opt[:total_success].to_i + opt[:total_failures].to_f
|
8
|
+
success = ((opt[:total_success].to_i * 100) / total).to_f.round 2
|
9
|
+
failures = ((opt[:total_failures].to_i * 100) / total).to_f.round 2
|
10
|
+
|
11
|
+
str = "[{ value: #{success}, color: \"#1A0B9C\", highlight: \"#1E0CC0\", label: \"Success (%)\"},"
|
12
|
+
str << "{ value : #{failures}, color : \"#BF1717\", highlight: \"#D71515\", label: \"Failures (%)\"}]"
|
13
|
+
|
14
|
+
ChartFactory._template :id => opt[:id], :data => str, :type => :pie
|
15
|
+
end
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
def self.totals_tags_chart(opt)
|
17
|
-
stats = opt[:stats]
|
18
|
-
str = <<-eos
|
19
|
-
{
|
20
|
-
labels: ["#{stats.keys.join('","')}"],
|
21
|
-
datasets: [{
|
22
|
-
fillColor: "rgba(151,187,205,0.5)",
|
23
|
-
strokeColor: "rgba(151,187,205,0.8)",
|
24
|
-
highlightFill: "rgba(151,187,205,0.75)",
|
25
|
-
highlightStroke: "rgba(151,187,205,1)",
|
26
|
-
data: [#{stats.map {|k, v| stats[k][:total] }.join(',')}]
|
27
|
-
}]
|
28
|
-
}
|
29
|
-
eos
|
30
|
-
ChartFactory._template :id => opt[:id], :data => str, :type => :bar
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.stats_tags_chart(opt)
|
34
|
-
stats = opt[:stats]
|
35
|
-
str = <<-eos
|
36
|
-
{
|
37
|
-
labels: ["#{stats.keys.join('","')}"],
|
38
|
-
datasets: [{
|
39
|
-
fillColor: "rgba(220,220,220,0.5)",
|
40
|
-
strokeColor: "rgba(220,220,220,0.8)",
|
41
|
-
highlightFill: "rgba(220,220,220,0.75)",
|
42
|
-
highlightStroke: "rgba(220,220,220,1)",
|
43
|
-
data: [#{stats.keys.map {|k| 100 }.join(',')}]
|
44
|
-
},
|
17
|
+
def self.totals_tags_chart(opt)
|
18
|
+
stats = opt[:stats]
|
19
|
+
str = <<-eos
|
45
20
|
{
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
}
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
21
|
+
labels: ["#{stats.keys.join('","')}"],
|
22
|
+
datasets: [{
|
23
|
+
fillColor: "rgba(151,187,205,0.5)",
|
24
|
+
strokeColor: "rgba(151,187,205,0.8)",
|
25
|
+
highlightFill: "rgba(151,187,205,0.75)",
|
26
|
+
highlightStroke: "rgba(151,187,205,1)",
|
27
|
+
data: [#{stats.map {|k, v| stats[k][:total] }.join(',')}]
|
28
|
+
}]
|
29
|
+
}
|
30
|
+
eos
|
31
|
+
ChartFactory._template :id => opt[:id], :data => str, :type => :bar
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.stats_tags_chart(opt)
|
35
|
+
stats = opt[:stats]
|
36
|
+
str = <<-eos
|
37
|
+
{
|
38
|
+
labels: ["#{stats.keys.join('","')}"],
|
39
|
+
datasets: [{
|
40
|
+
fillColor: "rgba(220,220,220,0.5)",
|
41
|
+
strokeColor: "rgba(220,220,220,0.8)",
|
42
|
+
highlightFill: "rgba(220,220,220,0.75)",
|
43
|
+
highlightStroke: "rgba(220,220,220,1)",
|
44
|
+
data: [#{stats.keys.map {|k| 100 }.join(',')}]
|
45
|
+
},
|
46
|
+
{
|
47
|
+
fillColor: "rgba(151,187,205,0.5)",
|
48
|
+
strokeColor: "rgba(151,187,205,0.8)",
|
49
|
+
highlightFill: "rgba(151,187,205,0.75)",
|
50
|
+
highlightStroke: "rgba(151,187,205,1)",
|
51
|
+
data: [#{stats.map {|k, v| stats[k][:stat] }.join(',')}]
|
52
|
+
}]
|
53
|
+
}
|
54
|
+
eos
|
55
|
+
ChartFactory._template :id => opt[:id], :data => str, :type => :bar
|
56
|
+
end
|
57
|
+
|
58
|
+
def self._template(opt)
|
59
|
+
<<-eos
|
60
|
+
var data = #{opt[:data]};
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
eos
|
62
|
+
var chart = document.getElementById("#{opt[:id]}").getContext("2d");
|
63
|
+
new Chart(chart).#{opt[:type].to_s.capitalize}(data, {});
|
64
|
+
eos
|
65
|
+
end
|
66
|
+
|
64
67
|
end
|
65
|
-
|
66
|
-
end
|
67
68
|
|
69
|
+
end
|
68
70
|
end
|
data/lib/report/console.rb
CHANGED
@@ -1,94 +1,96 @@
|
|
1
|
-
module
|
1
|
+
module Theotokos
|
2
|
+
module Report
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
def print(object)
|
6
|
-
case object.class.name
|
7
|
-
when Theotokos::Model::TestResult.name then _print_test_result object
|
8
|
-
when Theotokos::Model::TestSuiteResult.name then _print_test_suite_result object
|
9
|
-
when Theotokos::Model::TestAppResult.name then _print_test_app_result object
|
10
|
-
else puts "Console printing is not supported for objects of type #{object.class.name}"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
def _print_test_result(test)
|
16
|
-
@output = ''
|
17
|
-
_append "Test case: ##{test.name}"
|
18
|
-
_append "Test description: #{test.description}"
|
19
|
-
_append "Tags: #{test.tags.join(', ')}" if test.tags
|
20
|
-
_append "Test expectations."
|
4
|
+
class Console < Reporter
|
21
5
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
6
|
+
def print(object)
|
7
|
+
case object.class.name
|
8
|
+
when Theotokos::Model::TestResult.name then _print_test_result object
|
9
|
+
when Theotokos::Model::TestSuiteResult.name then _print_test_suite_result object
|
10
|
+
when Theotokos::Model::TestAppResult.name then _print_test_app_result object
|
11
|
+
else puts "Console printing is not supported for objects of type #{object.class.name}"
|
27
12
|
end
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def _print_test_result(test)
|
17
|
+
@output = ''
|
18
|
+
_append "Test case: ##{test.name}"
|
19
|
+
_append "Test description: #{test.description}"
|
20
|
+
_append "Tags: #{test.tags.join(', ')}" if test.tags
|
21
|
+
_append "Test expectations."
|
22
|
+
|
23
|
+
if test.test_expectation && !test.status.nil?
|
24
|
+
if test.test_expectation['file']
|
25
|
+
file = test.test_expectation['file']
|
26
|
+
_append " => File '#{file}'\n#{File.read(Helper.format_ws_output_path file)}"
|
27
|
+
_append " => Status: #{test.status.test_file_status ? 'Passed' : 'Failed'}\n"
|
28
|
+
end
|
29
|
+
puts
|
30
|
+
if test.test_expectation['text']
|
31
|
+
exp = test.test_expectation['text']
|
32
|
+
_append " => Text\n"
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
exp.each do |k, v|
|
35
|
+
_append "#{k}: #{v}"
|
36
|
+
if test.status.test_text_status.nil?
|
37
|
+
_append "Status: Not performed"
|
38
|
+
else
|
39
|
+
status = test.status.test_text_status[k.to_sym]
|
40
|
+
_append "Status: #{status ? 'Passed' : 'Failed'}"
|
41
|
+
end
|
40
42
|
end
|
41
|
-
end
|
42
|
-
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
if test.error
|
47
|
+
backtrace = ((test.error[:backtrace].instance_of? Array) ? test.error[:backtrace].join("\n") : test.error[:backtrace])
|
48
|
+
_append "\n - Error message: #{test.error[:message]}"
|
49
|
+
_append "\n - Error detail:\n#{backtrace}"
|
50
|
+
else
|
51
|
+
_append "\n- Found output."
|
52
|
+
_append (test.test_actual) ? File.read(test.test_actual) : ''
|
53
|
+
end
|
54
|
+
|
55
|
+
_append "\n- Test case status: #{((test.status.nil?) ? 'Skipped' : (test.status.success? ? 'Success' : 'Fail'))}"
|
56
|
+
_append "\n------\n\n"
|
57
|
+
|
58
|
+
@output
|
43
59
|
end
|
44
60
|
|
45
|
-
|
46
|
-
|
47
|
-
_append "
|
48
|
-
_append "
|
49
|
-
|
50
|
-
|
51
|
-
|
61
|
+
def _print_test_suite_result(suite)
|
62
|
+
@output = ''
|
63
|
+
_append "-" * 100
|
64
|
+
_append "Total test success: #{suite.total_success}"
|
65
|
+
_append "Total test failures: #{suite.total_failures}"
|
66
|
+
|
67
|
+
@output
|
52
68
|
end
|
53
69
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
@output
|
58
|
-
end
|
59
|
-
|
60
|
-
def _print_test_suite_result(suite)
|
61
|
-
@output = ''
|
62
|
-
_append "-" * 100
|
63
|
-
_append "Total test success: #{suite.total_success}"
|
64
|
-
_append "Total test failures: #{suite.total_failures}"
|
65
|
-
|
66
|
-
@output
|
67
|
-
end
|
68
|
-
|
69
|
-
def _print_test_app_result(app)
|
70
|
-
@output = ''
|
71
|
-
_append "*" * 100
|
72
|
-
_append "Total test suites success: #{app.total_success}"
|
73
|
-
_append "Total test suites failures: #{app.total_failures}\n"
|
74
|
-
|
75
|
-
if app.error?
|
70
|
+
def _print_test_app_result(app)
|
71
|
+
@output = ''
|
76
72
|
_append "*" * 100
|
77
|
-
_append "
|
78
|
-
app.
|
79
|
-
|
73
|
+
_append "Total test suites success: #{app.total_success}"
|
74
|
+
_append "Total test suites failures: #{app.total_failures}\n"
|
75
|
+
|
76
|
+
if app.error?
|
77
|
+
_append "*" * 100
|
78
|
+
_append "- Broken tests"
|
79
|
+
app.broken_suites.each do |suite|
|
80
|
+
_append "Test suite: #{suite.model.source}\nTest cases: ##{suite.broken_tests.map {|t| t.name }.join(', #')}"
|
81
|
+
end
|
80
82
|
end
|
83
|
+
|
84
|
+
@output
|
81
85
|
end
|
82
86
|
|
83
|
-
|
84
|
-
|
87
|
+
def _append(text)
|
88
|
+
@output << "\n" unless @output.empty?
|
89
|
+
@output << text
|
90
|
+
puts text unless ENV['ENVIRONMENT'] == 'test'
|
91
|
+
end
|
85
92
|
|
86
|
-
def _append(text)
|
87
|
-
@output << "\n" unless @output.empty?
|
88
|
-
@output << text
|
89
|
-
puts text unless ENV['ENVIRONMENT'] == 'test'
|
90
93
|
end
|
91
|
-
|
92
|
-
end
|
93
94
|
|
95
|
+
end
|
94
96
|
end
|
data/lib/report/html.rb
CHANGED
@@ -1,55 +1,57 @@
|
|
1
|
-
module
|
1
|
+
module Theotokos
|
2
|
+
module Report
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
config_locale
|
7
|
-
@logger = AppLogger.create_logger self
|
8
|
-
end
|
4
|
+
class Html < Reporter
|
9
5
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
Dir.mkdir ENV['ws.test.reports.path'] unless File.exist? ENV['ws.test.reports.path']
|
14
|
-
|
15
|
-
@app = data[:app_result]
|
16
|
-
@ws_config = data[:ws_config]
|
17
|
-
@tags = data[:tags]
|
18
|
-
@suite_pages = {}
|
19
|
-
|
20
|
-
file = "#{ENV['ws.test.reports.path']}/index.html"
|
21
|
-
File.open(file, 'w') {|file| file.write Helper.build_index_page(@app, @locale, @ws_config, @tags) }
|
22
|
-
@logger.info "HTML report saved to #{file}" unless ENV['ENVIRONMENT'] == 'test'
|
23
|
-
|
24
|
-
@app.suites.each do |suite|
|
25
|
-
file = "#{ENV['ws.test.reports.path']}/#{suite.model.name}.html"
|
26
|
-
@logger.debug " -> Save HTML suite page for '#{suite.model.name}' to '#{file}'"
|
27
|
-
File.open(file, 'w') {|file| file.write Helper.build_suite_page @app, @locale, suite }
|
6
|
+
def initialize
|
7
|
+
config_locale
|
8
|
+
@logger = AppLogger.create_logger self
|
28
9
|
end
|
29
10
|
|
30
|
-
|
11
|
+
def print(data)
|
12
|
+
return if ENV['ENVIRONMENT'] == 'test'
|
13
|
+
Dir.mkdir 'tmp' unless File.exist? 'tmp'
|
14
|
+
Dir.mkdir ENV['ws.test.reports.path'] unless File.exist? ENV['ws.test.reports.path']
|
15
|
+
|
16
|
+
@app = data[:app_result]
|
17
|
+
@ws_config = data[:ws_config]
|
18
|
+
@tags = data[:tags]
|
19
|
+
@suite_pages = {}
|
20
|
+
|
21
|
+
file = "#{ENV['ws.test.reports.path']}/index.html"
|
22
|
+
File.open(file, 'w') {|file| file.write Helper.build_index_page(@app, @locale, @ws_config, @tags) }
|
23
|
+
@logger.info "HTML report saved to #{file}" unless ENV['ENVIRONMENT'] == 'test'
|
24
|
+
|
25
|
+
@app.suites.each do |suite|
|
26
|
+
file = "#{ENV['ws.test.reports.path']}/#{suite.model.name}.html"
|
27
|
+
@logger.debug " -> Save HTML suite page for '#{suite.model.name}' to '#{file}'"
|
28
|
+
File.open(file, 'w') {|file| file.write Helper.build_suite_page @app, @locale, suite }
|
29
|
+
end
|
30
|
+
|
31
|
+
_copy_resources
|
32
|
+
|
33
|
+
file
|
34
|
+
end
|
31
35
|
|
32
|
-
|
33
|
-
|
36
|
+
private
|
37
|
+
def _copy_resources
|
38
|
+
html_path = File.expand_path('../../../html', __FILE__)
|
39
|
+
css_path = "#{ENV['ws.test.reports.path']}/css"
|
40
|
+
Dir.mkdir css_path unless File.exist? css_path
|
41
|
+
|
42
|
+
@logger.debug "Copy stylesheets to #{css_path}"
|
43
|
+
FileUtils.cp "#{html_path}/bootstrap.min.css", css_path
|
44
|
+
|
45
|
+
js_path = "#{ENV['ws.test.reports.path']}/js"
|
46
|
+
Dir.mkdir js_path unless File.exist? js_path
|
47
|
+
|
48
|
+
@logger.debug "Copy javascripts to #{js_path}"
|
49
|
+
FileUtils.cp "#{html_path}/jquery.min.js", js_path
|
50
|
+
FileUtils.cp "#{html_path}/bootstrap-collapse.js", js_path
|
51
|
+
FileUtils.cp "#{html_path}/Chart.min.js", js_path
|
52
|
+
end
|
34
53
|
|
35
|
-
private
|
36
|
-
def _copy_resources
|
37
|
-
html_path = File.expand_path('../../../html', __FILE__)
|
38
|
-
css_path = "#{ENV['ws.test.reports.path']}/css"
|
39
|
-
Dir.mkdir css_path unless File.exist? css_path
|
40
|
-
|
41
|
-
@logger.debug "Copy stylesheets to #{css_path}"
|
42
|
-
FileUtils.cp "#{html_path}/bootstrap.min.css", css_path
|
43
|
-
|
44
|
-
js_path = "#{ENV['ws.test.reports.path']}/js"
|
45
|
-
Dir.mkdir js_path unless File.exist? js_path
|
46
|
-
|
47
|
-
@logger.debug "Copy javascripts to #{js_path}"
|
48
|
-
FileUtils.cp "#{html_path}/jquery.min.js", js_path
|
49
|
-
FileUtils.cp "#{html_path}/bootstrap-collapse.js", js_path
|
50
|
-
FileUtils.cp "#{html_path}/Chart.min.js", js_path
|
51
54
|
end
|
52
|
-
|
53
|
-
end
|
54
55
|
|
56
|
+
end
|
55
57
|
end
|
data/lib/report/json.rb
CHANGED
@@ -1,19 +1,21 @@
|
|
1
|
-
module
|
1
|
+
module Theotokos
|
2
|
+
module Report
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
4
|
+
class Json < Reporter
|
5
|
+
|
6
|
+
def print(data)
|
7
|
+
Dir.mkdir 'tmp' unless File.exist? 'tmp'
|
8
|
+
Dir.mkdir ENV['ws.test.reports.path'] unless File.exist? ENV['ws.test.reports.path']
|
9
|
+
|
10
|
+
file = "#{ENV['ws.test.reports.path']}/report.json"
|
11
|
+
json = ((data.nil?) ? {} : data.to_hash.to_json)
|
12
|
+
File.open(file, 'w') {|file| file.write json }
|
13
|
+
|
14
|
+
puts " -- JSON report saved to #{file}" unless ENV['ENVIRONMENT'] == 'test'
|
15
|
+
file
|
16
|
+
end
|
17
|
+
|
15
18
|
end
|
16
|
-
|
17
|
-
end
|
18
19
|
|
20
|
+
end
|
19
21
|
end
|
data/lib/report/reporter.rb
CHANGED
@@ -1,76 +1,78 @@
|
|
1
|
-
module
|
1
|
+
module Theotokos
|
2
|
+
module Report
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
yield self if block_given?
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.create_reporter(report_type = :console)
|
10
|
-
case report_type.to_sym
|
11
|
-
when :console then Console.new
|
12
|
-
when :json then Json.new
|
13
|
-
when :html then Html.new
|
14
|
-
else nil
|
15
|
-
end
|
16
|
-
end
|
4
|
+
class Reporter
|
17
5
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
raise Exception, 'Not supported operation for ' + self.class.name
|
22
|
-
end
|
6
|
+
def initialize
|
7
|
+
yield self if block_given?
|
8
|
+
end
|
23
9
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
10
|
+
def self.create_reporter(report_type = :console)
|
11
|
+
case report_type.to_sym
|
12
|
+
when :console then Console.new
|
13
|
+
when :json then Json.new
|
14
|
+
when :html then Html.new
|
15
|
+
else nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_accessor :data, :locale
|
20
|
+
|
21
|
+
def print
|
22
|
+
raise Exception, 'Not supported operation for ' + self.class.name
|
23
|
+
end
|
28
24
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
@logger.warn "Loading default locale for 'en' idiom"
|
25
|
+
protected
|
26
|
+
def config_locale
|
27
|
+
@logger = AppLogger.create_logger self if @logger.nil?
|
28
|
+
@logger.info "Localizing report to '#{ENV['ws.test.reports.locale']}' idiom"
|
29
|
+
|
30
|
+
if ENV['ws.test.reports.locale'] == 'en'
|
36
31
|
_config_default_locale
|
37
32
|
else
|
38
|
-
|
33
|
+
locale_file = File.join(ENV['ws.test.reports.locales.path'], ENV['ws.test.reports.locale'])
|
34
|
+
unless File.exist? locale_file
|
35
|
+
@logger.warn "Locale configuration file '#{locale_file}' for lacale '#{ENV['ws.test.reports.locale']}' does not exist"
|
36
|
+
@logger.warn "Loading default locale for 'en' idiom"
|
37
|
+
_config_default_locale
|
38
|
+
else
|
39
|
+
@locale = YAML.load_file File.join(ENV['ws.test.reports.locales.path'], ENV['ws.test.reports.locale'])
|
40
|
+
end
|
39
41
|
end
|
42
|
+
|
43
|
+
@locale = Hash.new unless @locale.instance_of? Hash
|
44
|
+
_config_default_values
|
40
45
|
end
|
41
46
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
default_locale_file = File.join(ENV['ws.test.reports.locales.path'], 'en')
|
52
|
-
@locale = unless File.exist? default_locale_file
|
53
|
-
@logger.debug "Custom locale config file for 'en' does not exist"
|
54
|
-
@logger.debug "Loading defaul locale config file"
|
55
|
-
YAML.load_file File.expand_path('../default_locale', __FILE__)
|
56
|
-
else
|
57
|
-
begin
|
58
|
-
@logger.info "Loading custom locale file '#{default_locale_file}'"
|
59
|
-
YAML.load_file default_locale_file
|
60
|
-
rescue Exception => ex
|
61
|
-
@logger.error ex
|
62
|
-
@logger.warn "Loading defaul locale config file"
|
47
|
+
private
|
48
|
+
def _config_default_locale
|
49
|
+
@logger.debug 'Loading default locale: en'
|
50
|
+
@logger.debug 'Looking for custom locale config file for en'
|
51
|
+
|
52
|
+
default_locale_file = File.join(ENV['ws.test.reports.locales.path'], 'en')
|
53
|
+
@locale = unless File.exist? default_locale_file
|
54
|
+
@logger.debug "Custom locale config file for 'en' does not exist"
|
55
|
+
@logger.debug "Loading defaul locale config file"
|
63
56
|
YAML.load_file File.expand_path('../default_locale', __FILE__)
|
57
|
+
else
|
58
|
+
begin
|
59
|
+
@logger.info "Loading custom locale file '#{default_locale_file}'"
|
60
|
+
YAML.load_file default_locale_file
|
61
|
+
rescue Exception => ex
|
62
|
+
@logger.error ex
|
63
|
+
@logger.warn "Loading defaul locale config file"
|
64
|
+
YAML.load_file File.expand_path('../default_locale', __FILE__)
|
65
|
+
end
|
64
66
|
end
|
65
67
|
end
|
66
|
-
|
68
|
+
|
69
|
+
def _config_default_values
|
70
|
+
@locale['date.pattern'] ||= '%Y-%m-%d %l:%M:%S %p'
|
71
|
+
@locale['suite.data.expand'] ||= '+'
|
72
|
+
@locale['suite.data.collapse'] ||= '-'
|
73
|
+
end
|
67
74
|
|
68
|
-
def _config_default_values
|
69
|
-
@locale['date.pattern'] ||= '%Y-%m-%d %l:%M:%S %p'
|
70
|
-
@locale['suite.data.expand'] ||= '+'
|
71
|
-
@locale['suite.data.collapse'] ||= '-'
|
72
75
|
end
|
73
|
-
|
74
|
-
end
|
75
76
|
|
77
|
+
end
|
76
78
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: theotokos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2014-07-15 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: logging
|
16
|
-
requirement: &
|
16
|
+
requirement: &87205620 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.8.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *87205620
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: savon
|
27
|
-
requirement: &
|
27
|
+
requirement: &87204830 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - =
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.5.1
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *87204830
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: equivalent-xml
|
38
|
-
requirement: &
|
38
|
+
requirement: &87204360 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 0.4.2
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *87204360
|
47
47
|
description: A gem for web service testing. Allows easily create test suites using
|
48
48
|
YAML as test model.
|
49
49
|
email: aureliano.franca@hotmail.com
|
@@ -134,7 +134,7 @@ rubyforge_project:
|
|
134
134
|
rubygems_version: 1.8.15
|
135
135
|
signing_key:
|
136
136
|
specification_version: 3
|
137
|
-
summary: theotokos-0.1.
|
137
|
+
summary: theotokos-0.1.2 Tool to easily test web services.
|
138
138
|
test_files:
|
139
139
|
- test/app-cfg.yml
|
140
140
|
- test/config/ws-config.yml
|