sus 0.21.1 → 0.22.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8653cb936d27d9e33250698daac7861a3235699ae90e6263a6d79d33dd24b4bd
4
- data.tar.gz: '0516931df8c4f34c61ab56cd75d65e29adc414e8d39797d79e8ba273af356e6e'
3
+ metadata.gz: 49e0b28d22be1c2142e9868d47de8e0e39447874bb5e17a4a9c513c723656617
4
+ data.tar.gz: 85e6348661715455dcec9ea552e59b788dd7637d79b32126c3e456e68b4d6998
5
5
  SHA512:
6
- metadata.gz: 8c8a8fd1d650280a873af340909fc55bfe3a3fa6fc510fb55dfc42a696a58beee78450d88d11340785d084e94c9a5bfedb85751f9f13cc0d61697cb7bfb2738c
7
- data.tar.gz: ebb26520158d23db914fc931afd6e001e2839fcaeff3f20b6734ab2f0a0c7d644a61f1f74f84ccf3af2f7e302954aa1244d792320e25dcc5f30e7e866b3e38a6
6
+ metadata.gz: f079bb5a6e5d3ff4f9f27f25f93675111754fbcc92f95b59209d981a370adbe2008ecb07acd7fb280db0f0d47705ae3254d55791f473e78891552cfebf7ba044
7
+ data.tar.gz: 99dde477c93576abf2ff664a3fd8bc31eda8be9280c6cd79aa6f831d68f4ae004ef9a6815ce6bcd49e718c64d4745a0b040c90b0b67fcb1be7886664823c6769
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  require_relative 'output'
7
7
  require_relative 'clock'
@@ -42,9 +42,16 @@ module Sus
42
42
  @count = 0
43
43
  end
44
44
 
45
+ # The identity that is used to identify this set of assertions.
45
46
  attr :identity
47
+
48
+ # The specific target of the assertions, e.g. the test case or nested test assertions.
46
49
  attr :target
50
+
51
+ # The output buffer used to capture output from the assertions.
47
52
  attr :output
53
+
54
+ # The nesting level of this set of assertions.
48
55
  attr :level
49
56
 
50
57
  # Whether this aset of assertions is inverted, i.e. the assertions are expected to fail relative to the parent. Used for grouping assertions and ensuring they are added to the parent passed/failed array correctly.
@@ -288,7 +295,7 @@ module Sus
288
295
  @output.error(error, @identity)
289
296
  end
290
297
 
291
- def nested(target, identity: nil, isolated: false, distinct: false, inverted: false, **options)
298
+ def nested(target, identity: @identity, isolated: false, distinct: false, inverted: false, **options)
292
299
  result = nil
293
300
 
294
301
  # Isolated assertions need to have buffered output so they can be replayed if they fail:
@@ -387,6 +394,8 @@ module Sus
387
394
  # self.print(@output, verbose: false)
388
395
  # @output.puts
389
396
  end
397
+
398
+ @skipped.concat(assertions.skipped)
390
399
  end
391
400
 
392
401
  # Concatenate the child assertions into this instance.
data/lib/sus/base.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  require_relative 'context'
7
7
 
@@ -45,6 +45,7 @@ module Sus
45
45
  base.extend(Context)
46
46
  base.identity = Identity.new(root) if root
47
47
  base.description = description
48
+ base.set_temporary_name("#{self}[#{description}]")
48
49
 
49
50
  return base
50
51
  end
data/lib/sus/be_truthy.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022, by Samuel Williams.
4
+ # Copyright, 2022-2023, by Samuel Williams.
5
5
 
6
6
  module Sus
7
7
  module BeTruthy
data/lib/sus/clock.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022, by Samuel Williams.
4
+ # Copyright, 2022-2023, by Samuel Williams.
5
5
 
6
6
  module Sus
7
7
  class Clock
data/lib/sus/config.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022, by Samuel Williams.
4
+ # Copyright, 2022-2023, by Samuel Williams.
5
5
 
6
6
  require_relative 'clock'
7
7
  require_relative 'registry'
@@ -78,12 +78,12 @@ module Sus
78
78
  return Dir.glob(DEFAULT_TEST_PATTERN, base: @root)
79
79
  end
80
80
 
81
- def registry
82
- @registry ||= self.load_registry
81
+ def make_registry
82
+ Sus::Registry.new(root: @root)
83
83
  end
84
84
 
85
85
  def load_registry(paths = @paths)
86
- registry = Sus::Registry.new(root: @root)
86
+ registry = make_registry
87
87
 
88
88
  if paths&.any?
89
89
  registry = Sus::Filter.new(registry)
@@ -99,6 +99,10 @@ module Sus
99
99
  return registry
100
100
  end
101
101
 
102
+ def registry
103
+ @registry ||= self.load_registry
104
+ end
105
+
102
106
  def before_tests(assertions, output: self.output)
103
107
  @clock.reset!
104
108
  @clock.start!
data/lib/sus/context.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  require_relative 'assertions'
7
7
  require_relative 'identity'
@@ -16,15 +16,21 @@ module Sus
16
16
  base.children = Hash.new
17
17
  end
18
18
 
19
- def to_s
20
- self.description || self.name
21
- end
22
-
23
- def inspect
24
- if description = self.description
25
- "\#<#{self.name || "Context"} #{self.description}>"
26
- else
27
- self.name
19
+ unless respond_to?(:set_temporary_name)
20
+ def set_temporary_name(name)
21
+ # No-op.
22
+ end
23
+
24
+ def to_s
25
+ (self.description || self.name).to_s
26
+ end
27
+
28
+ def inspect
29
+ if description = self.description
30
+ "\#<#{self.name || "Context"} #{self.description}>"
31
+ else
32
+ self.name
33
+ end
28
34
  end
29
35
  end
30
36
 
@@ -41,7 +47,13 @@ module Sus
41
47
  end
42
48
 
43
49
  def print(output)
44
- output.write("context ", :context, self.description)
50
+ output.write("context", :context, self.description)
51
+ end
52
+
53
+ def full_name
54
+ output = Output::Buffered.new
55
+ print(output)
56
+ return output.string
45
57
  end
46
58
 
47
59
  def call(assertions)
data/lib/sus/describe.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  require_relative 'context'
7
7
 
@@ -18,6 +18,8 @@ module Sus
18
18
  base.subject = subject
19
19
  base.description = subject.to_s
20
20
  base.identity = Identity.nested(parent.identity, base.description, unique: unique)
21
+ base.set_temporary_name("#{self}[#{base.description}]")
22
+
21
23
  base.define_method(:subject, ->{subject})
22
24
 
23
25
  if block_given?
data/lib/sus/expect.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  module Sus
7
7
  class Expect
data/lib/sus/file.rb CHANGED
@@ -24,6 +24,10 @@ module Sus
24
24
  module File
25
25
  extend Context
26
26
 
27
+ def self.[] path
28
+ self.build(Sus.base, path)
29
+ end
30
+
27
31
  def self.extended(base)
28
32
  base.children = Hash.new
29
33
  end
@@ -34,6 +38,7 @@ module Sus
34
38
  base.extend(File)
35
39
  base.description = path
36
40
  base.identity = Identity.file(parent.identity, path)
41
+ base.set_temporary_name("#{self}[#{path}]")
37
42
 
38
43
  begin
39
44
  TOPLEVEL_CLASS_EVAL.call(base, path)
data/lib/sus/filter.rb CHANGED
@@ -1,9 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  module Sus
7
+ # Provides a way to filter the registry according to the suffix on loaded paths.
8
+ #
9
+ # A test has an identity, e.g. the file and line number on which it's defined.
10
+ #
11
+ # A filter takes an identity, decomposes it into a file and suffix, loads the file, and registers the filter suffix.
12
+ #
13
+ # When the filter is used to enumerate the registry, it will only return the tests that match the suffix.
7
14
  class Filter
8
15
  class Index
9
16
  def initialize
data/lib/sus/identity.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  module Sus
7
7
  class Identity
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  require_relative 'context'
7
7
 
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2023, by Samuel Williams.
5
+
6
+ module Sus
7
+ module Integrations
8
+ end
9
+ end
data/lib/sus/it.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  require_relative 'context'
7
7
 
@@ -12,6 +12,7 @@ module Sus
12
12
  base.extend(It)
13
13
  base.description = description
14
14
  base.identity = Identity.nested(parent.identity, base.description, unique: unique)
15
+ base.set_temporary_name("#{self}[#{description}]")
15
16
 
16
17
  if block_given?
17
18
  base.define_method(:call, &block)
@@ -27,11 +28,11 @@ module Sus
27
28
  def print(output)
28
29
  self.superclass.print(output)
29
30
 
30
- if description = self.description
31
- output.write(" it ", :it, description, :reset, " ", :identity, self.identity.to_s, :reset)
32
- else
33
- output.write(" and ", :identity, self.identity.to_s, :reset)
34
- end
31
+ output.write(" it ", :it, self.description, :reset, " ", :identity, self.identity.to_s, :reset)
32
+ end
33
+
34
+ def to_s
35
+ "it #{description}"
35
36
  end
36
37
 
37
38
  def call(assertions)
@@ -64,5 +65,29 @@ module Sus
64
65
  @__assertions__.skip(reason)
65
66
  throw :skip, reason
66
67
  end
68
+
69
+ def skip_unless_method_defined(method, target)
70
+ unless target.method_defined?(method)
71
+ skip "Method #{method} is not defined in #{target}!"
72
+ end
73
+ end
74
+
75
+ def skip_unless_constant_defined(constant, target = Object)
76
+ unless target.const_defined?(constant)
77
+ skip "Constant #{constant} is not defined in #{target}!"
78
+ end
79
+ end
80
+
81
+ def skip_unless_minimum_ruby_version(version)
82
+ unless RUBY_VERSION >= version
83
+ skip "Ruby #{version} is required, but running #{RUBY_VERSION}!"
84
+ end
85
+ end
86
+
87
+ def skip_if_maximum_ruby_version(version)
88
+ if RUBY_VERSION >= version
89
+ skip "Ruby #{version} is not supported, but running #{RUBY_VERSION}!"
90
+ end
91
+ end
67
92
  end
68
93
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  require_relative 'context'
7
7
 
@@ -17,6 +17,7 @@ module Sus
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
+ base.set_temporary_name("#{self}[#{base.description}]")
20
21
 
21
22
  # User provided block is evaluated first, so that it can provide default behaviour for the shared context:
22
23
  if block_given?
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  require 'io/console'
7
7
  require 'stringio'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  require_relative 'messages'
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  require_relative 'messages'
7
7
  require_relative 'buffered'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  module Sus
7
7
  class RaiseException
data/lib/sus/registry.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
  # Copyright, 2022, by Brad Schrag.
6
6
 
7
7
  require_relative 'base'
@@ -27,7 +27,7 @@ module Sus
27
27
  @base = Sus.base(self, **options)
28
28
  @loaded = {}
29
29
  end
30
-
30
+
31
31
  attr :base
32
32
 
33
33
  def print(output)
@@ -35,7 +35,7 @@ module Sus
35
35
  end
36
36
 
37
37
  def to_s
38
- @base.identity.to_s
38
+ @base&.identity&.to_s || self.class.name
39
39
  end
40
40
 
41
41
  def load(path)
data/lib/sus/tree.rb CHANGED
@@ -1,3 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2023, by Samuel Williams.
5
+
1
6
  module Sus
2
7
  class Tree
3
8
  def initialize(context)
data/lib/sus/version.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  module Sus
7
- VERSION = "0.21.1"
7
+ VERSION = "0.22.0"
8
8
  end
data/lib/sus/with.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  require_relative 'context'
7
7
 
@@ -19,6 +19,8 @@ module Sus
19
19
  base.subject = subject
20
20
  base.description = subject
21
21
  base.identity = Identity.nested(parent.identity, base.description, unique: unique)
22
+ base.set_temporary_name("#{self}[#{base.description}]")
23
+
22
24
  base.variables = variables
23
25
 
24
26
  base.define_method(:description, ->{subject})
@@ -36,6 +38,7 @@ module Sus
36
38
 
37
39
  def print(output)
38
40
  self.superclass.print(output)
41
+
39
42
  output.write(
40
43
  " with ", :with, self.description, :reset,
41
44
  # " ", :variables, self.variables.inspect
data/lib/sus.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  require_relative 'sus/version'
7
7
  require_relative 'sus/config'
data/readme.md CHANGED
@@ -1,4 +1,4 @@
1
- # Sus(picious) \[working name\]
1
+ # Sus(picious)
2
2
 
3
3
  An opinionated test framework designed with several goals:
4
4
 
@@ -38,8 +38,18 @@ Check `test` directory for examples.
38
38
 
39
39
  ## Contributing
40
40
 
41
+ We welcome contributions to this project.
42
+
41
43
  1. Fork it.
42
44
  2. Create your feature branch (`git checkout -b my-new-feature`).
43
45
  3. Commit your changes (`git commit -am 'Add some feature'`).
44
46
  4. Push to the branch (`git push origin my-new-feature`).
45
47
  5. Create new Pull Request.
48
+
49
+ ### Developer Certificate of Origin
50
+
51
+ This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
52
+
53
+ ### Contributor Covenant
54
+
55
+ This project is governed by [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
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.21.1
4
+ version: 0.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -38,50 +38,8 @@ cert_chain:
38
38
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
39
39
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
40
40
  -----END CERTIFICATE-----
41
- date: 2023-06-14 00:00:00.000000000 Z
42
- dependencies:
43
- - !ruby/object:Gem::Dependency
44
- name: bake-test
45
- requirement: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - "~>"
48
- - !ruby/object:Gem::Version
49
- version: '0.1'
50
- type: :development
51
- prerelease: false
52
- version_requirements: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - "~>"
55
- - !ruby/object:Gem::Version
56
- version: '0.1'
57
- - !ruby/object:Gem::Dependency
58
- name: bake-test-external
59
- requirement: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - "~>"
62
- - !ruby/object:Gem::Version
63
- version: '0.1'
64
- type: :development
65
- prerelease: false
66
- version_requirements: !ruby/object:Gem::Requirement
67
- requirements:
68
- - - "~>"
69
- - !ruby/object:Gem::Version
70
- version: '0.1'
71
- - !ruby/object:Gem::Dependency
72
- name: covered
73
- requirement: !ruby/object:Gem::Requirement
74
- requirements:
75
- - - "~>"
76
- - !ruby/object:Gem::Version
77
- version: '0.18'
78
- type: :development
79
- prerelease: false
80
- version_requirements: !ruby/object:Gem::Requirement
81
- requirements:
82
- - - "~>"
83
- - !ruby/object:Gem::Version
84
- version: '0.18'
41
+ date: 2023-07-22 00:00:00.000000000 Z
42
+ dependencies: []
85
43
  description:
86
44
  email:
87
45
  executables:
@@ -116,6 +74,7 @@ files:
116
74
  - lib/sus/have_duration.rb
117
75
  - lib/sus/identity.rb
118
76
  - lib/sus/include_context.rb
77
+ - lib/sus/integrations.rb
119
78
  - lib/sus/it.rb
120
79
  - lib/sus/it_behaves_like.rb
121
80
  - lib/sus/let.rb
@@ -155,14 +114,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
155
114
  requirements:
156
115
  - - ">="
157
116
  - !ruby/object:Gem::Version
158
- version: 2.7.0
117
+ version: '3.0'
159
118
  required_rubygems_version: !ruby/object:Gem::Requirement
160
119
  requirements:
161
120
  - - ">="
162
121
  - !ruby/object:Gem::Version
163
122
  version: '0'
164
123
  requirements: []
165
- rubygems_version: 3.4.7
124
+ rubygems_version: 3.4.10
166
125
  signing_key:
167
126
  specification_version: 4
168
127
  summary: A fast and scalable test runner.
metadata.gz.sig CHANGED
Binary file