sus 0.3.0 → 0.5.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 +4 -4
- data/lib/sus/be.rb +1 -1
- data/lib/sus/be_within.rb +1 -1
- data/lib/sus/describe.rb +7 -10
- data/lib/sus/file.rb +34 -0
- data/lib/sus/filter.rb +7 -1
- data/lib/sus/identity.rb +11 -3
- data/lib/sus/it_behaves_like.rb +6 -9
- data/lib/sus/registry.rb +2 -6
- data/lib/sus/version.rb +1 -1
- data/lib/sus/with.rb +4 -7
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7af09d0464d3ca51e1934e41acd230f7654faa864a37a6d21937023d282a180
|
4
|
+
data.tar.gz: 79205ad8526cd12292909e8509a859beda4854035c46b5ce696c0434b1287da4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28c12a85e343b51be0203b90aeff2e4c38d7031b2a835fa0cab1dfb9f4401de59dc2b747d5e4f45c7f5247c94a42267d0dfeb123bfdbb0a3b3a5e9eb546c781d
|
7
|
+
data.tar.gz: 58a4fe6cd8d9f0ba1c59334783260b60d70abf6ee710944ad1576d8e66e4f81b5c598afbfa6c9e495e544bf906fe02e461de99ecf0d60377552c8c2701a4c08a
|
data/lib/sus/be.rb
CHANGED
data/lib/sus/be_within.rb
CHANGED
data/lib/sus/describe.rb
CHANGED
@@ -7,16 +7,13 @@ module Sus
|
|
7
7
|
|
8
8
|
attr_accessor :subject
|
9
9
|
|
10
|
-
def self.
|
11
|
-
base.children = Hash.new
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.build(parent, subject, identity: nil, &block)
|
10
|
+
def self.build(parent, subject, unique: true, &block)
|
15
11
|
base = Class.new(parent)
|
16
|
-
base.
|
12
|
+
base.singleton_class.prepend(Describe)
|
13
|
+
base.children = Hash.new
|
17
14
|
base.subject = subject
|
18
|
-
base.description = subject.
|
19
|
-
base.identity =
|
15
|
+
base.description = subject.to_s
|
16
|
+
base.identity = Identity.nested(parent.identity, base.description, unique: unique)
|
20
17
|
base.define_method(:subject, ->{subject})
|
21
18
|
|
22
19
|
if block_given?
|
@@ -35,8 +32,8 @@ module Sus
|
|
35
32
|
end
|
36
33
|
|
37
34
|
module Context
|
38
|
-
def describe(
|
39
|
-
add Describe.build(self,
|
35
|
+
def describe(subject, **options, &block)
|
36
|
+
add Describe.build(self, subject, **options, &block)
|
40
37
|
end
|
41
38
|
end
|
42
39
|
end
|
data/lib/sus/file.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
require_relative 'context'
|
3
|
+
|
4
|
+
# This has to be done at the top level. It allows us to define constants within the given class while still retaining top-level constant resolution.
|
5
|
+
Sus::TOPLEVEL_CLASS_EVAL = ->(klass, path){klass.class_eval(::File.read(path), path)}
|
6
|
+
|
7
|
+
module Sus
|
8
|
+
module File
|
9
|
+
extend Context
|
10
|
+
|
11
|
+
attr_accessor :path
|
12
|
+
|
13
|
+
def self.extended(base)
|
14
|
+
base.children = Hash.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.build(parent, path)
|
18
|
+
base = Class.new(parent)
|
19
|
+
base.extend(File)
|
20
|
+
base.description = path
|
21
|
+
base.identity = Identity.new(path)
|
22
|
+
|
23
|
+
TOPLEVEL_CLASS_EVAL.call(base, path)
|
24
|
+
|
25
|
+
return base
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
module Context
|
30
|
+
def file(path)
|
31
|
+
add File.build(self, path)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/sus/filter.rb
CHANGED
@@ -16,7 +16,13 @@ module Sus
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def insert(identity, context)
|
19
|
-
|
19
|
+
key = identity.key
|
20
|
+
|
21
|
+
if existing_context = @contexts[key]
|
22
|
+
raise KeyError, "Assigning context to existing key: #{key.inspect}!"
|
23
|
+
else
|
24
|
+
@contexts[key] = context
|
25
|
+
end
|
20
26
|
end
|
21
27
|
|
22
28
|
def [] key
|
data/lib/sus/identity.rb
CHANGED
@@ -7,6 +7,7 @@ module Sus
|
|
7
7
|
self.new(location.path, name, location.lineno, parent, **options)
|
8
8
|
end
|
9
9
|
|
10
|
+
# @parameter unique [Boolean | Symbol] Whether this identity is unique or needs a unique key/line number suffix.
|
10
11
|
def initialize(path, name = nil, line = nil, parent = nil, unique: true)
|
11
12
|
@path = path
|
12
13
|
@name = name
|
@@ -55,7 +56,8 @@ module Sus
|
|
55
56
|
unless @key
|
56
57
|
key = Array.new
|
57
58
|
|
58
|
-
|
59
|
+
# For a specific leaf node, the last part is not unique, i.e. it must be identified explicitly.
|
60
|
+
append_unique_key(key, @unique == true ? false : @unique)
|
59
61
|
|
60
62
|
@key = key.join(':')
|
61
63
|
end
|
@@ -72,8 +74,14 @@ module Sus
|
|
72
74
|
key << @path
|
73
75
|
end
|
74
76
|
|
75
|
-
if
|
76
|
-
key
|
77
|
+
if unique == true
|
78
|
+
# No key is needed because this identity is unique.
|
79
|
+
else
|
80
|
+
if unique
|
81
|
+
key << unique
|
82
|
+
elsif @line
|
83
|
+
key << @line
|
84
|
+
end
|
77
85
|
end
|
78
86
|
end
|
79
87
|
end
|
data/lib/sus/it_behaves_like.rb
CHANGED
@@ -7,15 +7,12 @@ module Sus
|
|
7
7
|
|
8
8
|
attr_accessor :shared
|
9
9
|
|
10
|
-
def self.
|
11
|
-
base.children = Hash.new
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.build(parent, shared)
|
10
|
+
def self.build(parent, shared, unique: false)
|
15
11
|
base = Class.new(parent)
|
16
|
-
base.
|
12
|
+
base.singleton_class.prepend(ItBehavesLike)
|
13
|
+
base.children = Hash.new
|
17
14
|
base.description = shared.name
|
18
|
-
base.identity = Identity.nested(parent.identity, base.description, unique:
|
15
|
+
base.identity = Identity.nested(parent.identity, base.description, unique: unique)
|
19
16
|
base.class_exec(&shared.block)
|
20
17
|
return base
|
21
18
|
end
|
@@ -27,8 +24,8 @@ module Sus
|
|
27
24
|
end
|
28
25
|
|
29
26
|
module Context
|
30
|
-
def it_behaves_like(shared)
|
31
|
-
add ItBehavesLike.build(self, shared)
|
27
|
+
def it_behaves_like(shared, **options)
|
28
|
+
add ItBehavesLike.build(self, shared, **options)
|
32
29
|
end
|
33
30
|
end
|
34
31
|
end
|
data/lib/sus/registry.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
|
2
2
|
require_relative 'base'
|
3
3
|
|
4
|
+
require_relative 'file'
|
4
5
|
require_relative 'describe'
|
5
6
|
require_relative 'with'
|
6
7
|
|
@@ -12,9 +13,6 @@ require_relative 'include_context'
|
|
12
13
|
|
13
14
|
require_relative 'let'
|
14
15
|
|
15
|
-
# This has to be done at the top level. It allows us to define constants within the given class while still retaining top-level constant resolution.
|
16
|
-
TOPLEVEL_CLASS_EVAL = ->(klass, path){klass.class_eval(File.read(path), path)}
|
17
|
-
|
18
16
|
module Sus
|
19
17
|
class Registry
|
20
18
|
# Create a top level scope with self as the instance:
|
@@ -25,9 +23,7 @@ module Sus
|
|
25
23
|
attr :base
|
26
24
|
|
27
25
|
def load(path)
|
28
|
-
@base.
|
29
|
-
TOPLEVEL_CLASS_EVAL.call(self, path)
|
30
|
-
end
|
26
|
+
@base.file(path)
|
31
27
|
end
|
32
28
|
|
33
29
|
def call(assertions = Assertions.default)
|
data/lib/sus/version.rb
CHANGED
data/lib/sus/with.rb
CHANGED
@@ -8,16 +8,13 @@ module Sus
|
|
8
8
|
attr_accessor :subject
|
9
9
|
attr_accessor :variables
|
10
10
|
|
11
|
-
def self.
|
12
|
-
base.children = Hash.new
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.build(parent, subject, variables, &block)
|
11
|
+
def self.build(parent, subject, variables, unique: true, &block)
|
16
12
|
base = Class.new(parent)
|
17
|
-
base.
|
13
|
+
base.singleton_class.prepend(With)
|
14
|
+
base.children = Hash.new
|
18
15
|
base.subject = subject
|
19
16
|
base.description = subject
|
20
|
-
base.identity = Identity.nested(parent.identity, base.description)
|
17
|
+
base.identity = Identity.nested(parent.identity, base.description, unique: unique)
|
21
18
|
base.variables = variables
|
22
19
|
|
23
20
|
variables.each do |key, value|
|
metadata
CHANGED
@@ -1,19 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
15
15
|
executables:
|
16
16
|
- sus
|
17
|
+
- sus-parallel
|
17
18
|
extensions: []
|
18
19
|
extra_rdoc_files: []
|
19
20
|
files:
|
@@ -27,6 +28,7 @@ files:
|
|
27
28
|
- lib/sus/context.rb
|
28
29
|
- lib/sus/describe.rb
|
29
30
|
- lib/sus/expect.rb
|
31
|
+
- lib/sus/file.rb
|
30
32
|
- lib/sus/filter.rb
|
31
33
|
- lib/sus/have_duration.rb
|
32
34
|
- lib/sus/identity.rb
|
@@ -68,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
70
|
- !ruby/object:Gem::Version
|
69
71
|
version: '0'
|
70
72
|
requirements: []
|
71
|
-
rubygems_version: 3.
|
73
|
+
rubygems_version: 3.2.32
|
72
74
|
signing_key:
|
73
75
|
specification_version: 4
|
74
76
|
summary: A fast and scalable test runner.
|