soaspec 0.2.32 → 0.2.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +15 -15
- data/.gitlab-ci.yml +62 -62
- data/.rspec +3 -3
- data/.rubocop.yml +2 -2
- data/CODE_OF_CONDUCT.md +74 -74
- data/ChangeLog +632 -625
- data/Dockerfile +7 -7
- data/Gemfile +8 -8
- data/LICENSE.txt +21 -21
- data/README.md +231 -231
- data/Rakefile +52 -52
- data/Todo.md +16 -16
- data/exe/soaspec +138 -138
- data/exe/xml_to_yaml_file +43 -43
- data/lib/soaspec.rb +106 -105
- data/lib/soaspec/baseline.rb +23 -0
- data/lib/soaspec/core_ext/hash.rb +44 -44
- data/lib/soaspec/cucumber/generic_steps.rb +94 -94
- data/lib/soaspec/demo.rb +6 -6
- data/lib/soaspec/errors.rb +24 -22
- data/lib/soaspec/exchange/exchange.rb +129 -129
- data/lib/soaspec/exchange/exchange_extractor.rb +90 -90
- data/lib/soaspec/exchange/exchange_properties.rb +28 -28
- data/lib/soaspec/exchange/exchange_repeater.rb +21 -21
- data/lib/soaspec/exchange/request_builder.rb +70 -70
- data/lib/soaspec/exchange/variable_storer.rb +24 -24
- data/lib/soaspec/exchange_handlers/exchange_handler.rb +98 -98
- data/lib/soaspec/exchange_handlers/exchange_handler_defaults.rb +61 -61
- data/lib/soaspec/exchange_handlers/handler_accessors.rb +132 -132
- data/lib/soaspec/exchange_handlers/request/rest_request.rb +59 -51
- data/lib/soaspec/exchange_handlers/request/soap_request.rb +41 -41
- data/lib/soaspec/exchange_handlers/response_extractor.rb +84 -84
- data/lib/soaspec/exchange_handlers/rest_exchanger_factory.rb +111 -111
- data/lib/soaspec/exchange_handlers/rest_handler.rb +307 -298
- data/lib/soaspec/exchange_handlers/rest_methods.rb +65 -65
- data/lib/soaspec/exchange_handlers/rest_parameters.rb +112 -112
- data/lib/soaspec/exchange_handlers/rest_parameters_defaults.rb +42 -42
- data/lib/soaspec/exchange_handlers/soap_handler.rb +241 -241
- data/lib/soaspec/exe_helpers.rb +94 -94
- data/lib/soaspec/generate_server.rb +48 -48
- data/lib/soaspec/generator/.rspec.erb +5 -5
- data/lib/soaspec/generator/.travis.yml.erb +5 -5
- data/lib/soaspec/generator/Gemfile.erb +8 -8
- data/lib/soaspec/generator/README.md.erb +29 -29
- data/lib/soaspec/generator/Rakefile.erb +19 -19
- data/lib/soaspec/generator/config/data/default.yml.erb +2 -2
- data/lib/soaspec/generator/css/bootstrap.css +6833 -6833
- data/lib/soaspec/generator/features/support/env.rb.erb +3 -3
- data/lib/soaspec/generator/generate_exchange.html.erb +47 -47
- data/lib/soaspec/generator/lib/blz_service.rb.erb +26 -26
- data/lib/soaspec/generator/lib/dynamic_class_content.rb.erb +12 -12
- data/lib/soaspec/generator/lib/new_rest_service.rb.erb +56 -56
- data/lib/soaspec/generator/lib/new_soap_service.rb.erb +29 -29
- data/lib/soaspec/generator/lib/package_service.rb.erb +2 -2
- data/lib/soaspec/generator/lib/shared_example.rb.erb +8 -8
- data/lib/soaspec/generator/spec/dynamic_soap_spec.rb.erb +12 -12
- data/lib/soaspec/generator/spec/rest_spec.rb.erb +9 -9
- data/lib/soaspec/generator/spec/soap_spec.rb.erb +51 -51
- data/lib/soaspec/generator/spec/spec_helper.rb.erb +23 -23
- data/lib/soaspec/generator/template/soap_template.xml +6 -6
- data/lib/soaspec/indifferent_hash.rb +9 -9
- data/lib/soaspec/interpreter.rb +70 -70
- data/lib/soaspec/matchers.rb +140 -118
- data/lib/soaspec/o_auth2.rb +142 -142
- data/lib/soaspec/soaspec_shared_examples.rb +26 -26
- data/lib/soaspec/spec_logger.rb +143 -143
- data/lib/soaspec/template_reader.rb +30 -30
- data/lib/soaspec/test_server/bank.wsdl +90 -90
- data/lib/soaspec/test_server/get_bank.rb +166 -166
- data/lib/soaspec/test_server/id_manager.rb +41 -41
- data/lib/soaspec/test_server/invoices.rb +29 -29
- data/lib/soaspec/test_server/namespace.xml +14 -14
- data/lib/soaspec/test_server/note.xml +5 -5
- data/lib/soaspec/test_server/puppy_service.rb +21 -21
- data/lib/soaspec/test_server/test_attribute.rb +14 -14
- data/lib/soaspec/test_server/test_namespace.rb +14 -14
- data/lib/soaspec/version.rb +6 -6
- data/lib/soaspec/virtual_server.rb +190 -176
- data/lib/soaspec/wait.rb +43 -43
- data/lib/soaspec/wsdl_generator.rb +215 -215
- data/soaspec.gemspec +58 -58
- data/test.wsdl +116 -116
- data/test.xml +10 -10
- data/test_wsdl.rb +43 -43
- metadata +4 -3
data/Rakefile
CHANGED
@@ -1,52 +1,52 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'bundler/gem_tasks'
|
4
|
-
require 'rspec/core/rake_task'
|
5
|
-
require 'rake/clean'
|
6
|
-
require 'yard'
|
7
|
-
require 'yard/doctest/rake'
|
8
|
-
|
9
|
-
ENV['folder'] ||= ''
|
10
|
-
ENV['test'] ||= ''
|
11
|
-
|
12
|
-
desc 'Run tests'
|
13
|
-
RSpec::Core::RakeTask.new(spec: %i[clean clobber start_test_server]) do |t|
|
14
|
-
t.pattern = "spec/**/#{ENV['folder']}*/#{ENV['test']}*_spec.rb"
|
15
|
-
end
|
16
|
-
|
17
|
-
task parallel: %i[clean clobber start_test_server] do
|
18
|
-
puts `parallel_rspec spec`
|
19
|
-
end
|
20
|
-
|
21
|
-
task default: :spec
|
22
|
-
|
23
|
-
CLEAN.include 'tmp/*'
|
24
|
-
CLOBBER.include 'logs/*'
|
25
|
-
|
26
|
-
desc 'Start virtual web service'
|
27
|
-
task :start_test_server do
|
28
|
-
ENV['leave_server_running'] = 'true' # This will stop created suites from killing this service
|
29
|
-
mkdir_p 'logs'
|
30
|
-
ENV['test_server_pid'] = Process.spawn('ruby', 'exe/soaspec', 'virtual_server', err: %w[logs/test_server.log w]).to_s
|
31
|
-
sleep 2 # Wait a little for virtual server to start up
|
32
|
-
puts 'Running test server at pid ' + ENV['test_server_pid']
|
33
|
-
end
|
34
|
-
|
35
|
-
YARD::Rake::YardocTask.new do |t|
|
36
|
-
t.files = %w[features/**/*.feature features/**/*.rb lib/soaspec/cucumber/*.rb] # lib/soaspec/cucumber/*.rb]
|
37
|
-
end
|
38
|
-
|
39
|
-
desc 'Ensure system has all docs'
|
40
|
-
task :must_have_docs do
|
41
|
-
yard = `yard`
|
42
|
-
puts yard
|
43
|
-
percentage = yard.lines.last.strip.split('%').first.to_f
|
44
|
-
raise 'Must be fully documented' unless percentage == 100.00
|
45
|
-
end
|
46
|
-
|
47
|
-
desc 'Test examples shown in documentation'
|
48
|
-
YARD::Doctest::RakeTask.new do |task|
|
49
|
-
task.doctest_opts = %w[-v]
|
50
|
-
# task.pattern = 'lib/**/*.rb'
|
51
|
-
task.pattern = 'lib/soaspec/core_ext/hash.rb'
|
52
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'rake/clean'
|
6
|
+
require 'yard'
|
7
|
+
require 'yard/doctest/rake'
|
8
|
+
|
9
|
+
ENV['folder'] ||= ''
|
10
|
+
ENV['test'] ||= ''
|
11
|
+
|
12
|
+
desc 'Run tests'
|
13
|
+
RSpec::Core::RakeTask.new(spec: %i[clean clobber start_test_server]) do |t|
|
14
|
+
t.pattern = "spec/**/#{ENV['folder']}*/#{ENV['test']}*_spec.rb"
|
15
|
+
end
|
16
|
+
|
17
|
+
task parallel: %i[clean clobber start_test_server] do
|
18
|
+
puts `parallel_rspec spec`
|
19
|
+
end
|
20
|
+
|
21
|
+
task default: :spec
|
22
|
+
|
23
|
+
CLEAN.include 'tmp/*'
|
24
|
+
CLOBBER.include 'logs/*'
|
25
|
+
|
26
|
+
desc 'Start virtual web service'
|
27
|
+
task :start_test_server do
|
28
|
+
ENV['leave_server_running'] = 'true' # This will stop created suites from killing this service
|
29
|
+
mkdir_p 'logs'
|
30
|
+
ENV['test_server_pid'] = Process.spawn('ruby', 'exe/soaspec', 'virtual_server', err: %w[logs/test_server.log w]).to_s
|
31
|
+
sleep 2 # Wait a little for virtual server to start up
|
32
|
+
puts 'Running test server at pid ' + ENV['test_server_pid']
|
33
|
+
end
|
34
|
+
|
35
|
+
YARD::Rake::YardocTask.new do |t|
|
36
|
+
t.files = %w[features/**/*.feature features/**/*.rb lib/soaspec/cucumber/*.rb] # lib/soaspec/cucumber/*.rb]
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'Ensure system has all docs'
|
40
|
+
task :must_have_docs do
|
41
|
+
yard = `yard`
|
42
|
+
puts yard
|
43
|
+
percentage = yard.lines.last.strip.split('%').first.to_f
|
44
|
+
raise 'Must be fully documented' unless percentage == 100.00
|
45
|
+
end
|
46
|
+
|
47
|
+
desc 'Test examples shown in documentation'
|
48
|
+
YARD::Doctest::RakeTask.new do |task|
|
49
|
+
task.doctest_opts = %w[-v]
|
50
|
+
# task.pattern = 'lib/**/*.rb'
|
51
|
+
task.pattern = 'lib/soaspec/core_ext/hash.rb'
|
52
|
+
end
|
data/Todo.md
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
* Exception in setting a value results in 'headers' being called on Nil Class
|
2
|
-
* `yard` should show everything documented
|
3
|
-
* Rubocop should have 0 offenses
|
4
|
-
* Unit tests
|
5
|
-
* OAuth class, etc
|
6
|
-
* Get initial `soaspec new` working with TODOs as placeholders for how to get started
|
7
|
-
* Request method from within exchange
|
8
|
-
* Use this in tests
|
9
|
-
* Basic service generator
|
10
|
-
* Give examples and convenience methods for building classes for each SOAP or REST operation
|
11
|
-
* Potentially have in built use of 'vcr' and 'http_stub' gems
|
12
|
-
* Handle proxies to record traffic for MiddleWare testing
|
13
|
-
* soaspec generate
|
14
|
-
* Get wsdl generator working for non complex gems (Put on hold til new Savon version)
|
15
|
-
* Generate from a RAML
|
16
|
-
* Much more - please raise an issue for suggestion
|
1
|
+
* Exception in setting a value results in 'headers' being called on Nil Class
|
2
|
+
* `yard` should show everything documented
|
3
|
+
* Rubocop should have 0 offenses
|
4
|
+
* Unit tests
|
5
|
+
* OAuth class, etc
|
6
|
+
* Get initial `soaspec new` working with TODOs as placeholders for how to get started
|
7
|
+
* Request method from within exchange
|
8
|
+
* Use this in tests
|
9
|
+
* Basic service generator
|
10
|
+
* Give examples and convenience methods for building classes for each SOAP or REST operation
|
11
|
+
* Potentially have in built use of 'vcr' and 'http_stub' gems
|
12
|
+
* Handle proxies to record traffic for MiddleWare testing
|
13
|
+
* soaspec generate
|
14
|
+
* Get wsdl generator working for non complex gems (Put on hold til new Savon version)
|
15
|
+
* Generate from a RAML
|
16
|
+
* Much more - please raise an issue for suggestion
|
data/exe/soaspec
CHANGED
@@ -1,138 +1,138 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'thor'
|
5
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
6
|
-
require 'savon'
|
7
|
-
require 'soaspec'
|
8
|
-
require 'soaspec/virtual_server'
|
9
|
-
require 'soaspec/wsdl_generator'
|
10
|
-
|
11
|
-
module Soaspec
|
12
|
-
# Common executable for Soaspec
|
13
|
-
class Exe < Thor
|
14
|
-
include Soaspec::ExeHelpers
|
15
|
-
include Soaspec::WsdlGenerator
|
16
|
-
|
17
|
-
long_desc <<-LONGDESC
|
18
|
-
`soaspec new` will generate the initial files and folders for starting a testing project using soaspec
|
19
|
-
\x5
|
20
|
-
|
21
|
-
`soaspec new soap` will create example files testing against a SOAP service
|
22
|
-
\x5
|
23
|
-
|
24
|
-
`soaspec new rest` will create example files testing against a REST service
|
25
|
-
LONGDESC
|
26
|
-
desc 'new [type]', 'Initialize soaspec repository'
|
27
|
-
option :ci, default: 'jenkins', banner: 'What Continuous Integration is used'
|
28
|
-
option :virtual, type: :boolean, default: true, banner: 'Whether to set things up for a virtual server'
|
29
|
-
def new(type = 'initial')
|
30
|
-
@virtual = options[:virtual]
|
31
|
-
@type = type
|
32
|
-
puts "Creating files for soaspec. options are #{options}"
|
33
|
-
create_file(filename: 'Gemfile')
|
34
|
-
create_file(filename: 'Rakefile')
|
35
|
-
create_file(filename: '.rspec')
|
36
|
-
create_file(filename: 'README.md')
|
37
|
-
create_file(filename: '.travis.yml') if options[:ci] == 'travis'
|
38
|
-
create_folder 'lib'
|
39
|
-
create_files_for type
|
40
|
-
create_file(filename: 'config/data/default.yml') # Example of data file
|
41
|
-
create_file(filename: 'spec/spec_helper.rb')
|
42
|
-
puts "Run 'bundle install' to install necessary gems"
|
43
|
-
puts "Run 'rake spec' to run the tests"
|
44
|
-
end
|
45
|
-
|
46
|
-
long_desc <<-LONGDESC
|
47
|
-
`soaspec add rest` will generate the initial files and folders for starting a testing project using soaspec
|
48
|
-
\x5
|
49
|
-
|
50
|
-
`soaspec add soap` will create example files testing against a virtual SOAP service
|
51
|
-
\x5
|
52
|
-
|
53
|
-
LONGDESC
|
54
|
-
desc 'add [type] [name]', 'Add new ExchangeHandler'
|
55
|
-
def add(type = 'rest', name = 'TestService')
|
56
|
-
raise "Type '#{type}' is not available" unless %w[rest soap].include? type
|
57
|
-
|
58
|
-
@name = name # Use instance variable for ERB
|
59
|
-
create_file filename: File.join('lib', "#{name.snakecase}.rb"),
|
60
|
-
content: retrieve_contents(File.join('lib', "new_#{type}_service.rb"))
|
61
|
-
end
|
62
|
-
|
63
|
-
long_desc <<-LONGDESC
|
64
|
-
`soaspec cucumber` will add generic steps file within step definitions folder. It will also
|
65
|
-
add Gemfile, and other Cucumber setup files if not already added
|
66
|
-
\x5
|
67
|
-
|
68
|
-
LONGDESC
|
69
|
-
desc 'cucumber', 'Add cucumber generic steps template within step_definitions folder'
|
70
|
-
def cucumber
|
71
|
-
@cucumber = true
|
72
|
-
create_file(filename: 'Gemfile', ignore_if_present: true)
|
73
|
-
create_file(filename: 'features/support/env.rb', ignore_if_present: true)
|
74
|
-
create_file filename: File.join('features', 'step_definitions', 'generic_steps.rb'),
|
75
|
-
content: retrieve_contents(File.join('../cucumber', 'generic_steps.rb'), false)
|
76
|
-
end
|
77
|
-
|
78
|
-
desc 'generate', 'Generate initial test code from wsdl'
|
79
|
-
long_desc <<-LONGDESC
|
80
|
-
If no wsdl is given a server will be started from which code to generate Exchanges
|
81
|
-
|
82
|
-
`soaspec generate wsdl=wsdl name=ServiceName ` will generate the initial files and folders to test each operation in a wsdl
|
83
|
-
\x5
|
84
|
-
Additionally the auth parameter can be used to use basic authentication to retrieve the WSDL.
|
85
|
-
To do use the following `soaspec generate --auth=basic`
|
86
|
-
Note: This is still a work in progress and will only work for a very simple wsdl
|
87
|
-
LONGDESC
|
88
|
-
option :wsdl, default: nil, aliases: :w
|
89
|
-
option :name, default: 'Service', aliases: :n
|
90
|
-
option :ci, default: 'jenkins', banner: 'What Continuous Integration is used'
|
91
|
-
option :auth
|
92
|
-
option :open_browser, default: 'true'
|
93
|
-
option :string_default, default: 'test string'
|
94
|
-
option :port, default: nil, banner: 'What port to run generate server. Default is random'
|
95
|
-
def generate
|
96
|
-
if options[:wsdl]
|
97
|
-
generate_from_wsdl(options)
|
98
|
-
else
|
99
|
-
require 'launchy'
|
100
|
-
require 'soaspec/generate_server'
|
101
|
-
require 'random-port'
|
102
|
-
port = options[:port] || RandomPort::Pool.new.acquire.to_s
|
103
|
-
puts "Using random port '#{port}' for hosting generate server"
|
104
|
-
|
105
|
-
Soaspec::GenerateServer.run!(port: port) do
|
106
|
-
Launchy.open "http://localhost:#{port}" if options[:open_browser] == 'true'
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
long_desc <<-LONGDESC
|
112
|
-
Run virtual web services on localhost. See root for documentation of web services provided.
|
113
|
-
LONGDESC
|
114
|
-
desc 'virtual_server [port]', 'Run virtual web service on localhost'
|
115
|
-
def virtual_server(port = '4999')
|
116
|
-
ENV['port'] = port
|
117
|
-
require 'soaspec/virtual_server'
|
118
|
-
Soaspec::VirtualServer.run!(port: port)
|
119
|
-
end
|
120
|
-
|
121
|
-
long_desc <<-LONGDESC
|
122
|
-
Run pry with Soaspec and other relevant libraries loaded. Pass either the relative path to files desired with a
|
123
|
-
'.rb' extension or the path to the folder to be loaded with 'require_all'
|
124
|
-
LONGDESC
|
125
|
-
desc 'pry [required_files]', 'Run pry with Soaspec and other relevant libraries loaded'
|
126
|
-
def pry(required_files = nil)
|
127
|
-
require 'soaspec'
|
128
|
-
|
129
|
-
require 'require_all'
|
130
|
-
require_all required_files if required_files
|
131
|
-
|
132
|
-
require 'pry'
|
133
|
-
Pry.start
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
Soaspec::Exe.start(ARGV)
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'thor'
|
5
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
6
|
+
require 'savon'
|
7
|
+
require 'soaspec'
|
8
|
+
require 'soaspec/virtual_server'
|
9
|
+
require 'soaspec/wsdl_generator'
|
10
|
+
|
11
|
+
module Soaspec
|
12
|
+
# Common executable for Soaspec
|
13
|
+
class Exe < Thor
|
14
|
+
include Soaspec::ExeHelpers
|
15
|
+
include Soaspec::WsdlGenerator
|
16
|
+
|
17
|
+
long_desc <<-LONGDESC
|
18
|
+
`soaspec new` will generate the initial files and folders for starting a testing project using soaspec
|
19
|
+
\x5
|
20
|
+
|
21
|
+
`soaspec new soap` will create example files testing against a SOAP service
|
22
|
+
\x5
|
23
|
+
|
24
|
+
`soaspec new rest` will create example files testing against a REST service
|
25
|
+
LONGDESC
|
26
|
+
desc 'new [type]', 'Initialize soaspec repository'
|
27
|
+
option :ci, default: 'jenkins', banner: 'What Continuous Integration is used'
|
28
|
+
option :virtual, type: :boolean, default: true, banner: 'Whether to set things up for a virtual server'
|
29
|
+
def new(type = 'initial')
|
30
|
+
@virtual = options[:virtual]
|
31
|
+
@type = type
|
32
|
+
puts "Creating files for soaspec. options are #{options}"
|
33
|
+
create_file(filename: 'Gemfile')
|
34
|
+
create_file(filename: 'Rakefile')
|
35
|
+
create_file(filename: '.rspec')
|
36
|
+
create_file(filename: 'README.md')
|
37
|
+
create_file(filename: '.travis.yml') if options[:ci] == 'travis'
|
38
|
+
create_folder 'lib'
|
39
|
+
create_files_for type
|
40
|
+
create_file(filename: 'config/data/default.yml') # Example of data file
|
41
|
+
create_file(filename: 'spec/spec_helper.rb')
|
42
|
+
puts "Run 'bundle install' to install necessary gems"
|
43
|
+
puts "Run 'rake spec' to run the tests"
|
44
|
+
end
|
45
|
+
|
46
|
+
long_desc <<-LONGDESC
|
47
|
+
`soaspec add rest` will generate the initial files and folders for starting a testing project using soaspec
|
48
|
+
\x5
|
49
|
+
|
50
|
+
`soaspec add soap` will create example files testing against a virtual SOAP service
|
51
|
+
\x5
|
52
|
+
|
53
|
+
LONGDESC
|
54
|
+
desc 'add [type] [name]', 'Add new ExchangeHandler'
|
55
|
+
def add(type = 'rest', name = 'TestService')
|
56
|
+
raise "Type '#{type}' is not available" unless %w[rest soap].include? type
|
57
|
+
|
58
|
+
@name = name # Use instance variable for ERB
|
59
|
+
create_file filename: File.join('lib', "#{name.snakecase}.rb"),
|
60
|
+
content: retrieve_contents(File.join('lib', "new_#{type}_service.rb"))
|
61
|
+
end
|
62
|
+
|
63
|
+
long_desc <<-LONGDESC
|
64
|
+
`soaspec cucumber` will add generic steps file within step definitions folder. It will also
|
65
|
+
add Gemfile, and other Cucumber setup files if not already added
|
66
|
+
\x5
|
67
|
+
|
68
|
+
LONGDESC
|
69
|
+
desc 'cucumber', 'Add cucumber generic steps template within step_definitions folder'
|
70
|
+
def cucumber
|
71
|
+
@cucumber = true
|
72
|
+
create_file(filename: 'Gemfile', ignore_if_present: true)
|
73
|
+
create_file(filename: 'features/support/env.rb', ignore_if_present: true)
|
74
|
+
create_file filename: File.join('features', 'step_definitions', 'generic_steps.rb'),
|
75
|
+
content: retrieve_contents(File.join('../cucumber', 'generic_steps.rb'), false)
|
76
|
+
end
|
77
|
+
|
78
|
+
desc 'generate', 'Generate initial test code from wsdl'
|
79
|
+
long_desc <<-LONGDESC
|
80
|
+
If no wsdl is given a server will be started from which code to generate Exchanges
|
81
|
+
|
82
|
+
`soaspec generate wsdl=wsdl name=ServiceName ` will generate the initial files and folders to test each operation in a wsdl
|
83
|
+
\x5
|
84
|
+
Additionally the auth parameter can be used to use basic authentication to retrieve the WSDL.
|
85
|
+
To do use the following `soaspec generate --auth=basic`
|
86
|
+
Note: This is still a work in progress and will only work for a very simple wsdl
|
87
|
+
LONGDESC
|
88
|
+
option :wsdl, default: nil, aliases: :w
|
89
|
+
option :name, default: 'Service', aliases: :n
|
90
|
+
option :ci, default: 'jenkins', banner: 'What Continuous Integration is used'
|
91
|
+
option :auth
|
92
|
+
option :open_browser, default: 'true'
|
93
|
+
option :string_default, default: 'test string'
|
94
|
+
option :port, default: nil, banner: 'What port to run generate server. Default is random'
|
95
|
+
def generate
|
96
|
+
if options[:wsdl]
|
97
|
+
generate_from_wsdl(options)
|
98
|
+
else
|
99
|
+
require 'launchy'
|
100
|
+
require 'soaspec/generate_server'
|
101
|
+
require 'random-port'
|
102
|
+
port = options[:port] || RandomPort::Pool.new.acquire.to_s
|
103
|
+
puts "Using random port '#{port}' for hosting generate server"
|
104
|
+
|
105
|
+
Soaspec::GenerateServer.run!(port: port) do
|
106
|
+
Launchy.open "http://localhost:#{port}" if options[:open_browser] == 'true'
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
long_desc <<-LONGDESC
|
112
|
+
Run virtual web services on localhost. See root for documentation of web services provided.
|
113
|
+
LONGDESC
|
114
|
+
desc 'virtual_server [port]', 'Run virtual web service on localhost'
|
115
|
+
def virtual_server(port = '4999')
|
116
|
+
ENV['port'] = port
|
117
|
+
require 'soaspec/virtual_server'
|
118
|
+
Soaspec::VirtualServer.run!(port: port)
|
119
|
+
end
|
120
|
+
|
121
|
+
long_desc <<-LONGDESC
|
122
|
+
Run pry with Soaspec and other relevant libraries loaded. Pass either the relative path to files desired with a
|
123
|
+
'.rb' extension or the path to the folder to be loaded with 'require_all'
|
124
|
+
LONGDESC
|
125
|
+
desc 'pry [required_files]', 'Run pry with Soaspec and other relevant libraries loaded'
|
126
|
+
def pry(required_files = nil)
|
127
|
+
require 'soaspec'
|
128
|
+
|
129
|
+
require 'require_all'
|
130
|
+
require_all required_files if required_files
|
131
|
+
|
132
|
+
require 'pry'
|
133
|
+
Pry.start
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
Soaspec::Exe.start(ARGV)
|
data/exe/xml_to_yaml_file
CHANGED
@@ -1,43 +1,43 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'xmlsimple'
|
5
|
-
require 'yaml'
|
6
|
-
require 'fileutils'
|
7
|
-
|
8
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
9
|
-
|
10
|
-
require 'soaspec'
|
11
|
-
|
12
|
-
include Soaspec::ExeHelpers
|
13
|
-
|
14
|
-
default_output_file = 'output.yml'
|
15
|
-
|
16
|
-
# For all keys in a Hash, convert Camelcase to underscore separated
|
17
|
-
def convert_hash_keys(value)
|
18
|
-
case value
|
19
|
-
when Array
|
20
|
-
value.map { |v| convert_hash_keys(v) }
|
21
|
-
when Hash
|
22
|
-
Hash[value.map { |k, v| [k.snakecase, convert_hash_keys(v)] }]
|
23
|
-
else
|
24
|
-
value
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# Remove arrays created as another string
|
29
|
-
def clean_up_yaml(yaml_string)
|
30
|
-
yaml_string = yaml_string.gsub(/\R+(\s*)-/, '').gsub(/{}/, "''") # Remove arrays, {} -> ''
|
31
|
-
# Insert new line where there are 2 ':' on 1 line. Issue from first gsub
|
32
|
-
yaml_string.gsub(/:(\s)(\w*):/) { |s| s.insert(1, "\n") }
|
33
|
-
end
|
34
|
-
|
35
|
-
if ARGV[0]
|
36
|
-
warn "Using '#{default_output_file}' as default output file since no 2nd argument passed" unless ARGV[1]
|
37
|
-
hash = XmlSimple.xml_in(ARGV[0])
|
38
|
-
converted = convert_hash_keys hash
|
39
|
-
yaml_file = clean_up_yaml(converted.to_yaml)
|
40
|
-
create_file(filename: ARGV[1] || default_output_file, content: yaml_file)
|
41
|
-
else
|
42
|
-
puts 'usage: xml_to_yaml_file [input.xml] [output.yml] '
|
43
|
-
end
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'xmlsimple'
|
5
|
+
require 'yaml'
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
9
|
+
|
10
|
+
require 'soaspec'
|
11
|
+
|
12
|
+
include Soaspec::ExeHelpers
|
13
|
+
|
14
|
+
default_output_file = 'output.yml'
|
15
|
+
|
16
|
+
# For all keys in a Hash, convert Camelcase to underscore separated
|
17
|
+
def convert_hash_keys(value)
|
18
|
+
case value
|
19
|
+
when Array
|
20
|
+
value.map { |v| convert_hash_keys(v) }
|
21
|
+
when Hash
|
22
|
+
Hash[value.map { |k, v| [k.snakecase, convert_hash_keys(v)] }]
|
23
|
+
else
|
24
|
+
value
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Remove arrays created as another string
|
29
|
+
def clean_up_yaml(yaml_string)
|
30
|
+
yaml_string = yaml_string.gsub(/\R+(\s*)-/, '').gsub(/{}/, "''") # Remove arrays, {} -> ''
|
31
|
+
# Insert new line where there are 2 ':' on 1 line. Issue from first gsub
|
32
|
+
yaml_string.gsub(/:(\s)(\w*):/) { |s| s.insert(1, "\n") }
|
33
|
+
end
|
34
|
+
|
35
|
+
if ARGV[0]
|
36
|
+
warn "Using '#{default_output_file}' as default output file since no 2nd argument passed" unless ARGV[1]
|
37
|
+
hash = XmlSimple.xml_in(ARGV[0])
|
38
|
+
converted = convert_hash_keys hash
|
39
|
+
yaml_file = clean_up_yaml(converted.to_yaml)
|
40
|
+
create_file(filename: ARGV[1] || default_output_file, content: yaml_file)
|
41
|
+
else
|
42
|
+
puts 'usage: xml_to_yaml_file [input.xml] [output.yml] '
|
43
|
+
end
|