varar-rspec 0.7.0 → 0.8.0
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 +39 -11
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0a79154b49d4b13d706d22d242f4edd456c061de513d13681be93f6fbfad21ed
|
|
4
|
+
data.tar.gz: 7ec9debe89392c639140b059d2885f477f281d61d7b99174f57a4e4f0592c39a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 66206a596b79c0d267618fdd8c157a3be5eb272405e1ecae5d254e70c4fcf689b5b07a21510ce79ce5efdb50d97ccb77615ab70ecc875b4f5ebfc7c7e6f8e216
|
|
7
|
+
data.tar.gz: a9e7a899eadfddfb6eebb7c0f7a88e527557dea82b093f3cf043863d3503c09e5c0e5b9c421c000fa264b25ab88dd32345b5e2cea8279e38d062c9aa85cdb01a
|
data/lib/varar/rspec.rb
CHANGED
|
@@ -4,48 +4,71 @@ require 'rspec/core'
|
|
|
4
4
|
require 'varar/runner'
|
|
5
5
|
|
|
6
6
|
module Varar
|
|
7
|
-
# RSpec adapter. One call defines an RSpec example group per
|
|
7
|
+
# RSpec adapter. One call defines an RSpec example group per oath matched by
|
|
8
8
|
# varar.config.json, with one `it` per Markdown example (header-bound rows are
|
|
9
9
|
# separate examples) and a drift gate. See ADR 0005.
|
|
10
10
|
#
|
|
11
|
-
# # spec/
|
|
11
|
+
# # spec/varar_spec.rb
|
|
12
12
|
# require "varar/rspec"
|
|
13
13
|
# Varar::RSpec.generate
|
|
14
14
|
module RSpec
|
|
15
|
-
VERSION = '0.
|
|
15
|
+
VERSION = '0.8.0'
|
|
16
16
|
|
|
17
17
|
module_function
|
|
18
18
|
|
|
19
19
|
def generate(root: nil)
|
|
20
20
|
root ||= File.dirname(caller_locations(1, 1).first.path)
|
|
21
21
|
root = File.expand_path(root)
|
|
22
|
-
cfg = Config.
|
|
22
|
+
cfg = Config.read_config(root)
|
|
23
23
|
loaded = Runner.load_steps(cfg.steps, root)
|
|
24
24
|
store = Runner.create_file_baseline_store(root)
|
|
25
25
|
update = %w[1 true].include?(ENV.fetch('VARAR_UPDATE', nil))
|
|
26
26
|
|
|
27
|
-
Runner.
|
|
28
|
-
|
|
27
|
+
oaths = Runner.find_oaths(cfg.docs_include, cfg.docs_exclude, root)
|
|
28
|
+
# Run results for the language server (ADR 0014). RSpec has no per-oath
|
|
29
|
+
# completion hook here, so each group flushes its own oath in after(:all).
|
|
30
|
+
results = Runner::Results.new
|
|
31
|
+
|
|
32
|
+
# Drop baselines for oaths the config no longer discovers. Reconciliation is
|
|
33
|
+
# per-oath and never sees a path that has gone, so the lock would otherwise
|
|
34
|
+
# accumulate dead entries forever (#70). Once per run, keyed off the config
|
|
35
|
+
# globs — which here IS the full set, since generate always discovers
|
|
36
|
+
# everything.
|
|
37
|
+
Core::Drifts.prune_baselines(store, oaths.map { |p| Runner.rel_posix(p, root) }, update: update)
|
|
38
|
+
|
|
39
|
+
oaths.each do |oath_path|
|
|
40
|
+
define_group(oath_path, root, loaded, store, update, results)
|
|
29
41
|
end
|
|
30
42
|
end
|
|
31
43
|
|
|
32
|
-
def define_group(
|
|
33
|
-
rel = Runner.rel_posix(
|
|
34
|
-
source = File.read(
|
|
35
|
-
plan = Runner.
|
|
44
|
+
def define_group(oath_path, root, loaded, store, update, results)
|
|
45
|
+
rel = Runner.rel_posix(oath_path, root)
|
|
46
|
+
source = File.read(oath_path, encoding: 'UTF-8')
|
|
47
|
+
plan = Runner.plan_oath(File.basename(oath_path), source, loaded.registry)
|
|
36
48
|
pairs = Runner.examples_with_runs(plan, loaded.create_context, Runner::RecordingReporter.new)
|
|
37
|
-
drifts = Core::Drifts.reconcile_drift(store, rel, source, plan.
|
|
49
|
+
drifts = Core::Drifts.reconcile_drift(store, rel, source, plan.doc, plan, update: update)
|
|
38
50
|
|
|
39
51
|
::RSpec.describe(rel) do
|
|
40
52
|
pairs.each do |example, run|
|
|
53
|
+
lines = example.steps.map { |s| s.match_span.start_line }.uniq
|
|
41
54
|
# A var diff surfaces as a failure carrying the span-anchored render;
|
|
42
55
|
# any other exception propagates. RSpec reports both as failures.
|
|
43
56
|
it(example.name) do
|
|
44
57
|
run.call
|
|
45
58
|
rescue StandardError => e
|
|
59
|
+
# Recorded here, where the error object is still in hand: to_failure
|
|
60
|
+
# reads the anchor the executor attached to it.
|
|
61
|
+
results.record(rel, source, Core::ExampleResult.new(
|
|
62
|
+
name: example.name, status: 'failed', lines: lines,
|
|
63
|
+
failure: Core::Failures.to_failure(e, rel, lines.first || 0)
|
|
64
|
+
))
|
|
46
65
|
raise Runner.render_failure(e, source, rel) if RSpec.var_diff_error?(e)
|
|
47
66
|
|
|
48
67
|
raise
|
|
68
|
+
else
|
|
69
|
+
results.record(rel, source, Core::ExampleResult.new(
|
|
70
|
+
name: example.name, status: 'passed', lines: lines, failure: nil
|
|
71
|
+
))
|
|
49
72
|
end
|
|
50
73
|
end
|
|
51
74
|
|
|
@@ -53,6 +76,11 @@ module Varar
|
|
|
53
76
|
message = Core::Diagnostics.drift_detected(drift.name, drift.span).message
|
|
54
77
|
it("var drift at line #{drift.line}") { raise message }
|
|
55
78
|
end
|
|
79
|
+
|
|
80
|
+
# This oath's examples are all in — write its results. A passing oath is
|
|
81
|
+
# written too: a stale file would keep a diagnostic on screen that this
|
|
82
|
+
# run has just cleared.
|
|
83
|
+
after(:all) { results.flush(root, rel) }
|
|
56
84
|
end
|
|
57
85
|
end
|
|
58
86
|
|
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.
|
|
4
|
+
version: 0.8.0
|
|
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.
|
|
32
|
+
version: 0.8.0
|
|
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.
|
|
39
|
+
version: 0.8.0
|
|
40
40
|
description: 'RSpec adapter: one selectable example per Markdown example, with a drift
|
|
41
41
|
gate.'
|
|
42
42
|
email:
|
|
@@ -67,5 +67,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
67
67
|
requirements: []
|
|
68
68
|
rubygems_version: 4.0.16
|
|
69
69
|
specification_version: 4
|
|
70
|
-
summary: Markdown-native BDD — run Markdown
|
|
70
|
+
summary: Markdown-native BDD — run Markdown oaths as RSpec examples
|
|
71
71
|
test_files: []
|