sus 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/sus/assertions.rb +8 -0
- data/lib/sus/be.rb +4 -0
- data/lib/sus/be_truthy.rb +40 -0
- data/lib/sus/file.rb +1 -1
- data/lib/sus/it.rb +17 -1
- data/lib/sus/it_behaves_like.rb +9 -3
- data/lib/sus/output/status.rb +0 -3
- data/lib/sus/output/text.rb +2 -0
- data/lib/sus/output.rb +1 -0
- data/lib/sus/receive.rb +3 -0
- data/lib/sus/registry.rb +14 -0
- data/lib/sus/version.rb +1 -1
- data/lib/sus.rb +1 -0
- data.tar.gz.sig +0 -0
- metadata +3 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68595280910704ed5eb41683985ffaff34df40eb30e72408da93667de742fb0c
|
4
|
+
data.tar.gz: fc0ac561eae164316247c381c0a20cb244c61c0af6b68891ea120fad2f7916c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fa0de727817b73859de636f2414dcd08b6001cdd5d837cc9ca72caa3014bdfe08052a0d5c785c91127ee8632e21e64d1eb43817e00baeee2461e698975ab937
|
7
|
+
data.tar.gz: 2ce965a251d21411e22f8d5feb8ae5573805c18da2e8061ef47768e60600721ebd0d72cb2d8c9a6e1d6be6989dbddb32f12a8fd5a26d65e64c9cb3b47bc7d4ac
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/sus/assertions.rb
CHANGED
@@ -139,6 +139,10 @@ module Sus
|
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
142
|
+
def skip(reason)
|
143
|
+
@output.puts(:indent, :skip, skip_prefix, reason)
|
144
|
+
end
|
145
|
+
|
142
146
|
def inform(message)
|
143
147
|
@output.puts(:indent, :inform, inform_prefix, message)
|
144
148
|
end
|
@@ -303,5 +307,9 @@ module Sus
|
|
303
307
|
def inform_prefix
|
304
308
|
"ℹ "
|
305
309
|
end
|
310
|
+
|
311
|
+
def skip_prefix
|
312
|
+
"⚠ "
|
313
|
+
end
|
306
314
|
end
|
307
315
|
end
|
data/lib/sus/be.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2021-2022, by Samuel Williams.
|
5
|
+
|
6
|
+
module Sus
|
7
|
+
module BeTruthy
|
8
|
+
def self.print(output)
|
9
|
+
output.write("be truthy")
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.call(assertions, subject)
|
13
|
+
assertions.nested(self) do |assertions|
|
14
|
+
assertions.assert(subject, self)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module BeFalsey
|
20
|
+
def self.print(output)
|
21
|
+
output.write("be falsey")
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.call(assertions, subject)
|
25
|
+
assertions.nested(self) do |assertions|
|
26
|
+
assertions.assert(!subject, self)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Base
|
32
|
+
def be_truthy
|
33
|
+
BeTruthy
|
34
|
+
end
|
35
|
+
|
36
|
+
def be_falsey
|
37
|
+
BeFalsey
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/sus/file.rb
CHANGED
data/lib/sus/it.rb
CHANGED
@@ -39,10 +39,20 @@ module Sus
|
|
39
39
|
instance = self.new(assertions)
|
40
40
|
|
41
41
|
instance.around do
|
42
|
-
instance
|
42
|
+
handle_skip(instance, assertions)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
46
|
+
|
47
|
+
def handle_skip(instance, assertions)
|
48
|
+
reason = catch(:skip) do
|
49
|
+
return instance.call
|
50
|
+
end
|
51
|
+
|
52
|
+
assertions.skip(reason)
|
53
|
+
|
54
|
+
return nil
|
55
|
+
end
|
46
56
|
end
|
47
57
|
|
48
58
|
module Context
|
@@ -50,4 +60,10 @@ module Sus
|
|
50
60
|
add It.build(self, ...)
|
51
61
|
end
|
52
62
|
end
|
63
|
+
|
64
|
+
class Base
|
65
|
+
def skip(reason)
|
66
|
+
throw :skip, reason
|
67
|
+
end
|
68
|
+
end
|
53
69
|
end
|
data/lib/sus/it_behaves_like.rb
CHANGED
@@ -11,12 +11,18 @@ module Sus
|
|
11
11
|
|
12
12
|
attr_accessor :shared
|
13
13
|
|
14
|
-
def self.build(parent, shared, unique: false)
|
14
|
+
def self.build(parent, shared, unique: false, &block)
|
15
15
|
base = Class.new(parent)
|
16
16
|
base.singleton_class.prepend(ItBehavesLike)
|
17
17
|
base.children = Hash.new
|
18
18
|
base.description = shared.name
|
19
19
|
base.identity = Identity.nested(parent.identity, base.description, unique: unique)
|
20
|
+
|
21
|
+
# User provided block is evaluated first, so that it can provide default behaviour for the shared context:
|
22
|
+
if block_given?
|
23
|
+
base.class_exec(&block)
|
24
|
+
end
|
25
|
+
|
20
26
|
base.class_exec(&shared.block)
|
21
27
|
return base
|
22
28
|
end
|
@@ -28,8 +34,8 @@ module Sus
|
|
28
34
|
end
|
29
35
|
|
30
36
|
module Context
|
31
|
-
def it_behaves_like(shared, **options)
|
32
|
-
add ItBehavesLike.build(self, shared, **options)
|
37
|
+
def it_behaves_like(shared, **options, &block)
|
38
|
+
add ItBehavesLike.build(self, shared, **options, &block)
|
33
39
|
end
|
34
40
|
end
|
35
41
|
end
|
data/lib/sus/output/status.rb
CHANGED
@@ -14,7 +14,6 @@ module Sus
|
|
14
14
|
def initialize(state = :free, context = nil)
|
15
15
|
@state = state
|
16
16
|
@context = context
|
17
|
-
@index = 0
|
18
17
|
end
|
19
18
|
|
20
19
|
INDICATORS = {
|
@@ -36,8 +35,6 @@ module Sus
|
|
36
35
|
end
|
37
36
|
|
38
37
|
def print(output)
|
39
|
-
message = @message
|
40
|
-
|
41
38
|
output.write(
|
42
39
|
@state, self.indicator, " "
|
43
40
|
)
|
data/lib/sus/output/text.rb
CHANGED
data/lib/sus/output.rb
CHANGED
data/lib/sus/receive.rb
CHANGED
@@ -47,14 +47,17 @@ module Sus
|
|
47
47
|
|
48
48
|
def once
|
49
49
|
@times = Times.new(Be.new(:==, 1))
|
50
|
+
return self
|
50
51
|
end
|
51
52
|
|
52
53
|
def twice
|
53
54
|
@times = Times.new(Be.new(:==, 2))
|
55
|
+
return self
|
54
56
|
end
|
55
57
|
|
56
58
|
def with_call_count(predicate)
|
57
59
|
@times = Times.new(predicate)
|
60
|
+
return self
|
58
61
|
end
|
59
62
|
|
60
63
|
def and_return(*returning)
|
data/lib/sus/registry.rb
CHANGED
@@ -19,6 +19,8 @@ require_relative 'let'
|
|
19
19
|
|
20
20
|
module Sus
|
21
21
|
class Registry
|
22
|
+
DIRECTORY_GLOB = "**/*.rb"
|
23
|
+
|
22
24
|
# Create a top level scope with self as the instance:
|
23
25
|
def initialize(base = Sus.base(self))
|
24
26
|
@base = base
|
@@ -31,9 +33,21 @@ module Sus
|
|
31
33
|
end
|
32
34
|
|
33
35
|
def load(path)
|
36
|
+
if ::File.directory?(path)
|
37
|
+
load_directory(path)
|
38
|
+
else
|
39
|
+
load_file(path)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
private def load_file(path)
|
34
44
|
@base.file(path)
|
35
45
|
end
|
36
46
|
|
47
|
+
private def load_directory(path)
|
48
|
+
::Dir.glob(::File.join(path, DIRECTORY_GLOB), &self.method(:load_file))
|
49
|
+
end
|
50
|
+
|
37
51
|
def call(assertions = Assertions.default)
|
38
52
|
@base.call(assertions)
|
39
53
|
|
data/lib/sus/version.rb
CHANGED
data/lib/sus.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -37,7 +37,7 @@ cert_chain:
|
|
37
37
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
38
38
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
39
39
|
-----END CERTIFICATE-----
|
40
|
-
date: 2022-10-
|
40
|
+
date: 2022-10-30 00:00:00.000000000 Z
|
41
41
|
dependencies:
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: bake-test
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- lib/sus/assertions.rb
|
96
96
|
- lib/sus/base.rb
|
97
97
|
- lib/sus/be.rb
|
98
|
+
- lib/sus/be_truthy.rb
|
98
99
|
- lib/sus/be_within.rb
|
99
100
|
- lib/sus/clock.rb
|
100
101
|
- lib/sus/config.rb
|
metadata.gz.sig
CHANGED
Binary file
|