Module: Snails::Harness
- Defined in:
- runtime/snails/harness.rbs,
runtime/snails/harness.rb,
runtime/snails/harness.rb
Defined Under Namespace
Classes: IntegrationTest, Response, SkipSignal
Constant Summary collapse
- MAIL_LOG_PATH =
The mail capture sink, relative to this target's cwd: the runner executes cases in
harness/, directly under the spin root, so this resolves to the root'stmp/mail-capture.jsonl— the file the server's DeliveryLog writes in test mode from the same anchor. The gate empties the file before boot, so it holds one run's deliveries; without a gate the file is absent and the helpers answer empty. "../tmp/mail-capture.jsonl"
Class Method Summary collapse
-
.file_selected? ⇒ Boolean
the bundle dispatch gate the case macro reads.
-
.request(method, path, base_url, params, headers, as) ⇒ Response
one real HTTP request to the running server.
Class Method Details
.file_selected? ⇒ Boolean
the bundle dispatch gate the case macro reads. The bundle runner compiles
every case file into one binary and runs it once per file, so each process
must run only the file it was started for: the entry writes
$spin_test_file = <index> before each file's require (require order is
the runner's index order) and the process env names the selected index.
Without the env (a plain spin test <file>) every file runs — the
single-file path.
103 104 105 106 107 108 |
# File 'runtime/snails/harness.rb', line 103 def self.file_selected? return true if ENV["SPIN_TEST_BUNDLE"].to_s == "" file = $spin_test_file file = 0 if file.nil? file == ENV["SPIN_TEST_INDEX"].to_i end |
.request(method, path, base_url, params, headers, as) ⇒ Response
one real HTTP request to the running server.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'runtime/snails/harness.rb', line 53 def self.request(method, path, base_url, params, headers, as) uri = URI(base_url) target = path.dup if params && method == :get query = URI.encode_www_form(params) target += (target.include?("?") ? "&" : "?") + query end http = Net::HTTP.new(uri.host, uri.port) req = request_object(method, target) headers.each { |k, v| req[k] = v } unless headers.nil? if params && method != :get if as == :json req["Content-Type"] = "application/json" req.body = JSON.generate(params) else req.set_form_data(params) end end res = http.request(req) Response.new(res.code.to_i, res.body, res) end |