oselvar-var-rspec 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/oselvar/var/rspec.rb +66 -0
- metadata +74 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: da1add0685800dbb76fd61693e66a8fed8f36f7ac7a5ed31456ff21140cc550c
|
|
4
|
+
data.tar.gz: 7886ee80bca5c9734505b93aba054ef5fa2e6c28bc8fd9dbf6cda453508458fe
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: c33709eda5f2e0b16ca0376cd6d96bc005e2161830cc5981997b32fc091f9c398c27b4125c6d00e40b4435d4df77ba80d602106199aa9068abd8e1d70f488801
|
|
7
|
+
data.tar.gz: f9a650736444fea8835e58fe03eb307be86d278b5e7dac89535ca18421c28f7684a912a059f81cb70eb9d7342d3fc91536307181f6cbf4e0bc399d8a878f7558
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rspec/core'
|
|
4
|
+
require 'oselvar/var/runner'
|
|
5
|
+
|
|
6
|
+
module Oselvar
|
|
7
|
+
module Var
|
|
8
|
+
# RSpec adapter. One call defines an RSpec example group per spec matched by
|
|
9
|
+
# var.config.json, with one `it` per Markdown example (header-bound rows are
|
|
10
|
+
# separate examples) and a drift gate. See ADR 0005.
|
|
11
|
+
#
|
|
12
|
+
# # spec/var_spec.rb
|
|
13
|
+
# require "oselvar/var/rspec"
|
|
14
|
+
# Oselvar::Var::RSpec.generate
|
|
15
|
+
module RSpec
|
|
16
|
+
VERSION = '0.3.2'
|
|
17
|
+
|
|
18
|
+
module_function
|
|
19
|
+
|
|
20
|
+
def generate(root: nil)
|
|
21
|
+
root ||= File.dirname(caller_locations(1, 1).first.path)
|
|
22
|
+
root = File.expand_path(root)
|
|
23
|
+
cfg = Config.read_var_config(root)
|
|
24
|
+
loaded = Runner.load_steps(cfg.steps, root)
|
|
25
|
+
store = Runner.create_file_baseline_store(root)
|
|
26
|
+
update = %w[1 true].include?(ENV.fetch('VAR_UPDATE', nil))
|
|
27
|
+
|
|
28
|
+
Runner.find_specs(cfg.docs_include, cfg.docs_exclude, root).each do |spec_path|
|
|
29
|
+
define_group(spec_path, root, loaded, store, update)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def define_group(spec_path, root, loaded, store, update)
|
|
34
|
+
rel = Runner.rel_posix(spec_path, root)
|
|
35
|
+
source = File.read(spec_path, encoding: 'UTF-8')
|
|
36
|
+
plan = Runner.plan_spec(File.basename(spec_path), source, loaded.registry)
|
|
37
|
+
pairs = Runner.examples_with_runs(plan, loaded.create_context, Runner::RecordingReporter.new)
|
|
38
|
+
drifts = Core::Drifts.reconcile_drift(store, rel, source, plan.var_doc, plan, update: update)
|
|
39
|
+
|
|
40
|
+
::RSpec.describe(rel) do
|
|
41
|
+
pairs.each do |example, run|
|
|
42
|
+
# A var diff surfaces as a failure carrying the span-anchored render;
|
|
43
|
+
# any other exception propagates. RSpec reports both as failures.
|
|
44
|
+
it(example.name) do
|
|
45
|
+
run.call
|
|
46
|
+
rescue StandardError => e
|
|
47
|
+
raise Runner.render_failure(e, source, rel) if RSpec.var_diff_error?(e)
|
|
48
|
+
|
|
49
|
+
raise
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
drifts.each do |drift|
|
|
54
|
+
message = Core::Diagnostics.drift_detected(drift.name, drift.span).message
|
|
55
|
+
it("var drift at line #{drift.line}") { raise message }
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def var_diff_error?(error)
|
|
61
|
+
error.is_a?(Core::CellMismatchError) || error.is_a?(Core::DocStringMismatchError) ||
|
|
62
|
+
error.is_a?(Core::ReturnShapeError) || error.is_a?(Core::UnexpectedPassError)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: oselvar-var-rspec
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.3.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Aslak Hellesøy
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-07-07 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: oselvar-var-runner
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - '='
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 0.3.2
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - '='
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 0.3.2
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rspec-core
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '3.13'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '3.13'
|
|
41
|
+
description: 'RSpec adapter: one selectable example per Markdown example, with a drift
|
|
42
|
+
gate.'
|
|
43
|
+
email:
|
|
44
|
+
- aslak@oselvar.com
|
|
45
|
+
executables: []
|
|
46
|
+
extensions: []
|
|
47
|
+
extra_rdoc_files: []
|
|
48
|
+
files:
|
|
49
|
+
- lib/oselvar/var/rspec.rb
|
|
50
|
+
homepage: https://var.oselvar.com
|
|
51
|
+
licenses:
|
|
52
|
+
- MIT
|
|
53
|
+
metadata:
|
|
54
|
+
rubygems_mfa_required: 'true'
|
|
55
|
+
post_install_message:
|
|
56
|
+
rdoc_options: []
|
|
57
|
+
require_paths:
|
|
58
|
+
- lib
|
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
60
|
+
requirements:
|
|
61
|
+
- - ">="
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: '3.2'
|
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
requirements: []
|
|
70
|
+
rubygems_version: 3.4.10
|
|
71
|
+
signing_key:
|
|
72
|
+
specification_version: 4
|
|
73
|
+
summary: Markdown-native BDD — run Markdown specs as RSpec examples
|
|
74
|
+
test_files: []
|