exe/soaspec in soaspec-0.2.18 vs exe/soaspec in soaspec-0.2.19

- old
+ new

@@ -63,57 +63,33 @@ content: retrieve_contents(File.join('../cucumber', 'generic_steps.rb'), false) end desc 'generate', 'Generate initial test code from wsdl' long_desc <<-LONGDESC + If no wsdl is given a server will be started from which code to generate Exchanges + `soaspec generate wsdl=wsdl name=ServiceName ` will generate the initial files and folders to test each operation in a wsdl \x5 Additionally the auth parameter can be used to use basic authentication to retrieve the WSDL. To do use the following `soaspec generate --auth=basic` Note: This is still a work in progress and will only work for a very simple wsdl LONGDESC - option :wsdl, required: true, aliases: :w + option :wsdl, default: nil, aliases: :w option :name, default: 'Service', aliases: :n option :ci, default: 'jenkins', banner: 'What Continuous Integration is used' option :auth + option :open_browser, default: 'true' option :string_default, default: 'test string' def generate - enter_auth_details if options[:auth] == 'basic' - @virtual = false - savon_options = { wsdl: options[:wsdl] } - savon_options[:basic_auth] = [@auth_name, @auth_password] if options[:auth] == 'basic' - - @wsdl_doc = Savon.client(**savon_options).wsdl - @wsdl_schemas = @wsdl_doc.parser.schemas - - create_files %w[Rakefile Gemfile README.md spec/spec_helper.rb], ignore_if_present: true - create_file(filename: '.rspec') - create_file(filename: '.travis.yml') if options[:ci] == 'travis' - create_folder 'logs' - create_file filename: "lib/#{options[:name].snakecase}.rb", content: class_content - - # Files according to WSDL - @wsdl_doc.operations.each do |operation, op_details| - puts "Creating files for operation: #{operation}" - @content = "default:\n" - @use_camel_case = false - puts 'Message params: ' + op_details.to_s - # From namespace identifier, find namespace, and for that find schemaLocation xsd and use that to build request - if op_details[:parameters] - op_details[:parameters].each do |element, details| - @use_camel_case = true unless /[[:upper:]]/.match(element.to_s[0]).nil? - @content += " #{element.to_s.snakecase}: #{fill_in_field_from_type(details[:type])} # #{details[:type]} \n" - # TODO: If details is a Hash need to loop again - end + if options[:wsdl] + generate_from_wsdl(options) + else + require 'launchy' + require 'soaspec/generate_server' + Soaspec::GenerateServer.run! do + sleep 2 + Launchy.open 'http://localhost:8999' if options[:open_browser] == 'true' end - wsdl_to_yaml_for root_elements_for(op_details) - params = [] - params << 'convert_request_keys_to: :camelcase' if @use_camel_case - params_string = params == [] ? '' : ', ' + params.join(', ') - @class_params = "'#{camel_case(operation)}'#{params_string}" - - create_file(filename: "config/data/#{operation}.yml", content: @content) - create_file(filename: "spec/#{operation}_spec.rb", content: generated_soap_spec_for(operation)) end end long_desc <<-LONGDESC Run virtual web services on localhost. See root for documentation of web services provided.