soaspec 0.2.19 → 0.2.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/ChangeLog +4 -0
- data/exe/soaspec +17 -1
- data/lib/soaspec.rb +0 -7
- data/lib/soaspec/exchange/exchange.rb +8 -2
- data/lib/soaspec/exe_helpers.rb +14 -7
- data/lib/soaspec/generate_server.rb +6 -7
- data/lib/soaspec/test_server/id_manager.rb +11 -2
- data/lib/soaspec/version.rb +1 -1
- data/lib/soaspec/virtual_server.rb +6 -0
- data/lib/soaspec/wsdl_generator.rb +12 -8
- data/soaspec.gemspec +3 -4
- metadata +33 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0f031c3b5588049808871e6fcda16d9381811b18df3cf383f9a777cb82a6fa23
|
4
|
+
data.tar.gz: 5ea7c6cff5d06ed935e43d53f32289c13430a9da8047a946dc84c30ec18994b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cd0f0bdc1b1938cdf67e6e3f5c04ec69a9a58d734fd2e815cb8ab9b1cad051618f6a33acc021161ba26715a167ae8b8358bea70889bf5d328c168aed1119251
|
7
|
+
data.tar.gz: 0d3a7087204edf457af446cecc5347f4a7045e3c56d57c1856ab2876ec96570397a2f7fa9b8ef2445c2417c38d409134d0644653cce54b7f699ca1eef2728871
|
data/ChangeLog
CHANGED
data/exe/soaspec
CHANGED
@@ -4,6 +4,8 @@ require 'thor'
|
|
4
4
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
5
5
|
require 'savon'
|
6
6
|
require 'soaspec'
|
7
|
+
require 'soaspec/virtual_server'
|
8
|
+
require 'soaspec/wsdl_generator'
|
7
9
|
|
8
10
|
module Soaspec
|
9
11
|
# Common executable for Soaspec
|
@@ -86,7 +88,6 @@ module Soaspec
|
|
86
88
|
require 'launchy'
|
87
89
|
require 'soaspec/generate_server'
|
88
90
|
Soaspec::GenerateServer.run! do
|
89
|
-
sleep 2
|
90
91
|
Launchy.open 'http://localhost:8999' if options[:open_browser] == 'true'
|
91
92
|
end
|
92
93
|
end
|
@@ -101,6 +102,21 @@ module Soaspec
|
|
101
102
|
require 'soaspec/virtual_server'
|
102
103
|
Soaspec::VirtualServer.run!(Port: port)
|
103
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
|
104
120
|
end
|
105
121
|
end
|
106
122
|
|
data/lib/soaspec.rb
CHANGED
@@ -25,13 +25,6 @@ require 'soaspec/exchange_handlers/rest_handler'
|
|
25
25
|
require 'soaspec/exchange_handlers/handler_accessors'
|
26
26
|
require 'soaspec/interpreter'
|
27
27
|
require 'soaspec/not_found_errors'
|
28
|
-
require 'soaspec/test_server/get_bank'
|
29
|
-
require 'soaspec/test_server/test_attribute'
|
30
|
-
require 'soaspec/test_server/puppy_service'
|
31
|
-
require 'soaspec/test_server/invoices'
|
32
|
-
require 'soaspec/test_server/test_namespace'
|
33
|
-
require 'soaspec/test_server/id_manager'
|
34
|
-
require 'soaspec/wsdl_generator'
|
35
28
|
require 'soaspec/wait'
|
36
29
|
|
37
30
|
# Gem for handling SOAP and REST api tests
|
@@ -83,7 +83,8 @@ class Exchange
|
|
83
83
|
test_name
|
84
84
|
end
|
85
85
|
|
86
|
-
# Returns response object from Api.
|
86
|
+
# @return [RestClient::Response,Savon::Response] Returns response object from Api.
|
87
|
+
# Will make the request if not made and then cache it for later on
|
87
88
|
# @example For SOAP it will be a Savon response
|
88
89
|
# response.body (body of response as Hash)
|
89
90
|
# response.header (head of response as Hash)
|
@@ -95,5 +96,10 @@ class Exchange
|
|
95
96
|
@response
|
96
97
|
end
|
97
98
|
|
98
|
-
|
99
|
+
# @return [ResponseObject] Currently returning response object. This will change (in 0.3) to be itself to
|
100
|
+
# allow easy method chaining
|
101
|
+
def call
|
102
|
+
warn 'This method will be changed to return "Exchange" object in 0.3. Use "response" method if you want the response object'
|
103
|
+
response
|
104
|
+
end
|
99
105
|
end
|
data/lib/soaspec/exe_helpers.rb
CHANGED
@@ -45,18 +45,25 @@ module Soaspec
|
|
45
45
|
# @param [String] filename Name of the file to create
|
46
46
|
# @param [String] content Content to place inside file
|
47
47
|
# @param [Boolean] ignore_if_present Don't complain if file is present
|
48
|
+
# @return [String] String describing if file created or not
|
48
49
|
def create_file(filename: nil, content: nil, ignore_if_present: false, erb: true)
|
49
50
|
raise 'Need to pass filename' unless filename
|
50
51
|
|
51
52
|
content ||= retrieve_contents(filename, erb)
|
52
53
|
create_folder File.split(filename).first
|
53
|
-
if File.exist? filename
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
54
|
+
msg = if File.exist? filename
|
55
|
+
old_content = File.read(filename)
|
56
|
+
if old_content != content && !ignore_if_present
|
57
|
+
"!! #{filename} already exists and differs from template"
|
58
|
+
else
|
59
|
+
"#{filename} already exists"
|
60
|
+
end
|
61
|
+
else
|
62
|
+
File.open(filename, 'w') { |f| f.puts content }
|
63
|
+
"Created: #{filename}"
|
64
|
+
end
|
65
|
+
puts msg
|
66
|
+
msg
|
60
67
|
end
|
61
68
|
|
62
69
|
# Create folder if there's not a file already there.
|
@@ -6,6 +6,7 @@ module Soaspec
|
|
6
6
|
include Soaspec::ExeHelpers
|
7
7
|
|
8
8
|
class << self
|
9
|
+
# @return [Hash] Parameters used when creating handler
|
9
10
|
attr_accessor :create_params
|
10
11
|
end
|
11
12
|
|
@@ -22,17 +23,15 @@ module Soaspec
|
|
22
23
|
end
|
23
24
|
|
24
25
|
post '/generate' do
|
25
|
-
|
26
|
-
type = :rest
|
26
|
+
type = :rest # SOAP will be added to later
|
27
27
|
@name = params['className']
|
28
28
|
@base_url = params['baseUrl']
|
29
29
|
filename = File.join('lib', "#{params['className'].snakecase}.rb")
|
30
|
-
create_file filename: filename,
|
31
|
-
|
30
|
+
feedback = create_file filename: filename,
|
31
|
+
content: retrieve_contents(File.join('lib', "new_#{type}_service.rb"))
|
32
32
|
GenerateServer.create_params = params
|
33
|
-
GenerateServer.create_params['feedback'] =
|
33
|
+
GenerateServer.create_params['feedback'] = feedback
|
34
34
|
redirect '/'
|
35
|
-
# params.to_s
|
36
35
|
end
|
37
36
|
end
|
38
|
-
end
|
37
|
+
end
|
@@ -1,24 +1,33 @@
|
|
1
1
|
module Soaspec
|
2
2
|
module TestServer
|
3
3
|
# Handles returning ids dependent on a number of factors
|
4
|
-
# Made to demonstrate creating testing a list of ids
|
4
|
+
# Made to demonstrate creating testing a list of ids where a few return false
|
5
|
+
# when not developed and checking each value in the list can find the false value
|
5
6
|
class IdManager
|
7
|
+
# @return [Boolean] Whether to simulate a fully developed state where everything is done
|
6
8
|
@developed = false
|
7
9
|
class << self
|
8
10
|
attr_accessor :developed
|
9
11
|
|
12
|
+
# Once developed is set, everything will return true. A 'false' value represents something
|
13
|
+
# not developed
|
14
|
+
# @param [String] num Number representing tester or test number
|
15
|
+
# @param [String] id Id used in test
|
10
16
|
# @return Result depending on num, id and whether '@developed' is set
|
11
17
|
def result_for(num, id)
|
12
18
|
result = undeveloped_id(num, id) unless @developed
|
13
19
|
result || 'true'
|
14
20
|
end
|
15
21
|
|
22
|
+
# Idea is that this will return false for a particular id for different test numbers
|
23
|
+
# @param [String] num Number representing tester or test number
|
24
|
+
# @param [String] id Id used in test
|
16
25
|
# @return [String] true of false depending on num and id
|
17
26
|
def undeveloped_id(num, id)
|
18
27
|
case num
|
19
28
|
when '1', '4', '10' then 'false' if id == '40'
|
20
29
|
when '3', '11', '9' then 'false' if id == '74'
|
21
|
-
when '
|
30
|
+
when '2', '6', '8' then 'false' if id == '80'
|
22
31
|
when '7', '5', '12' then 'false' if id == '64'
|
23
32
|
else
|
24
33
|
'true'
|
data/lib/soaspec/version.rb
CHANGED
@@ -6,6 +6,12 @@ require 'nokogiri'
|
|
6
6
|
require 'erb'
|
7
7
|
require 'json'
|
8
8
|
require 'faker'
|
9
|
+
require 'soaspec/test_server/get_bank'
|
10
|
+
require 'soaspec/test_server/test_attribute'
|
11
|
+
require 'soaspec/test_server/puppy_service'
|
12
|
+
require 'soaspec/test_server/invoices'
|
13
|
+
require 'soaspec/test_server/test_namespace'
|
14
|
+
require 'soaspec/test_server/id_manager'
|
9
15
|
|
10
16
|
module Soaspec
|
11
17
|
# Used to run virtual web service on localhost. This makes tests more reliable and faster
|
@@ -1,16 +1,18 @@
|
|
1
1
|
module Soaspec
|
2
2
|
# Produce test content from a WSDL
|
3
3
|
module WsdlGenerator
|
4
|
+
include ExeHelpers
|
5
|
+
|
4
6
|
# Generate from WSDL
|
5
7
|
def generate_from_wsdl(options)
|
6
|
-
enter_auth_details if options[:auth] == 'basic'
|
8
|
+
auth_name, auth_password = enter_auth_details if options[:auth] == 'basic'
|
7
9
|
@virtual = false
|
8
10
|
savon_options = { wsdl: options[:wsdl] }
|
9
|
-
savon_options[:basic_auth] = [
|
10
|
-
|
11
|
-
@wsdl_doc = Savon.client(**savon_options).wsdl
|
12
|
-
@wsdl_schemas = @wsdl_doc.parser.schemas
|
11
|
+
savon_options[:basic_auth] = [auth_name, auth_password] if options[:auth] == 'basic'
|
13
12
|
|
13
|
+
wsdl_doc = Savon.client(**savon_options).wsdl
|
14
|
+
@wsdl_schemas = wsdl_doc.parser.schemas
|
15
|
+
# Create basic project files
|
14
16
|
create_files %w[Rakefile Gemfile README.md spec/spec_helper.rb], ignore_if_present: true
|
15
17
|
create_file(filename: '.rspec')
|
16
18
|
create_file(filename: '.travis.yml') if options[:ci] == 'travis'
|
@@ -18,7 +20,7 @@ module Soaspec
|
|
18
20
|
create_file filename: "lib/#{options[:name].snakecase}.rb", content: class_content
|
19
21
|
|
20
22
|
# Files according to WSDL
|
21
|
-
|
23
|
+
wsdl_doc.operations.each do |operation, op_details|
|
22
24
|
puts "Creating files for operation: #{operation}"
|
23
25
|
@content = "default:\n"
|
24
26
|
@use_camel_case = false
|
@@ -176,20 +178,22 @@ module Soaspec
|
|
176
178
|
end
|
177
179
|
|
178
180
|
# Prompt user to enter basic auth details
|
181
|
+
# @return [Array] Array with Basic auth username and password entered
|
179
182
|
def enter_auth_details
|
180
183
|
prompt = <<-AUTH_PROMPT
|
181
184
|
User Name:
|
182
185
|
AUTH_PROMPT
|
183
186
|
print prompt.chop
|
184
|
-
|
187
|
+
auth_name = $stdin.gets.strip
|
185
188
|
puts
|
186
189
|
|
187
190
|
prompt = <<-PASSWORD
|
188
191
|
User Password:
|
189
192
|
PASSWORD
|
190
193
|
print prompt.chop
|
191
|
-
|
194
|
+
auth_password = $stdin.gets.strip
|
192
195
|
puts
|
196
|
+
[auth_name, auth_password]
|
193
197
|
end
|
194
198
|
end
|
195
199
|
end
|
data/soaspec.gemspec
CHANGED
@@ -29,7 +29,6 @@ the same configuration. Examples designed for RSpec and Cucumber."
|
|
29
29
|
spec.add_development_dependency 'rack'
|
30
30
|
spec.add_development_dependency 'rack-test'
|
31
31
|
spec.add_development_dependency 'rake', '~> 12.0'
|
32
|
-
spec.add_development_dependency 'require_all', '1.5.0'
|
33
32
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
34
33
|
spec.add_development_dependency 'simplecov'
|
35
34
|
spec.add_development_dependency 'yard-cucumber'
|
@@ -40,13 +39,13 @@ the same configuration. Examples designed for RSpec and Cucumber."
|
|
40
39
|
spec.add_dependency 'jsonpath'
|
41
40
|
spec.add_dependency 'launchy'
|
42
41
|
spec.add_dependency 'nokogiri'
|
42
|
+
spec.add_dependency 'pry'
|
43
|
+
spec.add_dependency 'require_all', '>= 1.5.0'
|
43
44
|
spec.add_dependency 'rest-client', '>= 2.0' # REST
|
44
45
|
spec.add_dependency 'rspec', '~> 3.0' # This framework is designed to work with RSpec
|
45
46
|
spec.add_dependency 'rspec-its'
|
46
47
|
spec.add_dependency 'savon', '>= 2' # SOAP
|
47
|
-
|
48
|
-
# Only affects Ruby < 2.4
|
49
|
-
spec.add_dependency 'sinatra', '2.0.4'
|
48
|
+
spec.add_dependency 'sinatra', '>= 2.0.4'
|
50
49
|
spec.add_dependency 'sinatra-basic-auth'
|
51
50
|
spec.add_dependency 'sinatra-docdsl'
|
52
51
|
spec.add_dependency 'thor'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soaspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SamuelGarrattIQA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,20 +122,6 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '12.0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: require_all
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - '='
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: 1.5.0
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - '='
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: 1.5.0
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: rspec
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -276,6 +262,34 @@ dependencies:
|
|
276
262
|
- - ">="
|
277
263
|
- !ruby/object:Gem::Version
|
278
264
|
version: '0'
|
265
|
+
- !ruby/object:Gem::Dependency
|
266
|
+
name: pry
|
267
|
+
requirement: !ruby/object:Gem::Requirement
|
268
|
+
requirements:
|
269
|
+
- - ">="
|
270
|
+
- !ruby/object:Gem::Version
|
271
|
+
version: '0'
|
272
|
+
type: :runtime
|
273
|
+
prerelease: false
|
274
|
+
version_requirements: !ruby/object:Gem::Requirement
|
275
|
+
requirements:
|
276
|
+
- - ">="
|
277
|
+
- !ruby/object:Gem::Version
|
278
|
+
version: '0'
|
279
|
+
- !ruby/object:Gem::Dependency
|
280
|
+
name: require_all
|
281
|
+
requirement: !ruby/object:Gem::Requirement
|
282
|
+
requirements:
|
283
|
+
- - ">="
|
284
|
+
- !ruby/object:Gem::Version
|
285
|
+
version: 1.5.0
|
286
|
+
type: :runtime
|
287
|
+
prerelease: false
|
288
|
+
version_requirements: !ruby/object:Gem::Requirement
|
289
|
+
requirements:
|
290
|
+
- - ">="
|
291
|
+
- !ruby/object:Gem::Version
|
292
|
+
version: 1.5.0
|
279
293
|
- !ruby/object:Gem::Dependency
|
280
294
|
name: rest-client
|
281
295
|
requirement: !ruby/object:Gem::Requirement
|
@@ -336,14 +350,14 @@ dependencies:
|
|
336
350
|
name: sinatra
|
337
351
|
requirement: !ruby/object:Gem::Requirement
|
338
352
|
requirements:
|
339
|
-
- -
|
353
|
+
- - ">="
|
340
354
|
- !ruby/object:Gem::Version
|
341
355
|
version: 2.0.4
|
342
356
|
type: :runtime
|
343
357
|
prerelease: false
|
344
358
|
version_requirements: !ruby/object:Gem::Requirement
|
345
359
|
requirements:
|
346
|
-
- -
|
360
|
+
- - ">="
|
347
361
|
- !ruby/object:Gem::Version
|
348
362
|
version: 2.0.4
|
349
363
|
- !ruby/object:Gem::Dependency
|
@@ -522,7 +536,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
522
536
|
version: '0'
|
523
537
|
requirements: []
|
524
538
|
rubyforge_project:
|
525
|
-
rubygems_version: 2.
|
539
|
+
rubygems_version: 2.7.3
|
526
540
|
signing_key:
|
527
541
|
specification_version: 4
|
528
542
|
summary: Helps to create tests for 'SOAP' or 'REST' apis
|