soaspec 0.2.23 → 0.2.24

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 (80) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +15 -15
  3. data/.gitlab-ci.yml +33 -33
  4. data/.rspec +3 -3
  5. data/.rubocop.yml +2 -2
  6. data/CODE_OF_CONDUCT.md +74 -74
  7. data/ChangeLog +577 -573
  8. data/Gemfile +6 -6
  9. data/LICENSE.txt +21 -21
  10. data/README.md +230 -230
  11. data/Rakefile +42 -42
  12. data/Todo.md +15 -15
  13. data/exe/soaspec +123 -123
  14. data/exe/xml_to_yaml_file +42 -42
  15. data/lib/soaspec.rb +101 -101
  16. data/lib/soaspec/core_ext/hash.rb +35 -35
  17. data/lib/soaspec/cucumber/generic_steps.rb +85 -85
  18. data/lib/soaspec/demo.rb +4 -4
  19. data/lib/soaspec/exchange/exchange.rb +111 -111
  20. data/lib/soaspec/exchange/exchange_extractor.rb +83 -83
  21. data/lib/soaspec/exchange/exchange_properties.rb +26 -26
  22. data/lib/soaspec/exchange/exchange_repeater.rb +19 -19
  23. data/lib/soaspec/exchange/request_builder.rb +68 -68
  24. data/lib/soaspec/exchange/variable_storer.rb +22 -22
  25. data/lib/soaspec/exchange_handlers/exchange_handler.rb +126 -126
  26. data/lib/soaspec/exchange_handlers/handler_accessors.rb +130 -130
  27. data/lib/soaspec/exchange_handlers/response_extractor.rb +82 -82
  28. data/lib/soaspec/exchange_handlers/rest_exchanger_factory.rb +109 -109
  29. data/lib/soaspec/exchange_handlers/rest_handler.rb +259 -259
  30. data/lib/soaspec/exchange_handlers/rest_methods.rb +44 -44
  31. data/lib/soaspec/exchange_handlers/rest_parameters.rb +86 -86
  32. data/lib/soaspec/exchange_handlers/rest_parameters_defaults.rb +21 -21
  33. data/lib/soaspec/exchange_handlers/soap_handler.rb +235 -235
  34. data/lib/soaspec/exe_helpers.rb +92 -92
  35. data/lib/soaspec/generate_server.rb +37 -37
  36. data/lib/soaspec/generator/.rspec.erb +5 -5
  37. data/lib/soaspec/generator/.travis.yml.erb +5 -5
  38. data/lib/soaspec/generator/Gemfile.erb +8 -8
  39. data/lib/soaspec/generator/README.md.erb +29 -29
  40. data/lib/soaspec/generator/Rakefile.erb +19 -19
  41. data/lib/soaspec/generator/config/data/default.yml.erb +2 -2
  42. data/lib/soaspec/generator/css/bootstrap.css +6833 -6833
  43. data/lib/soaspec/generator/generate_exchange.html.erb +35 -35
  44. data/lib/soaspec/generator/lib/blz_service.rb.erb +26 -26
  45. data/lib/soaspec/generator/lib/dynamic_class_content.rb.erb +12 -12
  46. data/lib/soaspec/generator/lib/new_rest_service.rb.erb +51 -51
  47. data/lib/soaspec/generator/lib/new_soap_service.rb.erb +29 -29
  48. data/lib/soaspec/generator/lib/package_service.rb.erb +2 -2
  49. data/lib/soaspec/generator/lib/shared_example.rb.erb +8 -8
  50. data/lib/soaspec/generator/spec/dynamic_soap_spec.rb.erb +12 -12
  51. data/lib/soaspec/generator/spec/rest_spec.rb.erb +9 -9
  52. data/lib/soaspec/generator/spec/soap_spec.rb.erb +51 -51
  53. data/lib/soaspec/generator/spec/spec_helper.rb.erb +23 -23
  54. data/lib/soaspec/generator/template/soap_template.xml +6 -6
  55. data/lib/soaspec/indifferent_hash.rb +7 -7
  56. data/lib/soaspec/interpreter.rb +39 -39
  57. data/lib/soaspec/matchers.rb +114 -114
  58. data/lib/soaspec/not_found_errors.rb +13 -13
  59. data/lib/soaspec/o_auth2.rb +128 -128
  60. data/lib/soaspec/soaspec_shared_examples.rb +24 -24
  61. data/lib/soaspec/spec_logger.rb +121 -121
  62. data/lib/soaspec/template_reader.rb +28 -28
  63. data/lib/soaspec/test_server/bank.wsdl +90 -90
  64. data/lib/soaspec/test_server/get_bank.rb +164 -164
  65. data/lib/soaspec/test_server/id_manager.rb +39 -39
  66. data/lib/soaspec/test_server/invoices.rb +27 -27
  67. data/lib/soaspec/test_server/namespace.xml +14 -14
  68. data/lib/soaspec/test_server/note.xml +5 -5
  69. data/lib/soaspec/test_server/puppy_service.rb +19 -19
  70. data/lib/soaspec/test_server/test_attribute.rb +12 -12
  71. data/lib/soaspec/test_server/test_namespace.rb +12 -12
  72. data/lib/soaspec/version.rb +4 -3
  73. data/lib/soaspec/virtual_server.rb +174 -174
  74. data/lib/soaspec/wait.rb +41 -41
  75. data/lib/soaspec/wsdl_generator.rb +215 -215
  76. data/soaspec.gemspec +53 -53
  77. data/test.wsdl +116 -116
  78. data/test.xml +10 -10
  79. data/test_wsdl.rb +41 -41
  80. metadata +3 -4
data/Rakefile CHANGED
@@ -1,42 +1,42 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
- require 'rake/clean'
4
- require 'yard'
5
-
6
- ENV['folder'] ||= ''
7
- ENV['test'] ||= ''
8
-
9
- desc 'Run tests'
10
- RSpec::Core::RakeTask.new(spec: %i[clean clobber start_test_server]) do |t|
11
- t.pattern = "spec/**/#{ENV['folder']}*/#{ENV['test']}*_spec.rb"
12
- end
13
-
14
- task :parallel => [:clean, :clobber, :start_test_server] do
15
- puts `parallel_rspec spec`
16
- end
17
-
18
- task default: :spec
19
-
20
- CLEAN.include 'tmp/*'
21
- CLOBBER.include 'logs/*'
22
-
23
- desc 'Start virtual web service'
24
- task :start_test_server do
25
- ENV['leave_server_running'] = 'true' # This will stop created suites from killing this service
26
- mkdir_p 'logs'
27
- ENV['test_server_pid'] = Process.spawn('ruby', 'exe/soaspec', 'virtual_server', err: %w[logs/test_server.log w]).to_s
28
- sleep 2 # Wait a little for virtual server to start up
29
- puts 'Running test server at pid ' + ENV['test_server_pid']
30
- end
31
-
32
- YARD::Rake::YardocTask.new do |t|
33
- t.files = %w[features/**/*.feature features/**/*.rb lib/soaspec/cucumber/*.rb] # lib/soaspec/cucumber/*.rb]
34
- end
35
-
36
- desc 'Ensure system has all docs'
37
- task :must_have_docs do
38
- yard = `yard`
39
- puts yard
40
- percentage = yard.lines.last.strip.split('%').first.to_f
41
- raise 'Must be fully documented' unless percentage == 100.00
42
- end
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rake/clean'
4
+ require 'yard'
5
+
6
+ ENV['folder'] ||= ''
7
+ ENV['test'] ||= ''
8
+
9
+ desc 'Run tests'
10
+ RSpec::Core::RakeTask.new(spec: %i[clean clobber start_test_server]) do |t|
11
+ t.pattern = "spec/**/#{ENV['folder']}*/#{ENV['test']}*_spec.rb"
12
+ end
13
+
14
+ task :parallel => [:clean, :clobber, :start_test_server] do
15
+ puts `parallel_rspec spec`
16
+ end
17
+
18
+ task default: :spec
19
+
20
+ CLEAN.include 'tmp/*'
21
+ CLOBBER.include 'logs/*'
22
+
23
+ desc 'Start virtual web service'
24
+ task :start_test_server do
25
+ ENV['leave_server_running'] = 'true' # This will stop created suites from killing this service
26
+ mkdir_p 'logs'
27
+ ENV['test_server_pid'] = Process.spawn('ruby', 'exe/soaspec', 'virtual_server', err: %w[logs/test_server.log w]).to_s
28
+ sleep 2 # Wait a little for virtual server to start up
29
+ puts 'Running test server at pid ' + ENV['test_server_pid']
30
+ end
31
+
32
+ YARD::Rake::YardocTask.new do |t|
33
+ t.files = %w[features/**/*.feature features/**/*.rb lib/soaspec/cucumber/*.rb] # lib/soaspec/cucumber/*.rb]
34
+ end
35
+
36
+ desc 'Ensure system has all docs'
37
+ task :must_have_docs do
38
+ yard = `yard`
39
+ puts yard
40
+ percentage = yard.lines.last.strip.split('%').first.to_f
41
+ raise 'Must be fully documented' unless percentage == 100.00
42
+ end
data/Todo.md CHANGED
@@ -1,15 +1,15 @@
1
- * `yard` should show everything documented
2
- * Rubocop should have 0 offenses
3
- * Unit tests
4
- * OAuth class, etc
5
- * Get initial `soaspec new` working with TODOs as placeholders for how to get started
6
- * Request method from within exchange
7
- * Use this in tests
8
- * Basic service generator
9
- * Give examples and convenience methods for building classes for each SOAP or REST operation
10
- * Potentially have in built use of 'vcr' and 'http_stub' gems
11
- * Handle proxies to record traffic for MiddleWare testing
12
- * soaspec generate
13
- * Get wsdl generator working for non complex gems (Put on hold til new Savon version)
14
- * Generate from a RAML
15
- * Much more - please raise an issue for suggestion
1
+ * `yard` should show everything documented
2
+ * Rubocop should have 0 offenses
3
+ * Unit tests
4
+ * OAuth class, etc
5
+ * Get initial `soaspec new` working with TODOs as placeholders for how to get started
6
+ * Request method from within exchange
7
+ * Use this in tests
8
+ * Basic service generator
9
+ * Give examples and convenience methods for building classes for each SOAP or REST operation
10
+ * Potentially have in built use of 'vcr' and 'http_stub' gems
11
+ * Handle proxies to record traffic for MiddleWare testing
12
+ * soaspec generate
13
+ * Get wsdl generator working for non complex gems (Put on hold til new Savon version)
14
+ * Generate from a RAML
15
+ * Much more - please raise an issue for suggestion
@@ -1,123 +1,123 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'thor'
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
5
- require 'savon'
6
- require 'soaspec'
7
- require 'soaspec/virtual_server'
8
- require 'soaspec/wsdl_generator'
9
-
10
- module Soaspec
11
- # Common executable for Soaspec
12
- class Exe < Thor
13
- include Soaspec::ExeHelpers
14
- include Soaspec::WsdlGenerator
15
-
16
- long_desc <<-LONGDESC
17
- `soaspec new` will generate the initial files and folders for starting a testing project using soaspec
18
- \x5
19
-
20
- `soaspec new soap` will create example files testing against a SOAP service
21
- \x5
22
-
23
- `soaspec new rest` will create example files testing against a REST service
24
- LONGDESC
25
- desc 'new [type]', 'Initialize soaspec repository'
26
- option :ci, default: 'jenkins', banner: 'What Continuous Integration is used'
27
- option :virtual, type: :boolean, default: true, banner: 'Whether to set things up for a virtual server'
28
- def new(type = 'initial')
29
- @virtual = options[:virtual]
30
- @type = type
31
- puts "Creating files for soaspec. options are #{options}"
32
- create_file(filename: 'Gemfile')
33
- create_file(filename: 'Rakefile')
34
- create_file(filename: '.rspec')
35
- create_file(filename: 'README.md')
36
- create_file(filename: '.travis.yml') if options[:ci] == 'travis'
37
- create_folder 'lib'
38
- create_files_for type
39
- create_file(filename: 'config/data/default.yml') # Example of data file
40
- create_file(filename: 'spec/spec_helper.rb')
41
- puts "Run 'bundle install' to install necessary gems"
42
- puts "Run 'rake spec' to run the tests"
43
- end
44
-
45
- long_desc <<-LONGDESC
46
- `soaspec add rest` will generate the initial files and folders for starting a testing project using soaspec
47
- \x5
48
-
49
- `soaspec add soap` will create example files testing against a virtual SOAP service
50
- \x5
51
-
52
- LONGDESC
53
- desc 'add [type] [name]', 'Add new ExchangeHandler'
54
- def add(type = 'rest', name = 'TestService')
55
- raise "Type '#{type}' is not available" unless %w[rest soap].include? type
56
-
57
- @name = name # Use instance variable for ERB
58
- create_file filename: File.join('lib', "#{name.snakecase}.rb"),
59
- content: retrieve_contents(File.join('lib', "new_#{type}_service.rb"))
60
- end
61
-
62
- desc 'cucumber', 'Add cucumber generic steps template within step_definitions folder'
63
- def cucumber
64
- create_file filename: File.join('features', 'step_definitions', 'generic_steps.rb'),
65
- content: retrieve_contents(File.join('../cucumber', 'generic_steps.rb'), false)
66
- end
67
-
68
- desc 'generate', 'Generate initial test code from wsdl'
69
- long_desc <<-LONGDESC
70
- If no wsdl is given a server will be started from which code to generate Exchanges
71
-
72
- `soaspec generate wsdl=wsdl name=ServiceName ` will generate the initial files and folders to test each operation in a wsdl
73
- \x5
74
- Additionally the auth parameter can be used to use basic authentication to retrieve the WSDL.
75
- To do use the following `soaspec generate --auth=basic`
76
- Note: This is still a work in progress and will only work for a very simple wsdl
77
- LONGDESC
78
- option :wsdl, default: nil, aliases: :w
79
- option :name, default: 'Service', aliases: :n
80
- option :ci, default: 'jenkins', banner: 'What Continuous Integration is used'
81
- option :auth
82
- option :open_browser, default: 'true'
83
- option :string_default, default: 'test string'
84
- def generate
85
- if options[:wsdl]
86
- generate_from_wsdl(options)
87
- else
88
- require 'launchy'
89
- require 'soaspec/generate_server'
90
- Soaspec::GenerateServer.run! do
91
- Launchy.open 'http://localhost:8999' if options[:open_browser] == 'true'
92
- end
93
- end
94
- end
95
-
96
- long_desc <<-LONGDESC
97
- Run virtual web services on localhost. See root for documentation of web services provided.
98
- LONGDESC
99
- desc 'virtual_server [port]', 'Run virtual web service on localhost'
100
- def virtual_server(port = '4999')
101
- ENV['port'] = port
102
- require 'soaspec/virtual_server'
103
- Soaspec::VirtualServer.run!(Port: port)
104
- end
105
-
106
- long_desc <<-LONGDESC
107
- Run pry with Soaspec and other relevant libraries loaded. Pass either the relative path to files desired with a
108
- '.rb' extension or the path to the folder to be loaded with 'require_all'
109
- LONGDESC
110
- desc 'pry [required_files]', 'Run pry with Soaspec and other relevant libraries loaded'
111
- def pry(required_files = nil)
112
- require 'soaspec'
113
-
114
- require 'require_all'
115
- require_all required_files if required_files
116
-
117
- require 'pry'
118
- Pry.start
119
- end
120
- end
121
- end
122
-
123
- Soaspec::Exe.start(ARGV)
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'thor'
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
5
+ require 'savon'
6
+ require 'soaspec'
7
+ require 'soaspec/virtual_server'
8
+ require 'soaspec/wsdl_generator'
9
+
10
+ module Soaspec
11
+ # Common executable for Soaspec
12
+ class Exe < Thor
13
+ include Soaspec::ExeHelpers
14
+ include Soaspec::WsdlGenerator
15
+
16
+ long_desc <<-LONGDESC
17
+ `soaspec new` will generate the initial files and folders for starting a testing project using soaspec
18
+ \x5
19
+
20
+ `soaspec new soap` will create example files testing against a SOAP service
21
+ \x5
22
+
23
+ `soaspec new rest` will create example files testing against a REST service
24
+ LONGDESC
25
+ desc 'new [type]', 'Initialize soaspec repository'
26
+ option :ci, default: 'jenkins', banner: 'What Continuous Integration is used'
27
+ option :virtual, type: :boolean, default: true, banner: 'Whether to set things up for a virtual server'
28
+ def new(type = 'initial')
29
+ @virtual = options[:virtual]
30
+ @type = type
31
+ puts "Creating files for soaspec. options are #{options}"
32
+ create_file(filename: 'Gemfile')
33
+ create_file(filename: 'Rakefile')
34
+ create_file(filename: '.rspec')
35
+ create_file(filename: 'README.md')
36
+ create_file(filename: '.travis.yml') if options[:ci] == 'travis'
37
+ create_folder 'lib'
38
+ create_files_for type
39
+ create_file(filename: 'config/data/default.yml') # Example of data file
40
+ create_file(filename: 'spec/spec_helper.rb')
41
+ puts "Run 'bundle install' to install necessary gems"
42
+ puts "Run 'rake spec' to run the tests"
43
+ end
44
+
45
+ long_desc <<-LONGDESC
46
+ `soaspec add rest` will generate the initial files and folders for starting a testing project using soaspec
47
+ \x5
48
+
49
+ `soaspec add soap` will create example files testing against a virtual SOAP service
50
+ \x5
51
+
52
+ LONGDESC
53
+ desc 'add [type] [name]', 'Add new ExchangeHandler'
54
+ def add(type = 'rest', name = 'TestService')
55
+ raise "Type '#{type}' is not available" unless %w[rest soap].include? type
56
+
57
+ @name = name # Use instance variable for ERB
58
+ create_file filename: File.join('lib', "#{name.snakecase}.rb"),
59
+ content: retrieve_contents(File.join('lib', "new_#{type}_service.rb"))
60
+ end
61
+
62
+ desc 'cucumber', 'Add cucumber generic steps template within step_definitions folder'
63
+ def cucumber
64
+ create_file filename: File.join('features', 'step_definitions', 'generic_steps.rb'),
65
+ content: retrieve_contents(File.join('../cucumber', 'generic_steps.rb'), false)
66
+ end
67
+
68
+ desc 'generate', 'Generate initial test code from wsdl'
69
+ long_desc <<-LONGDESC
70
+ If no wsdl is given a server will be started from which code to generate Exchanges
71
+
72
+ `soaspec generate wsdl=wsdl name=ServiceName ` will generate the initial files and folders to test each operation in a wsdl
73
+ \x5
74
+ Additionally the auth parameter can be used to use basic authentication to retrieve the WSDL.
75
+ To do use the following `soaspec generate --auth=basic`
76
+ Note: This is still a work in progress and will only work for a very simple wsdl
77
+ LONGDESC
78
+ option :wsdl, default: nil, aliases: :w
79
+ option :name, default: 'Service', aliases: :n
80
+ option :ci, default: 'jenkins', banner: 'What Continuous Integration is used'
81
+ option :auth
82
+ option :open_browser, default: 'true'
83
+ option :string_default, default: 'test string'
84
+ def generate
85
+ if options[:wsdl]
86
+ generate_from_wsdl(options)
87
+ else
88
+ require 'launchy'
89
+ require 'soaspec/generate_server'
90
+ Soaspec::GenerateServer.run! do
91
+ Launchy.open 'http://localhost:8999' if options[:open_browser] == 'true'
92
+ end
93
+ end
94
+ end
95
+
96
+ long_desc <<-LONGDESC
97
+ Run virtual web services on localhost. See root for documentation of web services provided.
98
+ LONGDESC
99
+ desc 'virtual_server [port]', 'Run virtual web service on localhost'
100
+ def virtual_server(port = '4999')
101
+ ENV['port'] = port
102
+ require 'soaspec/virtual_server'
103
+ Soaspec::VirtualServer.run!(Port: port)
104
+ end
105
+
106
+ long_desc <<-LONGDESC
107
+ Run pry with Soaspec and other relevant libraries loaded. Pass either the relative path to files desired with a
108
+ '.rb' extension or the path to the folder to be loaded with 'require_all'
109
+ LONGDESC
110
+ desc 'pry [required_files]', 'Run pry with Soaspec and other relevant libraries loaded'
111
+ def pry(required_files = nil)
112
+ require 'soaspec'
113
+
114
+ require 'require_all'
115
+ require_all required_files if required_files
116
+
117
+ require 'pry'
118
+ Pry.start
119
+ end
120
+ end
121
+ end
122
+
123
+ Soaspec::Exe.start(ARGV)
@@ -1,42 +1,42 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'xmlsimple'
4
- require 'yaml'
5
- require 'fileutils'
6
-
7
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
8
-
9
- require 'soaspec'
10
-
11
- include Soaspec::ExeHelpers
12
-
13
- default_output_file = 'output.yml'
14
-
15
- # For all keys in a Hash, convert Camelcase to underscore separated
16
- def convert_hash_keys(value)
17
- case value
18
- when Array
19
- value.map { |v| convert_hash_keys(v) }
20
- when Hash
21
- Hash[value.map { |k, v| [k.snakecase, convert_hash_keys(v)] }]
22
- else
23
- value
24
- end
25
- end
26
-
27
- # Remove arrays created as another string
28
- def clean_up_yaml(yaml_string)
29
- yaml_string = yaml_string.gsub(/\R+(\s*)-/, '').gsub(/{}/, "''") # Remove arrays, {} -> ''
30
- # Insert new line where there are 2 ':' on 1 line. Issue from first gsub
31
- yaml_string.gsub(/:(\s)(\w*):/) { |s| s.insert(1, "\n") }
32
- end
33
-
34
- if ARGV[0]
35
- warn "Using '#{default_output_file}' as default output file since no 2nd argument passed" unless ARGV[1]
36
- hash = XmlSimple.xml_in(ARGV[0])
37
- converted = convert_hash_keys hash
38
- yaml_file = clean_up_yaml(converted.to_yaml)
39
- create_file(filename: ARGV[1] || default_output_file, content: yaml_file)
40
- else
41
- puts 'usage: xml_to_yaml_file [input.xml] [output.yml] '
42
- end
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'xmlsimple'
4
+ require 'yaml'
5
+ require 'fileutils'
6
+
7
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
8
+
9
+ require 'soaspec'
10
+
11
+ include Soaspec::ExeHelpers
12
+
13
+ default_output_file = 'output.yml'
14
+
15
+ # For all keys in a Hash, convert Camelcase to underscore separated
16
+ def convert_hash_keys(value)
17
+ case value
18
+ when Array
19
+ value.map { |v| convert_hash_keys(v) }
20
+ when Hash
21
+ Hash[value.map { |k, v| [k.snakecase, convert_hash_keys(v)] }]
22
+ else
23
+ value
24
+ end
25
+ end
26
+
27
+ # Remove arrays created as another string
28
+ def clean_up_yaml(yaml_string)
29
+ yaml_string = yaml_string.gsub(/\R+(\s*)-/, '').gsub(/{}/, "''") # Remove arrays, {} -> ''
30
+ # Insert new line where there are 2 ':' on 1 line. Issue from first gsub
31
+ yaml_string.gsub(/:(\s)(\w*):/) { |s| s.insert(1, "\n") }
32
+ end
33
+
34
+ if ARGV[0]
35
+ warn "Using '#{default_output_file}' as default output file since no 2nd argument passed" unless ARGV[1]
36
+ hash = XmlSimple.xml_in(ARGV[0])
37
+ converted = convert_hash_keys hash
38
+ yaml_file = clean_up_yaml(converted.to_yaml)
39
+ create_file(filename: ARGV[1] || default_output_file, content: yaml_file)
40
+ else
41
+ puts 'usage: xml_to_yaml_file [input.xml] [output.yml] '
42
+ end
@@ -1,101 +1,101 @@
1
- require 'rest-client' # REST
2
- require 'erb' # Embedded ruby
3
- require 'yaml' # Reading yaml
4
- require 'rspec' # Testing framework
5
- require 'rspec/its'
6
- require 'savon' # SOAP
7
- require 'nokogiri' # XPath
8
- require 'date'
9
- require 'jsonpath'
10
-
11
- require 'soaspec/version'
12
- require 'soaspec/indifferent_hash'
13
- require 'soaspec/o_auth2'
14
- require 'soaspec/template_reader'
15
- require 'soaspec/exchange_handlers/soap_handler'
16
- require 'soaspec/exchange_handlers/exchange_handler'
17
- require 'soaspec/exchange_handlers/rest_methods'
18
- require 'soaspec/exchange/exchange'
19
- require 'soaspec/matchers'
20
- require 'soaspec/soaspec_shared_examples'
21
- require 'soaspec/core_ext/hash'
22
- require 'soaspec/spec_logger'
23
- require 'soaspec/exe_helpers'
24
- require 'soaspec/exchange_handlers/rest_handler'
25
- require 'soaspec/exchange_handlers/handler_accessors'
26
- require 'soaspec/interpreter'
27
- require 'soaspec/not_found_errors'
28
- require 'soaspec/wait'
29
-
30
- # Gem for handling SOAP and REST api tests
31
- module Soaspec
32
- @template_folder = 'templates'
33
- @auto_oauth = true
34
- @log_warnings = true
35
-
36
- class << self
37
- # Folder used to store templates for API calls
38
- # @return [String]
39
- attr_reader :template_folder
40
- # Stores last exchange
41
- # @return [Exchange]
42
- attr_accessor :last_exchange
43
- # Automatically add Authorization header to RestHandler where oauth2 credentials are specified
44
- # @return [Boolean] Whether to add authorization header
45
- attr_accessor :auto_oauth
46
-
47
- # Folder used to store templates for API calls
48
- # Converts folder / folders into an array depending upon string passed
49
- def template_folder=(folder)
50
- @template_folder = folder.include?('\\') ? folder.split('\\') : folder.split('/')
51
- end
52
-
53
- # Credentials folder used to store secret data (not in source control) E.g passwords
54
- # Used in oauth2_file command
55
- # @return [String] folder in which credentials are stored
56
- attr_accessor :credentials_folder
57
-
58
- # Used so that exchange class knows what context it's in.
59
- # @return [ExchangeHandler] handler A class inheriting from Soaspec::ExchangeHandler. Exchange class uses this
60
- attr_accessor :api_handler
61
-
62
- # Set whether to transform strings to keys in request automatically.
63
- # @return [Boolean]
64
- attr_writer :always_use_keys
65
-
66
- # @return [Boolean] Whether to log warnings such as methods that may change usage in the future
67
- attr_accessor :log_warnings
68
-
69
- # @return [Boolean] Whether to transform strings to keys in request automatically
70
- def always_use_keys?
71
- @always_use_keys || true
72
- end
73
-
74
- # @return [Boolean] Whether to see params sent to & received from oauth URL
75
- def debug_oauth?
76
- puts 'Soaspec.debug_oauth? now deprecated. Please use Soaspec::OAuth2.debug_oauth? instead'
77
- Soaspec::OAuth2.debug_oauth?
78
- end
79
-
80
- # Specify whether to see params sent to and retrieved from oauth.
81
- # This will put password in log file, only recommended for debugging
82
- # @param [String] set Whether to debug oauth
83
- def debug_oauth=(set)
84
- puts 'Soaspec.debug_oauth= now deprecated. Please use Soaspec::OAuth2.debug_oauth= instead'
85
- Soaspec::OAuth2.debug_oauth = set
86
- end
87
-
88
- # Whether to log all API traffic
89
- # @param [Boolean] set
90
- def log_api_traffic=(set)
91
- puts 'Soaspec.log_api_traffic= now deprecated. Please use Soaspec::SpecLogger.log_api_traffic= instead'
92
- Soaspec::SpecLogger.log_api_traffic = set
93
- end
94
-
95
- # @return [Boolean] Whether to log all API traffic
96
- def log_api_traffic?
97
- puts 'Soaspec.log_api_traffic? now deprecated. Please use Soaspec::SpecLogger.log_api_traffic? instead'
98
- Soaspec::SpecLogger.log_api_traffic?
99
- end
100
- end
101
- end
1
+ require 'rest-client' # REST
2
+ require 'erb' # Embedded ruby
3
+ require 'yaml' # Reading yaml
4
+ require 'rspec' # Testing framework
5
+ require 'rspec/its'
6
+ require 'savon' # SOAP
7
+ require 'nokogiri' # XPath
8
+ require 'date'
9
+ require 'jsonpath'
10
+
11
+ require 'soaspec/version'
12
+ require 'soaspec/indifferent_hash'
13
+ require 'soaspec/o_auth2'
14
+ require 'soaspec/template_reader'
15
+ require 'soaspec/exchange_handlers/soap_handler'
16
+ require 'soaspec/exchange_handlers/exchange_handler'
17
+ require 'soaspec/exchange_handlers/rest_methods'
18
+ require 'soaspec/exchange/exchange'
19
+ require 'soaspec/matchers'
20
+ require 'soaspec/soaspec_shared_examples'
21
+ require 'soaspec/core_ext/hash'
22
+ require 'soaspec/spec_logger'
23
+ require 'soaspec/exe_helpers'
24
+ require 'soaspec/exchange_handlers/rest_handler'
25
+ require 'soaspec/exchange_handlers/handler_accessors'
26
+ require 'soaspec/interpreter'
27
+ require 'soaspec/not_found_errors'
28
+ require 'soaspec/wait'
29
+
30
+ # Gem for handling SOAP and REST api tests
31
+ module Soaspec
32
+ @template_folder = 'templates'
33
+ @auto_oauth = true
34
+ @log_warnings = true
35
+
36
+ class << self
37
+ # Folder used to store templates for API calls
38
+ # @return [String]
39
+ attr_reader :template_folder
40
+ # Stores last exchange
41
+ # @return [Exchange]
42
+ attr_accessor :last_exchange
43
+ # Automatically add Authorization header to RestHandler where oauth2 credentials are specified
44
+ # @return [Boolean] Whether to add authorization header
45
+ attr_accessor :auto_oauth
46
+
47
+ # Folder used to store templates for API calls
48
+ # Converts folder / folders into an array depending upon string passed
49
+ def template_folder=(folder)
50
+ @template_folder = folder.include?('\\') ? folder.split('\\') : folder.split('/')
51
+ end
52
+
53
+ # Credentials folder used to store secret data (not in source control) E.g passwords
54
+ # Used in oauth2_file command
55
+ # @return [String] folder in which credentials are stored
56
+ attr_accessor :credentials_folder
57
+
58
+ # Used so that exchange class knows what context it's in.
59
+ # @return [ExchangeHandler] handler A class inheriting from Soaspec::ExchangeHandler. Exchange class uses this
60
+ attr_accessor :api_handler
61
+
62
+ # Set whether to transform strings to keys in request automatically.
63
+ # @return [Boolean]
64
+ attr_writer :always_use_keys
65
+
66
+ # @return [Boolean] Whether to log warnings such as methods that may change usage in the future
67
+ attr_accessor :log_warnings
68
+
69
+ # @return [Boolean] Whether to transform strings to keys in request automatically
70
+ def always_use_keys?
71
+ @always_use_keys || true
72
+ end
73
+
74
+ # @return [Boolean] Whether to see params sent to & received from oauth URL
75
+ def debug_oauth?
76
+ puts 'Soaspec.debug_oauth? now deprecated. Please use Soaspec::OAuth2.debug_oauth? instead'
77
+ Soaspec::OAuth2.debug_oauth?
78
+ end
79
+
80
+ # Specify whether to see params sent to and retrieved from oauth.
81
+ # This will put password in log file, only recommended for debugging
82
+ # @param [String] set Whether to debug oauth
83
+ def debug_oauth=(set)
84
+ puts 'Soaspec.debug_oauth= now deprecated. Please use Soaspec::OAuth2.debug_oauth= instead'
85
+ Soaspec::OAuth2.debug_oauth = set
86
+ end
87
+
88
+ # Whether to log all API traffic
89
+ # @param [Boolean] set
90
+ def log_api_traffic=(set)
91
+ puts 'Soaspec.log_api_traffic= now deprecated. Please use Soaspec::SpecLogger.log_api_traffic= instead'
92
+ Soaspec::SpecLogger.log_api_traffic = set
93
+ end
94
+
95
+ # @return [Boolean] Whether to log all API traffic
96
+ def log_api_traffic?
97
+ puts 'Soaspec.log_api_traffic? now deprecated. Please use Soaspec::SpecLogger.log_api_traffic? instead'
98
+ Soaspec::SpecLogger.log_api_traffic?
99
+ end
100
+ end
101
+ end