sus 0.29.1 → 0.30.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb73658184c73da088c57ee5bb4a86834116fdfb31cccf7a7c93248bac9854c1
4
- data.tar.gz: ba96338fe0a444462b1a1d4d5f2c249b84874a7be4431a0aac395427e3e92cb5
3
+ metadata.gz: c1b91ed35726c8afcbc97fd2c73ea28d433874f7976958b26beebd9f4ed1dfe4
4
+ data.tar.gz: 2295e4817295a52265e94c4eadf708f15b4502ecd40e42b76a44570c3f7c5f2b
5
5
  SHA512:
6
- metadata.gz: 9f6469a0c7d2168a11cf3da899e348db511fba9a019fff95a28079ad0b4fb21639fb14a0883f59d69b4fe992aa326b6a58917b05470ed513ae713b0f9b0340dd
7
- data.tar.gz: 81282c2660c353a69d38800e70386fdba27a8f8221d522967a66d442a9be1692c75340c75f4a3bf14b0f774bc8367c5a2f5ac43e281cf01112b4d31d0f232782
6
+ metadata.gz: 821e42e75cb7628974b6e10b036eb222aa35adfbafb25dc7b773b7b2ba8714c1a292c9ab539763567e1a1010f814aeada965b406eb77969a2f78c6dbf59c82e1
7
+ data.tar.gz: 44a648f339a1a947037bdfde3a5e84f875dc9fb5b018133b8e269c572f33ff90dd05c9bfe86f233df60b6ae7357b08ec62523841dddc1cd137327c445d13258e
checksums.yaml.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- (�M�U ����Vյ� л�]<
2
- (nAp�8��"b��]J̀`&����Sې��dͻr�d�� � {]y�q���C��h]�tNI0�[gٟl}���L�,��I{�OX|'DJ��/E�Fj��5Q���.׫M;�����z%��Ț;��F� P��E�*�2uf��T]��7�A�%�J<Pf�‰
1
+ 2.�g��R���V9Cǹ��D�^���<�
2
+ ��)ͫ�P�;3K?���R�t2ϛ$�ǜ�G�J҂=�|��g�,����<@������zKt\5hG�A,l�)�d��$ժ֟��{�oU���q�F�{Jz�H�щ"a��3YB
data/bin/sus CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  # require 'stackprof'
4
5
  # StackProf.start(mode: :wall, interval: 10)
data/bin/sus-host CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'json'
4
5
 
data/bin/sus-parallel CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require_relative '../lib/sus/config'
4
5
  config = Sus::Config.load
data/bin/sus-tree CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'json'
4
5
 
data/lib/sus/context.rb CHANGED
@@ -75,5 +75,57 @@ module Sus
75
75
  end
76
76
  end
77
77
  end
78
+
79
+ # Include an around method to the context class, that invokes the given block before running the test.
80
+ #
81
+ # Before hooks are called in the reverse order they are defined, in other words the last defined before hook is called first.
82
+ #
83
+ # @parameter hook [Proc] The block to execute before each test.
84
+ def before(&hook)
85
+ wrapper = Module.new
86
+
87
+ wrapper.define_method(:around) do |&block|
88
+ instance_exec(&hook)
89
+ super(&block)
90
+ end
91
+
92
+ self.include(wrapper)
93
+ end
94
+
95
+ # Include an around method to the context class, that invokes the given block after running the test.
96
+ #
97
+ # After hooks are called in the order they are defined, in other words the last defined after hook is called last.
98
+ #
99
+ # @parameter hook [Proc] The block to execute after each test. An `error` argument is passed if the test failed with an exception.
100
+ def after(&hook)
101
+ wrapper = Module.new
102
+
103
+ wrapper.define_method(:around) do |&block|
104
+ error = nil
105
+
106
+ super(&block)
107
+ rescue => error
108
+ raise
109
+ ensure
110
+ instance_exec(error, &hook)
111
+ end
112
+
113
+ self.include(wrapper)
114
+ end
115
+
116
+ # Add an around hook to the context class.
117
+ #
118
+ # Around hooks are called in the reverse order they are defined.
119
+ #
120
+ # The top level `around` implementation invokes before and after hooks.
121
+ #
122
+ # @paremeter block [Proc] The block to execute around each test.
123
+ def around(&block)
124
+ wrapper = Module.new
125
+
126
+ wrapper.define_method(:around, &block)
127
+
128
+ self.include(wrapper)
129
+ end
78
130
  end
79
131
  end
@@ -7,6 +7,11 @@ require_relative 'context'
7
7
 
8
8
  module Sus
9
9
  module Context
10
+ # Include a shared context into the current context, along with any arguments or options.
11
+ #
12
+ # @parameter shared [Sus::Shared] The shared context to include.
13
+ # @parameter arguments [Array] The arguments to pass to the shared context.
14
+ # @parameter options [Hash] The options to pass to the shared context.
10
15
  def include_context(shared, *arguments, **options)
11
16
  self.class_exec(*arguments, **options, &shared.block)
12
17
  end
@@ -18,12 +18,12 @@ module Sus
18
18
  base.description = shared.name
19
19
  base.identity = Identity.nested(parent.identity, base.description, unique: unique)
20
20
  base.set_temporary_name("#{self}[#{base.description}]")
21
-
21
+
22
22
  # User provided block is evaluated first, so that it can provide default behaviour for the shared context:
23
23
  if block_given?
24
24
  base.class_exec(*arguments, &block)
25
25
  end
26
-
26
+
27
27
  base.class_exec(*arguments, &shared.block)
28
28
  return base
29
29
  end
data/lib/sus/shared.rb CHANGED
@@ -11,13 +11,21 @@ module Sus
11
11
  attr_accessor :block
12
12
 
13
13
  def self.build(name, block)
14
- base = Class.new
14
+ base = Module.new
15
15
  base.extend(Shared)
16
16
  base.name = name
17
17
  base.block = block
18
18
 
19
19
  return base
20
20
  end
21
+
22
+ def included(base)
23
+ base.class_exec(&self.block)
24
+ end
25
+
26
+ def prepended(base)
27
+ base.class_exec(&self.block)
28
+ end
21
29
  end
22
30
 
23
31
  def self.Shared(name, &block)
data/lib/sus/version.rb CHANGED
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2021-2024, by Samuel Williams.
5
5
 
6
6
  module Sus
7
- VERSION = "0.29.1"
7
+ VERSION = "0.30.0"
8
8
  end
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.29.1
4
+ version: 0.30.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -38,7 +38,7 @@ cert_chain:
38
38
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
39
39
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
40
40
  -----END CERTIFICATE-----
41
- date: 2024-07-17 00:00:00.000000000 Z
41
+ date: 2024-07-22 00:00:00.000000000 Z
42
42
  dependencies: []
43
43
  description:
44
44
  email:
metadata.gz.sig CHANGED
Binary file