lib/soaspec.rb in soaspec-0.1.1 vs lib/soaspec.rb in soaspec-0.1.2

- old
+ new

@@ -1,91 +1,91 @@ -require 'rest-client' # REST -require 'erb' # Embedded ruby -require 'yaml' # Reading yaml -require 'rspec' # Testing framework -require 'rspec/its' -require 'savon' # SOAP -require 'nokogiri' # XPath -require 'date' -require 'jsonpath' - -require 'soaspec/version' -require 'soaspec/exchange_handlers/soap_handler' -require 'soaspec/exchange_handlers/exchange_handler' -require 'soaspec/exchange_handlers/rest_methods' -require 'soaspec/exchange' -require 'soaspec/matchers' -require 'soaspec/soaspec_shared_examples' -require 'soaspec/core_ext/hash' -require 'soaspec/spec_logger' -require 'soaspec/exe_helpers' -require 'soaspec/exchange_handlers/rest_handler' -require 'soaspec/exchange_handlers/handler_accessors' -require 'soaspec/interpreter' -require 'soaspec/not_found_errors' -require 'soaspec/test_server/get_bank' -require 'soaspec/test_server/test_attribute' -require 'soaspec/test_server/puppy_service' -require 'soaspec/test_server/invoices' -require 'soaspec/test_server/test_namespace' -require 'soaspec/wsdl_generator' - -# Gem for handling SOAP and REST api tests -module Soaspec - - class << self - # Specify whether to see params sent to and retrieved from oauth. This will put password in log file, only recommended for debugging - attr_writer :debug_oauth - - # Folder used to store credentials - # Used in auth2_file command - # @param [String] folder - def credentials_folder=(folder) - @credentials_folder = folder - end - - # Credentials folder used to store secret data (not in source control) E.g passwords - def credentials_folder - @credentials_folder - end - - # Used so that exchange class knows what context it's in - # @param [ExchangeHandler] handler A class inheriting from Soaspec::ExchangeHandler. Exchange class uses this - def api_handler=(handler) - @api_handler = handler - end - - # Exchange Handler class currently being used - def api_handler - @api_handler - end - - # Set whether to transform strings to keys in request automatically - # @param [Boolean] use_keys - def always_use_keys=(use_keys) - @always_use_keys = use_keys - end - - # @return [Boolean] Whether to transform strings to keys in request automatically - def always_use_keys? - @always_use_keys || true - end - - # @return [Boolean] Whether to see params sent to & received from oauth URL - def debug_oauth? - @debug_oauth || false - end - - # Whether to log all API traffic - def log_api_traffic=(set) - @log_api_traffic = set - RestClient.log = nil unless set - end - - # @return [Boolean] Whether to log all API traffic - def log_api_traffic? - @log_api_traffic.nil? ? true : @log_api_traffic - end - end -end - -RestClient.log = Soaspec::SpecLogger.create +require 'rest-client' # REST +require 'erb' # Embedded ruby +require 'yaml' # Reading yaml +require 'rspec' # Testing framework +require 'rspec/its' +require 'savon' # SOAP +require 'nokogiri' # XPath +require 'date' +require 'jsonpath' + +require 'soaspec/version' +require 'soaspec/exchange_handlers/soap_handler' +require 'soaspec/exchange_handlers/exchange_handler' +require 'soaspec/exchange_handlers/rest_methods' +require 'soaspec/exchange' +require 'soaspec/matchers' +require 'soaspec/soaspec_shared_examples' +require 'soaspec/core_ext/hash' +require 'soaspec/spec_logger' +require 'soaspec/exe_helpers' +require 'soaspec/exchange_handlers/rest_handler' +require 'soaspec/exchange_handlers/handler_accessors' +require 'soaspec/interpreter' +require 'soaspec/not_found_errors' +require 'soaspec/test_server/get_bank' +require 'soaspec/test_server/test_attribute' +require 'soaspec/test_server/puppy_service' +require 'soaspec/test_server/invoices' +require 'soaspec/test_server/test_namespace' +require 'soaspec/wsdl_generator' + +# Gem for handling SOAP and REST api tests +module Soaspec + + class << self + # Specify whether to see params sent to and retrieved from oauth. This will put password in log file, only recommended for debugging + attr_writer :debug_oauth + + # Folder used to store credentials + # Used in auth2_file command + # @param [String] folder + def credentials_folder=(folder) + @credentials_folder = folder + end + + # Credentials folder used to store secret data (not in source control) E.g passwords + def credentials_folder + @credentials_folder + end + + # Used so that exchange class knows what context it's in + # @param [ExchangeHandler] handler A class inheriting from Soaspec::ExchangeHandler. Exchange class uses this + def api_handler=(handler) + @api_handler = handler + end + + # Exchange Handler class currently being used + def api_handler + @api_handler + end + + # Set whether to transform strings to keys in request automatically + # @param [Boolean] use_keys + def always_use_keys=(use_keys) + @always_use_keys = use_keys + end + + # @return [Boolean] Whether to transform strings to keys in request automatically + def always_use_keys? + @always_use_keys || true + end + + # @return [Boolean] Whether to see params sent to & received from oauth URL + def debug_oauth? + @debug_oauth || false + end + + # Whether to log all API traffic + def log_api_traffic=(set) + @log_api_traffic = set + RestClient.log = nil unless set + end + + # @return [Boolean] Whether to log all API traffic + def log_api_traffic? + @log_api_traffic.nil? ? true : @log_api_traffic + end + end +end + +RestClient.log = Soaspec::SpecLogger.create