varar-rspec 0.8.0 → 0.9.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/varar/rspec.rb +42 -8
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a79154b49d4b13d706d22d242f4edd456c061de513d13681be93f6fbfad21ed
4
- data.tar.gz: 7ec9debe89392c639140b059d2885f477f281d61d7b99174f57a4e4f0592c39a
3
+ metadata.gz: 3546d0bf08bbdf362638b47e975a637ac1cf52cc05c3c31997f848f72be44797
4
+ data.tar.gz: eb9efcd84cffe0ce560dbcc3c864296d1bffd473c273db74f756d3c49cebbfb3
5
5
  SHA512:
6
- metadata.gz: 66206a596b79c0d267618fdd8c157a3be5eb272405e1ecae5d254e70c4fcf689b5b07a21510ce79ce5efdb50d97ccb77615ab70ecc875b4f5ebfc7c7e6f8e216
7
- data.tar.gz: a9e7a899eadfddfb6eebb7c0f7a88e527557dea82b093f3cf043863d3503c09e5c0e5b9c421c000fa264b25ab88dd32345b5e2cea8279e38d062c9aa85cdb01a
6
+ metadata.gz: 67c5180756b91403fb9c9a1645fb2d03da9f95ec510c4d60259908226cce1d19c7016650355add65a6eb55569e2093ae21c08d7dec466b88fcfa699fb8ed9a52
7
+ data.tar.gz: cd39b2dc93b33dee54e479052345942795f85ef59c93005b213e7d2a671e3b191a3bcb83e980322871e3e34eae655c06401a7eb15242cc15b53afa2a15c41042
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.0'
15
+ VERSION = '0.9.0'
16
16
 
17
17
  module_function
18
18
 
@@ -36,21 +36,55 @@ 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
- plan = Runner.plan_oath(File.basename(oath_path), source, loaded.registry)
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
- drifts = Core::Drifts.reconcile_drift(store, rel, source, plan.doc, plan, update: update)
77
+ # A paragraph that became an example (#120) is named on stderr when the
78
+ # baseline is rewritten — a notice, never a failure.
79
+ notify = ->(line) { $stderr.write("#{line}\n") }
80
+ drifts = Core::Drifts.reconcile_drift(store, rel, plan.doc, plan, update: update, notify: notify)
50
81
 
51
82
  ::RSpec.describe(rel) do
52
83
  pairs.each do |example, run|
53
- lines = example.steps.map { |s| s.match_span.start_line }.uniq
84
+ # Lines in THIS oath: a step a reference block spliced in from
85
+ # another oath (ADR 0016) contributes none, since its line is not in
86
+ # this file.
87
+ lines = example.steps.reject(&:doc_path).map { |s| s.match_span.start_line }.uniq
54
88
  # A var diff surfaces as a failure carrying the span-anchored render;
55
89
  # any other exception propagates. RSpec reports both as failures.
56
90
  it(example.name) do
@@ -61,14 +95,14 @@ module Varar
61
95
  results.record(rel, source, Core::ExampleResult.new(
62
96
  name: example.name, status: 'failed', lines: lines,
63
97
  failure: Core::Failures.to_failure(e, rel, lines.first || 0)
64
- ))
98
+ ), referenced)
65
99
  raise Runner.render_failure(e, source, rel) if RSpec.var_diff_error?(e)
66
100
 
67
101
  raise
68
102
  else
69
103
  results.record(rel, source, Core::ExampleResult.new(
70
104
  name: example.name, status: 'passed', lines: lines, failure: nil
71
- ))
105
+ ), referenced)
72
106
  end
73
107
  end
74
108
 
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.0
4
+ version: 0.9.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.8.0
32
+ version: 0.9.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.8.0
39
+ version: 0.9.0
40
40
  description: 'RSpec adapter: one selectable example per Markdown example, with a drift
41
41
  gate.'
42
42
  email:
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  - !ruby/object:Gem::Version
66
66
  version: '0'
67
67
  requirements: []
68
- rubygems_version: 4.0.16
68
+ rubygems_version: 4.0.20
69
69
  specification_version: 4
70
70
  summary: Markdown-native BDD — run Markdown oaths as RSpec examples
71
71
  test_files: []