Module: Webspicy

Defined in:
lib/webspicy.rb,
lib/webspicy/web.rb,
lib/webspicy/tester.rb,
lib/webspicy/support.rb,
lib/webspicy/version.rb,
lib/webspicy/web/client.rb,
lib/webspicy/web/mocker.rb,
lib/webspicy/web/inferer.rb,
lib/webspicy/configuration.rb,
lib/webspicy/specification.rb,
lib/webspicy/support/hooks.rb,
lib/webspicy/support/world.rb,
lib/webspicy/tester/client.rb,
lib/webspicy/tester/result.rb,
lib/webspicy/tester/failure.rb,
lib/webspicy/tester/fakeses.rb,
lib/webspicy/web/invocation.rb,
lib/webspicy/tester/asserter.rb,
lib/webspicy/tester/fakesmtp.rb,
lib/webspicy/tester/reporter.rb,
lib/webspicy/web/openapi/ext.rb,
lib/webspicy/support/colorize.rb,
lib/webspicy/specification/err.rb,
lib/webspicy/specification/pre.rb,
lib/webspicy/tester/assertions.rb,
lib/webspicy/tester/invocation.rb,
lib/webspicy/web/specification.rb,
lib/webspicy/specification/post.rb,
lib/webspicy/support/deep_merge.rb,
lib/webspicy/web/client/support.rb,
lib/webspicy/configuration/scope.rb,
lib/webspicy/support/data_object.rb,
lib/webspicy/tester/fakesendgrid.rb,
lib/webspicy/tester/file_checker.rb,
lib/webspicy/tester/result/check.rb,
lib/webspicy/support/status_range.rb,
lib/webspicy/tester/fakeses/email.rb,
lib/webspicy/specification/service.rb,
lib/webspicy/tester/fakesmtp/email.rb,
lib/webspicy/web/openapi/generator.rb,
lib/webspicy/web/specification/pre.rb,
lib/webspicy/web/client/http_client.rb,
lib/webspicy/web/specification/post.rb,
lib/webspicy/specification/condition.rb,
lib/webspicy/specification/test_case.rb,
lib/webspicy/tester/reporter/summary.rb,
lib/webspicy/configuration/single_url.rb,
lib/webspicy/tester/reporter/progress.rb,
lib/webspicy/tester/result/assert_met.rb,
lib/webspicy/tester/fakesendgrid/email.rb,
lib/webspicy/tester/reporter/composite.rb,
lib/webspicy/web/specification/service.rb,
lib/webspicy/tester/reporter/exceptions.rb,
lib/webspicy/specification/oldies/bridge.rb,
lib/webspicy/web/client/rack_test_client.rb,
lib/webspicy/web/specification/test_case.rb,
lib/webspicy/tester/reporter/file_summary.rb,
lib/webspicy/configuration/single_yml_file.rb,
lib/webspicy/tester/reporter/documentation.rb,
lib/webspicy/tester/reporter/file_progress.rb,
lib/webspicy/web/specification/file_upload.rb,
lib/webspicy/tester/reporter/junit_xml_file.rb,
lib/webspicy/tester/reporter/success_or_not.rb,
lib/webspicy/tester/result/errcondition_met.rb,
lib/webspicy/tester/result/error_schema_met.rb,
lib/webspicy/tester/result/output_schema_met.rb,
lib/webspicy/tester/result/postcondition_met.rb,
lib/webspicy/specification/oldies/errcondition.rb,
lib/webspicy/specification/oldies/precondition.rb,
lib/webspicy/tester/result/response_header_met.rb,
lib/webspicy/tester/result/response_status_met.rb,
lib/webspicy/specification/oldies/postcondition.rb,
lib/webspicy/tester/result/invocation_succeeded.rb,
lib/webspicy/specification/post/missing_condition_impl.rb,
lib/webspicy/specification/post/unexpected_condition_impl.rb,
lib/webspicy/web/specification/post/etag_caching_protocol.rb,
lib/webspicy/web/specification/pre/global_request_headers.rb,
lib/webspicy/web/specification/pre/robust_to_invalid_input.rb,
lib/webspicy/web/specification/post/last_modified_caching_protocol.rb,
lib/webspicy/web/specification/post/semantics_preserved_by_refactoring.rb

Defined Under Namespace

Modules: Support, Version, Web Classes: Configuration, Error, Specification, Tester, TimeoutError

Constant Summary collapse

ROOT_FOLDER =

About folders

Path.backfind('.[Gemfile]')
EXAMPLES_FOLDER =
ROOT_FOLDER/('examples')
DEFAULT_SYSTEM =
Finitio.system(<<~FIO)
  @import webspicy/scalars
FIO
PASSTHROUGH_EXCEPTIONS =

Exceptions that we let pass during testing

[NoMemoryError, SignalException, SystemExit]
LOGGER =

Logging facade

::Logger.new(STDOUT)
Client =

Backward compatibility

Tester::Client
HttpClient =
Web::HttpClient
RackTestClient =
Web::RackTestClient
Resource =
Specification
FileUpload =
Web::Specification::FileUpload
Scope =
Configuration::Scope
Checker =
Tester::FileChecker
VERSION =
"#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
Precondition =

module Specification

Specification::Precondition
Postcondition =
Specification::Postcondition

Class Method Summary collapse

Class Method Details

.current_scopeObject

Returns the current scope or a default one is none has been previously installed using ‘set_current_scope` or `with_scope`



82
83
84
# File 'lib/webspicy.rb', line 82

def current_scope
  Thread.current[:webspicy_scope] || default_scope
end

.debug(*args, &bl) ⇒ Object



129
130
131
# File 'lib/webspicy.rb', line 129

def debug(*args, &bl)
  LOGGER && LOGGER.debug(*args, &bl)
end

.default_scopeObject

Returns a default scope instance.



54
55
56
# File 'lib/webspicy.rb', line 54

def default_scope
  Configuration::Scope.new(Configuration.new)
end

.fatal(*args, &bl) ⇒ Object



134
135
136
# File 'lib/webspicy.rb', line 134

def fatal(*args, &bl)
  LOGGER && LOGGER.fatal(*args, &bl)
end

.info(*args, &bl) ⇒ Object



124
125
126
# File 'lib/webspicy.rb', line 124

def info(*args, &bl)
  LOGGER && LOGGER.info(*args, &bl)
end

.schema(fio) ⇒ Object

Parses a webservice schema (typically input or output) in the context of the current scope previously installed using ‘with_scope`.

If no scope has previously been installed, Finitio’s default system is used instead of another schema.



105
106
107
108
109
110
111
# File 'lib/webspicy.rb', line 105

def schema(fio)
  if scope = Thread.current[:webspicy_scope]
    scope.parse_schema(fio)
  else
    DEFAULT_SYSTEM.system(fio)
  end
end

.set_current_scope(scope) ⇒ Object

Sets the current scope.

This method is considered private and should not be used outside of Webspicy itself.



93
94
95
# File 'lib/webspicy.rb', line 93

def set_current_scope(scope)
  Thread.current[:webspicy_scope] = scope
end

.with_scope(scope) ⇒ Object

Yields the block after having installed ‘scope` globally.

This method makes sure that the scope will also be accessible for Finitio world schema parsing/dressing. Given that some global state is required (see “Schema” ADT, the dresser in particular, which calls ‘schema` later), the scope is put as a thread-local variable…

This method is considered private and should not be used outside of Webspicy itself.



70
71
72
73
74
75
# File 'lib/webspicy.rb', line 70

def with_scope(scope)
  scope = set_current_scope(scope)
  result = yield scope
  set_current_scope(nil)
  result
end