sus 0.33.1 โ†’ 0.34.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: 8f23ab2c7fb7e993b1d0e957104ec363d45512e7de084b3d8c539dd68f0944f0
4
- data.tar.gz: 81786b021f4c5b2a27abcd589fc9844123f35c6c8b42495f56cbf1fba0f22778
3
+ metadata.gz: 5e9cdd2318c294d0d9cea4ae26b1b82635bdee10530302fc17c9fbbf66271e25
4
+ data.tar.gz: ae9c5b7311646e83acd88ad665126be152a8dc149db1e8a5156e0269f8a64b80
5
5
  SHA512:
6
- metadata.gz: 9cac16658c6feadbdd5ea53d39f395527d4af3f620c1e06576e71f0f4bb8b59947f2aaec4da117eda384932e958e7c1cfe018d7573bc630d408142ce68abf916
7
- data.tar.gz: 3d4964ca4aab54d6764072d8a1c015dc28c0ed2a4d84ec96877d62affc415eabf80094f74fbfc24cf88ca25c102f2f669560f0605b6f0474721c6ad0886cfab5
6
+ metadata.gz: da0963499c5f6b2aa2be21a5623a4ed1feb2f1889c6efcfb5fae927dbcf6bf33049a49ce849f622d4c87602ae353aa1476b89649bdc3de18a192dac495a97343
7
+ data.tar.gz: ddeb909536fdd63b90a1992fe7ba986320156fbd42d3c18bc2fdc82bdfd14879d61a3df0b4a7ffddb84bea8b0a5fb705b6730a4bbf05ff4083abaf2671042167
checksums.yaml.gz.sig CHANGED
Binary file
@@ -0,0 +1,49 @@
1
+ # Getting Started
2
+
3
+ This guide explains how to use the `sus` gem to write tests for your Ruby projects.
4
+
5
+ ## Installation
6
+
7
+ Add the gem to your project:
8
+
9
+ ~~~ bash
10
+ $ bundle add sus
11
+ ~~~
12
+
13
+ ## Write Some Tests
14
+
15
+ Create a test file in your project `test/my_project/my_class.rb`:
16
+
17
+ ~~~ ruby
18
+ describe MyProject::MyClass do
19
+ let(:instance) {subject.new}
20
+
21
+ it "instantiates an object" do
22
+ expect(instance).to be_a(Object)
23
+ end
24
+ end
25
+ ~~~
26
+
27
+ ## Run Your Tests
28
+
29
+ Run your tests with the `sus` command:
30
+
31
+ ~~~ bash
32
+ $ sus
33
+ 1 passed out of 1 total (1 assertions)
34
+ ๐Ÿ Finished in 47.0ยตs; 21272.535 assertions per second.
35
+ ๐Ÿ‡ No slow tests found! Well done!
36
+ ~~~
37
+
38
+ You can also run your tests in parallel:
39
+
40
+ ~~~ bash
41
+ $ sus-parallel
42
+ ~~~
43
+
44
+ ## More Examples
45
+
46
+ Check out all the repositories in this organisation, including these notable examples:
47
+
48
+ - [sus/test](https://github.com/socketry/sus/tree/main/test/sus)
49
+ - [async/test](https://github.com/socketry/async/tree/main/test)
@@ -0,0 +1,13 @@
1
+ # Automatically generated context index for Utopia::Project guides.
2
+ # Do not edit then files in this directory directly, instead edit the guides and then run `bake utopia:project:agent:context:update`.
3
+ ---
4
+ description: A fast and scalable test runner.
5
+ metadata:
6
+ documentation_uri: https://socketry.github.io/sus/
7
+ funding_uri: https://github.com/sponsors/ioquatix/
8
+ source_code_uri: https://github.com/socketry/sus.git
9
+ files:
10
+ - path: getting-started.md
11
+ title: Getting Started
12
+ description: This guide explains how to use the `sus` gem to write tests for your
13
+ Ruby projects.
@@ -368,7 +368,7 @@ module Sus
368
368
  @errored << assertions
369
369
  elsif assertions.passed?
370
370
  @passed << assertions
371
-
371
+
372
372
  # if @verbose
373
373
  # @output.write(:indent, :passed, pass_prefix, :reset)
374
374
  # self.print(@output, verbose: false)
@@ -376,7 +376,7 @@ module Sus
376
376
  # end
377
377
  else
378
378
  @failed << assertions
379
-
379
+
380
380
  # @output.write(:indent, :failed, fail_prefix, :reset)
381
381
  # self.print(@output, verbose: false)
382
382
  # @output.puts
data/lib/sus/config.rb CHANGED
@@ -195,7 +195,7 @@ module Sus
195
195
  output.puts "๐Ÿ‡ No slow tests found! Well done!"
196
196
  else
197
197
  output.puts "๐Ÿข Slow tests:"
198
-
198
+
199
199
  slowest_tests.each do |test|
200
200
  output.puts "\t", :variable, test.clock, :reset, ": ", test.target
201
201
  end
data/lib/sus/mock.rb CHANGED
@@ -28,7 +28,7 @@ module Sus
28
28
 
29
29
  def replace(method, &hook)
30
30
  execution_context = Thread.current
31
-
31
+
32
32
  @interceptor.define_method(method) do |*arguments, **options, &block|
33
33
  if execution_context == Thread.current
34
34
  hook.call(*arguments, **options, &block)
@@ -42,24 +42,24 @@ module Sus
42
42
 
43
43
  def before(method, &hook)
44
44
  execution_context = Thread.current
45
-
45
+
46
46
  @interceptor.define_method(method) do |*arguments, **options, &block|
47
47
  hook.call(*arguments, **options, &block) if execution_context == Thread.current
48
48
  super(*arguments, **options, &block)
49
49
  end
50
-
50
+
51
51
  return self
52
52
  end
53
-
53
+
54
54
  def after(method, &hook)
55
55
  execution_context = Thread.current
56
-
56
+
57
57
  @interceptor.define_method(method) do |*arguments, **options, &block|
58
58
  result = super(*arguments, **options, &block)
59
59
  hook.call(result, *arguments, **options, &block) if execution_context == Thread.current
60
60
  return result
61
61
  end
62
-
62
+
63
63
  return self
64
64
  end
65
65
 
@@ -80,7 +80,7 @@ module Sus
80
80
  end
81
81
  end
82
82
  end
83
-
83
+
84
84
  module Mocks
85
85
  def after(error = nil)
86
86
  super
@@ -90,36 +90,36 @@ module Sus
90
90
 
91
91
  def mock(target)
92
92
  validate_mock!(target)
93
-
93
+
94
94
  mock = self.mocks[target]
95
-
95
+
96
96
  if block_given?
97
97
  yield mock
98
98
  end
99
-
99
+
100
100
  return mock
101
101
  end
102
102
 
103
103
  private
104
104
 
105
105
  MockTargetError = Class.new(StandardError)
106
-
106
+
107
107
  def validate_mock!(target)
108
108
  if target.frozen?
109
109
  raise MockTargetError, "Cannot mock frozen object #{target.inspect}!"
110
110
  end
111
111
  end
112
-
112
+
113
113
  def mocks
114
114
  @mocks ||= Hash.new{|h,k| h[k] = Mock.new(k)}.compare_by_identity
115
115
  end
116
116
  end
117
-
117
+
118
118
  class Base
119
119
  def mock(target, &block)
120
120
  # Pull in the extra functionality:
121
121
  self.singleton_class.prepend(Mocks)
122
-
122
+
123
123
  # Redirect the method to the new functionality:
124
124
  self.mock(target, &block)
125
125
  end
@@ -56,13 +56,13 @@ module Sus
56
56
 
57
57
  def error(error, identity, prefix = error_prefix)
58
58
  lines = error.message.split(/\r?\n/)
59
-
59
+
60
60
  self.puts(:indent, *prefix, error.class, ": ", lines.shift)
61
61
 
62
62
  lines.each do |line|
63
63
  self.puts(:indent, line)
64
64
  end
65
-
65
+
66
66
  self.write(Output::Backtrace.for(error, identity))
67
67
 
68
68
  if cause = error.cause
@@ -22,13 +22,13 @@ module Sus
22
22
 
23
23
  def append(buffer)
24
24
  end
25
-
25
+
26
26
  def indent
27
27
  end
28
28
 
29
29
  def outdent
30
30
  end
31
-
31
+
32
32
  def indented
33
33
  yield
34
34
  end
data/lib/sus/receive.rb CHANGED
@@ -177,12 +177,12 @@ module Sus
177
177
  end
178
178
 
179
179
  class Times
180
- ONCE = Be.new(:==, 1)
180
+ AT_LEAST_ONCE = Be.new(:>=, 1)
181
181
 
182
- def initialize(condition = ONCE)
182
+ def initialize(condition = AT_LEAST_ONCE)
183
183
  @condition = condition
184
184
  end
185
-
185
+
186
186
  def print(output)
187
187
  output.write("with call count ", @condition)
188
188
  end
@@ -36,7 +36,7 @@ module Sus
36
36
  def initialize(options)
37
37
  @options = options
38
38
  end
39
-
39
+
40
40
  def print(output)
41
41
  output.write("with options ", :variable, @options.inspect)
42
42
  end
data/lib/sus/version.rb CHANGED
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2021-2025, by Samuel Williams.
5
5
 
6
6
  module Sus
7
- VERSION = "0.33.1"
7
+ VERSION = "0.34.0"
8
8
  end
data/readme.md CHANGED
@@ -29,6 +29,10 @@ Please see the [project documentation](https://socketry.github.io/sus/) for more
29
29
 
30
30
  Please see the [project releases](https://socketry.github.io/sus/releases/index) for all releases.
31
31
 
32
+ ### v0.34.0
33
+
34
+ - Allow `expect(...).to receive(...)` to accept one or more calls (at least once).
35
+
32
36
  ### v0.33.0
33
37
 
34
38
  - Add support for `agent-context` gem.
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v0.34.0
4
+
5
+ - Allow `expect(...).to receive(...)` to accept one or more calls (at least once).
6
+
3
7
  ## v0.33.0
4
8
 
5
9
  - Add support for `agent-context` gem.
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.33.1
4
+ version: 0.34.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -51,6 +51,8 @@ files:
51
51
  - bin/sus-host
52
52
  - bin/sus-parallel
53
53
  - bin/sus-tree
54
+ - context/getting-started.md
55
+ - context/index.yaml
54
56
  - context/mocking.md
55
57
  - context/shared.md
56
58
  - context/usage.md
@@ -123,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
125
  - !ruby/object:Gem::Version
124
126
  version: '0'
125
127
  requirements: []
126
- rubygems_version: 3.6.7
128
+ rubygems_version: 3.6.9
127
129
  specification_version: 4
128
130
  summary: A fast and scalable test runner.
129
131
  test_files: []
metadata.gz.sig CHANGED
Binary file