soaspec 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3dc517686970c428dfdc01fbd10939e89a051e4b1748167341d2f7c276416f88
4
- data.tar.gz: '08359bd7b82c35d4e4559f182a8968c8dc7e79b5a4d44270edcf21f56f249623'
3
+ metadata.gz: 6d04d8069ff220fabc590725f88eb322d1346067c16efcdd007d235b55ac2d20
4
+ data.tar.gz: b7391039e8f3dd04845b49bba4fba4ca2d50dd444c088ceabc7f515907c2949c
5
5
  SHA512:
6
- metadata.gz: 82578194b7b967d3f9eefa3e0b0646568be998a346cf5579e95de904dadf2ba0c7b2b55816a15319ca2c0ca4353747c1628ddfe78d47dfd798d8a797d0d02fc9
7
- data.tar.gz: 0d28e2326ca767e0670eae5b3ec2fe61a46376bd45f48b53d4980746d11f292211563929641decadf198888f2e2ab5b83bb3f88ad69b7e1e370900c75d2782e7
6
+ metadata.gz: b0ef8082d8e1e24576a0ea9bb9e477e33764a135b994d26e4a52a6a1366f57e8e3e89cb7d22f64914abbac27bce5c04ab21b6e1d9ee7703025539875b7187769
7
+ data.tar.gz: c984d69e28910e13171cd588ee98f363f0186b0d46b9ee8144a05964d7089054308f4017d4842ee7b064d25661b42c02d8a69fbf1c7a4c3e23106481819cdb61
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ Version 0.3.2
2
+ * Enhancement
3
+ * Handle 'html' format
4
+
1
5
  Version 0.3.1
2
6
  * Bug fix
3
7
  * Should create logs folder for hosting virtual server's error logs
@@ -79,9 +79,10 @@ module Soaspec
79
79
 
80
80
  desc 'generate', 'Generate initial test code from wsdl'
81
81
  long_desc <<-LONGDESC
82
- If no wsdl is given a server will be started from which code to generate Exchanges
82
+ If no wsdl is given a server will be started with a web page front end from which ExchangeHandler's can
83
+ can be created.
83
84
 
84
- `soaspec generate wsdl=wsdl name=ServiceName ` will generate the initial files and folders to test each operation in a wsdl
85
+ `soaspec generate wsdl=wsdl name=ServiceName` will generate the initial files and folders to test each operation in a wsdl
85
86
  \x5
86
87
  Additionally the auth parameter can be used to use basic authentication to retrieve the WSDL.
87
88
  To do use the following `soaspec generate --auth=basic`
@@ -193,7 +193,7 @@ module Soaspec
193
193
  # @return [Enumerable] Value inside element found through Xpath
194
194
  def xpath_elements_for(response: nil, xpath: nil, attribute: nil)
195
195
  raise ArgumentError unless response && xpath
196
- raise "Can't perform XPATH if response is not XML" unless Interpreter.response_type_for(response) == :xml
196
+ raise "Can't perform XPATH if response is not XML" unless %i[xml html].include? Interpreter.response_type_for(response)
197
197
 
198
198
  xpath = prefix_xpath(xpath, attribute)
199
199
  temp_doc = Nokogiri.parse(response.body).dup
@@ -239,7 +239,7 @@ module Soaspec
239
239
  def value_from_path(response, path, attribute: nil)
240
240
  path = path.to_s
241
241
  case Interpreter.response_type_for(response)
242
- when :xml
242
+ when :xml, :html
243
243
  result = xpath_elements_for(response: response, xpath: path, attribute: attribute).first
244
244
  raise NoElementAtPath, "No value at Xpath '#{prefix_xpath(path, attribute)}' in '#{response.body}'" unless result
245
245
  return result.inner_text if attribute.nil?
@@ -20,6 +20,8 @@ class Interpreter
20
20
  :xml
21
21
  elsif json?
22
22
  :json
23
+ elsif html?
24
+ :html
23
25
  else
24
26
  :string
25
27
  end
@@ -54,6 +56,18 @@ class Interpreter
54
56
  # @return [Boolean] Whether valid XML
55
57
  def xml?
56
58
  Nokogiri::XML(@response) { |config| config.options = Nokogiri::XML::ParseOptions::STRICT }
59
+ true
60
+ rescue Nokogiri::XML::SyntaxError => e
61
+ self.xml_errors = e
62
+ false
63
+ end
64
+
65
+ # @return [Boolean] Whether valid HTML. Must include at least one tag
66
+ def html?
67
+ Nokogiri::HTML(@response) do |config|
68
+ config.options = Nokogiri::XML::ParseOptions::DEFAULT_HTML
69
+ end
70
+ @response.include?('<') && @response.include?('>')
57
71
  rescue Nokogiri::XML::SyntaxError => e
58
72
  self.xml_errors = e
59
73
  false
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Soaspec
4
4
  # @return [String] Version of the gem
5
- VERSION = '0.3.1'
5
+ VERSION = '0.3.2'
6
6
  end
@@ -189,5 +189,18 @@ module Soaspec
189
189
  }
190
190
  BOOKS
191
191
  end
192
+
193
+ documentation 'HTML doc that is not valid HTML'
194
+ get '/html_doc' do
195
+ <<-HTML
196
+ <!doctype html>
197
+ <html lang="en">
198
+ <head></head>
199
+ <body>
200
+ <h1>Heading</h1>
201
+ </body>
202
+ </html>
203
+ HTML
204
+ end
192
205
  end
193
206
  end
@@ -7,10 +7,12 @@ module Soaspec
7
7
 
8
8
  # Generate from WSDL
9
9
  def generate_from_wsdl(options)
10
- auth_name, auth_password = enter_auth_details if options[:auth] == 'basic'
10
+ if options[:auth] == 'basic'
11
+ auth_name, auth_password = enter_auth_details
12
+ savon_options[:basic_auth] = [auth_name, auth_password]
13
+ end
11
14
  @virtual = false
12
15
  savon_options = { wsdl: options[:wsdl] }
13
- savon_options[:basic_auth] = [auth_name, auth_password] if options[:auth] == 'basic'
14
16
 
15
17
  wsdl_doc = Savon.client(**savon_options).wsdl
16
18
  @wsdl_schemas = wsdl_doc.parser.schemas
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.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - SamuelGarrattIQA
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-24 00:00:00.000000000 Z
11
+ date: 2019-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler