Module: Webspicy
- Defined in:
- lib/webspicy.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/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/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/specification/post.rb,
lib/webspicy/web/client/support.rb,
lib/webspicy/configuration/scope.rb,
lib/webspicy/support/data_object.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/client/http_client.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/specification/file_upload.rb,
lib/webspicy/tester/reporter/composite.rb,
lib/webspicy/tester/reporter/exceptions.rb,
lib/webspicy/specification/oldies/bridge.rb,
lib/webspicy/tester/reporter/error_count.rb,
lib/webspicy/web/client/rack_test_client.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/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/pre/global_request_headers.rb,
lib/webspicy/specification/post/missing_condition_impl.rb,
lib/webspicy/specification/pre/robust_to_invalid_input.rb,
lib/webspicy/specification/post/unexpected_condition_impl.rb
Defined Under Namespace
Modules: Support, Version, Web Classes: Configuration, Error, Specification, Tester, TimeoutError
Constant Summary collapse
- Client =
Backward compatibility
Tester::Client
- HttpClient =
Web::HttpClient
- RackTestClient =
Web::RackTestClient
- Resource =
Specification- FileUpload =
Specification::FileUpload
- Scope =
Configuration::Scope
- Checker =
Tester::FileChecker
- ROOT_FOLDER =
About folders
Path.backfind('.[Gemfile]')
- EXAMPLES_FOLDER =
ROOT_FOLDER/('examples')
- DEFAULT_SYSTEM =
Finitio.system("@import webspicy/scalars\n")
- FORMALDOC =
Finitio.system(Path.dir/("webspicy/formaldoc.fio"))
- PASSTHROUGH_EXCEPTIONS =
Exceptions that we let pass during testing
[NoMemoryError, SignalException, SystemExit]
- LOGGER =
Logging facade
::Logger.new(STDOUT)
- VERSION =
"#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"- Precondition =
module Specification
Specification::Precondition
- Postcondition =
Specification::Postcondition
Class Method Summary collapse
-
.current_scope ⇒ Object
Returns the current scope or a default one is none has been previously installed using ‘set_current_scope` or `with_scope`.
- .debug(*args, &bl) ⇒ Object
-
.default_scope ⇒ Object
Returns a default scope instance.
- .fatal(*args, &bl) ⇒ Object
- .handle_finitio_error(ex, scope) ⇒ Object
- .info(*args, &bl) ⇒ Object
-
.schema(fio) ⇒ Object
Parses a webservice schema (typically input or output) in the context of the current scope previously installed using ‘with_scope`.
- .service(raw, scope = default_scope) ⇒ Object
-
.set_current_scope(scope) ⇒ Object
Sets the current scope.
- .specification(raw, file = nil, scope = default_scope) ⇒ Object
- .test_case(raw, scope = default_scope) ⇒ Object
-
.with_scope(scope) ⇒ Object
Yields the block after having installed ‘scope` globally.
Class Method Details
.current_scope ⇒ Object
Returns the current scope or a default one is none has been previously installed using ‘set_current_scope` or `with_scope`
131 132 133 |
# File 'lib/webspicy.rb', line 131 def current_scope Thread.current[:webspicy_scope] || default_scope end |
.debug(*args, &bl) ⇒ Object
178 179 180 |
# File 'lib/webspicy.rb', line 178 def debug(*args, &bl) LOGGER && LOGGER.debug(*args, &bl) end |
.default_scope ⇒ Object
Returns a default scope instance.
64 65 66 |
# File 'lib/webspicy.rb', line 64 def default_scope Configuration::Scope.new(Configuration.new) end |
.fatal(*args, &bl) ⇒ Object
183 184 185 |
# File 'lib/webspicy.rb', line 183 def fatal(*args, &bl) LOGGER && LOGGER.fatal(*args, &bl) end |
.handle_finitio_error(ex, scope) ⇒ Object
100 101 102 103 104 105 |
# File 'lib/webspicy.rb', line 100 def handle_finitio_error(ex, scope) # msg = "#{ex.message}:\n #{ex.root_cause.message}" # msg = Support::Colorize.colorize_error(msg, scope.config) # fatal(msg) raise end |
.info(*args, &bl) ⇒ Object
173 174 175 |
# File 'lib/webspicy.rb', line 173 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.
154 155 156 157 158 159 160 |
# File 'lib/webspicy.rb', line 154 def schema(fio) if scope = Thread.current[:webspicy_scope] scope.parse_schema(fio) else DEFAULT_SYSTEM.system(fio) end end |
.service(raw, scope = default_scope) ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/webspicy.rb', line 82 def service(raw, scope = default_scope) with_scope(scope) do FORMALDOC["Service"].dress(raw) end rescue Finitio::Error => ex handle_finitio_error(ex) end |
.set_current_scope(scope) ⇒ Object
Sets the current scope.
This method is considered private and should not be used outside of Webspicy itself.
142 143 144 |
# File 'lib/webspicy.rb', line 142 def set_current_scope(scope) Thread.current[:webspicy_scope] = scope end |
.specification(raw, file = nil, scope = default_scope) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/webspicy.rb', line 69 def specification(raw, file = nil, scope = default_scope) raw = YAML.load(raw) if raw.is_a?(String) with_scope(scope) do r = FORMALDOC["Specification"].dress(raw) r.config = scope.config r.located_at!(file) if file r end rescue Finitio::Error => ex handle_finitio_error(ex, scope) end |
.test_case(raw, scope = default_scope) ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/webspicy.rb', line 91 def test_case(raw, scope = default_scope) with_scope(scope) do FORMALDOC["TestCase"].dress(raw) end rescue Finitio::Error => ex handle_finitio_error(ex) 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.
119 120 121 122 123 124 |
# File 'lib/webspicy.rb', line 119 def with_scope(scope) scope = set_current_scope(scope) result = yield scope set_current_scope(nil) result end |