varar-rspec 0.8.0 → 0.8.1
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 +4 -4
- data/lib/varar/rspec.rb +38 -7
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dd1931c8d54abf4bdaae28a8e8f136e3d6991b03ba6cf1a22cc49d5f658c8bfe
|
|
4
|
+
data.tar.gz: 0dd3622959aa6b187cc593223850229ab598fd0870c24f943f87e4779b8d31c8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cc553518b90a17dc6bd813462ccdea3bd1a4f004b1dc0cd6ec1de78c4879522eb3e6c55c73964f4cbbfed577dd8c7cedda22b12955756a9f60b2dcb3362674ef
|
|
7
|
+
data.tar.gz: 5a38ebeb4b9cfb4c78bf3ebd54327875f509ca74dc0de2926f8f1ae45daf59f98365b61d8389d8348817193c4bea8fca014e5e1ab0df91bd937fc86f13a472a5
|
data/lib/varar/rspec.rb
CHANGED
|
@@ -12,7 +12,7 @@ module Varar
|
|
|
12
12
|
# require "varar/rspec"
|
|
13
13
|
# Varar::RSpec.generate
|
|
14
14
|
module RSpec
|
|
15
|
-
VERSION = '0.8.
|
|
15
|
+
VERSION = '0.8.1'
|
|
16
16
|
|
|
17
17
|
module_function
|
|
18
18
|
|
|
@@ -36,21 +36,52 @@ module Varar
|
|
|
36
36
|
# everything.
|
|
37
37
|
Core::Drifts.prune_baselines(store, oaths.map { |p| Runner.rel_posix(p, root) }, update: update)
|
|
38
38
|
|
|
39
|
+
workspace = project_workspace(oaths, root)
|
|
40
|
+
|
|
39
41
|
oaths.each do |oath_path|
|
|
40
|
-
define_group(oath_path, root, loaded, store, update, results)
|
|
42
|
+
define_group(oath_path, root, loaded, store, update, results, workspace)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Whether a section is a standalone example depends on whether another oath
|
|
47
|
+
# references it, which is whole-project knowledge (ADR 0016). Built from the
|
|
48
|
+
# config globs — the full set, for the same reason baseline pruning is.
|
|
49
|
+
# The sources of every oath this plan's steps were spliced in from (ADR
|
|
50
|
+
# 0016). Their hashes go in the run record, so a consumer can tell a stale
|
|
51
|
+
# failure from a live one.
|
|
52
|
+
def referenced_sources(plan, workspace)
|
|
53
|
+
plan.examples.flat_map { |ex| ex.steps.map(&:doc_path) }.compact.uniq.each_with_object({}) do |path, out|
|
|
54
|
+
doc = workspace.docs[path]
|
|
55
|
+
out[path] = doc.source if doc
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def project_workspace(oaths, root)
|
|
60
|
+
docs = oaths.filter_map do |path|
|
|
61
|
+
Core::Parse.parse(Runner.rel_posix(path, root), File.read(path, encoding: 'UTF-8'))
|
|
62
|
+
rescue SystemCallError
|
|
63
|
+
nil
|
|
41
64
|
end
|
|
65
|
+
Core::Reference.build_workspace(docs)
|
|
42
66
|
end
|
|
43
67
|
|
|
44
|
-
def define_group(oath_path, root, loaded, store, update, results)
|
|
68
|
+
def define_group(oath_path, root, loaded, store, update, results, workspace)
|
|
45
69
|
rel = Runner.rel_posix(oath_path, root)
|
|
46
70
|
source = File.read(oath_path, encoding: 'UTF-8')
|
|
47
|
-
|
|
71
|
+
# `rel`, not the basename: doc.path is an oath's identity in every port,
|
|
72
|
+
# so a relative reference resolves alike and two same-named oaths in
|
|
73
|
+
# different directories stay distinct (ADR 0016).
|
|
74
|
+
plan = Runner.plan_oath(rel, source, loaded.registry, workspace)
|
|
75
|
+
referenced = referenced_sources(plan, workspace)
|
|
48
76
|
pairs = Runner.examples_with_runs(plan, loaded.create_context, Runner::RecordingReporter.new)
|
|
49
77
|
drifts = Core::Drifts.reconcile_drift(store, rel, source, plan.doc, plan, update: update)
|
|
50
78
|
|
|
51
79
|
::RSpec.describe(rel) do
|
|
52
80
|
pairs.each do |example, run|
|
|
53
|
-
|
|
81
|
+
# Lines in THIS oath: a step a reference block spliced in from
|
|
82
|
+
# another oath (ADR 0016) contributes none, since its line is not in
|
|
83
|
+
# this file.
|
|
84
|
+
lines = example.steps.reject(&:doc_path).map { |s| s.match_span.start_line }.uniq
|
|
54
85
|
# A var diff surfaces as a failure carrying the span-anchored render;
|
|
55
86
|
# any other exception propagates. RSpec reports both as failures.
|
|
56
87
|
it(example.name) do
|
|
@@ -61,14 +92,14 @@ module Varar
|
|
|
61
92
|
results.record(rel, source, Core::ExampleResult.new(
|
|
62
93
|
name: example.name, status: 'failed', lines: lines,
|
|
63
94
|
failure: Core::Failures.to_failure(e, rel, lines.first || 0)
|
|
64
|
-
))
|
|
95
|
+
), referenced)
|
|
65
96
|
raise Runner.render_failure(e, source, rel) if RSpec.var_diff_error?(e)
|
|
66
97
|
|
|
67
98
|
raise
|
|
68
99
|
else
|
|
69
100
|
results.record(rel, source, Core::ExampleResult.new(
|
|
70
101
|
name: example.name, status: 'passed', lines: lines, failure: nil
|
|
71
|
-
))
|
|
102
|
+
), referenced)
|
|
72
103
|
end
|
|
73
104
|
end
|
|
74
105
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: varar-rspec
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aslak Hellesøy
|
|
@@ -29,14 +29,14 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - '='
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 0.8.
|
|
32
|
+
version: 0.8.1
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - '='
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 0.8.
|
|
39
|
+
version: 0.8.1
|
|
40
40
|
description: 'RSpec adapter: one selectable example per Markdown example, with a drift
|
|
41
41
|
gate.'
|
|
42
42
|
email:
|