sus 0.10.1 → 0.11.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: 62b0520b1ea3639b141a0b0808d1d4b3949c94750bd9e168e4cf23e4f8282804
4
- data.tar.gz: 145f2f4dc24b7d3f1f05287acf43e21289f4ec29c0b331641dfe03589884f344
3
+ metadata.gz: 1e40571705fc5474aff2158cee00b9fd9b80778fa9d5e7caa30da9d039095368
4
+ data.tar.gz: 94cb197a3d237636360f5e62c1b5095352fb2956c7a4a01c49388d4dceab065d
5
5
  SHA512:
6
- metadata.gz: bc3adde570b2c5eca67612dbc20b78d85af042b1caeb9846c8a7b38c7bbd1b333bc734e6fe6bd8e9711c486fdf72c268f2788d2e28f076a7017a78da5b2d7123
7
- data.tar.gz: 0bd7224f611782ad494dcb4c6a63f0237e2c5bf621a021954eab6e55c2adbf1baf9e57e13d14529bd55bd8e91ef57573d5bbb28131629a298a209f65aa29a848
6
+ metadata.gz: 9cda6d03170da4badb665d704afe42f02f80f162f51891dad475c9a6ad7539c4b76a315f655293a686ccf24338c4d7128722cabb30e3671018b20ca0959c3373
7
+ data.tar.gz: e4a0f447efe11fcc9a7417277faf55100903b711703a363532f28dedebed0b6d3cb0b13bc6675a8ac1b0c5d8eaa21566cbf305ab9b90cea05c9f77d05d2902c1
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
1
5
 
2
6
  require_relative 'output'
3
7
  require_relative 'clock'
data/lib/sus/base.rb CHANGED
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
1
5
 
2
6
  require_relative 'context'
3
7
 
data/lib/sus/be.rb CHANGED
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
1
5
 
2
6
  module Sus
3
7
  class Be
@@ -48,6 +52,8 @@ module Sus
48
52
  Be.new(:===, value)
49
53
  end
50
54
  end
55
+
56
+ NIL = Be.new(:nil?)
51
57
  end
52
58
 
53
59
  class Base
@@ -62,5 +68,9 @@ module Sus
62
68
  def be_a(klass)
63
69
  Be.new(:is_a?, klass)
64
70
  end
71
+
72
+ def be_nil
73
+ Be::NIL
74
+ end
65
75
  end
66
76
  end
data/lib/sus/be_within.rb CHANGED
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
1
5
 
2
6
  module Sus
3
7
  class BeWithin
data/lib/sus/clock.rb CHANGED
@@ -1,3 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2022, by Samuel Williams.
5
+
1
6
  module Sus
2
7
  class Clock
3
8
  include Comparable
data/lib/sus/config.rb CHANGED
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2022, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2022, by Samuel Williams.
22
5
 
23
6
  require_relative 'clock'
24
7
  require_relative 'registry'
data/lib/sus/context.rb CHANGED
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
1
5
 
2
6
  require_relative 'assertions'
3
7
  require_relative 'identity'
data/lib/sus/describe.rb CHANGED
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
1
5
 
2
6
  require_relative 'context'
3
7
 
data/lib/sus/expect.rb CHANGED
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
1
5
 
2
6
  module Sus
3
7
  class Expect
@@ -47,5 +51,9 @@ module Sus
47
51
  Expect.new(@__assertions__, subject, **options)
48
52
  end
49
53
  end
54
+
55
+ def is_expected
56
+ expect(subject)
57
+ end
50
58
  end
51
59
  end
data/lib/sus/file.rb CHANGED
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
1
5
 
2
6
  require_relative 'context'
3
7
 
data/lib/sus/filter.rb CHANGED
@@ -1,3 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
5
+
1
6
  module Sus
2
7
  class Filter
3
8
  class Index
data/lib/sus/fixtures.rb CHANGED
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2022, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2022, by Samuel Williams.
22
5
 
23
6
  module Sus
24
7
  module Fixtures
data/lib/sus/have.rb ADDED
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2022, by Samuel Williams.
5
+
6
+ module Sus
7
+ module Have
8
+ class Composite
9
+ def initialize(predicates)
10
+ @predicates = predicates
11
+ end
12
+
13
+ def print(output)
14
+ first = true
15
+ output.write("have {")
16
+ @predicates.each do |predicate|
17
+ if first
18
+ first = false
19
+ else
20
+ output.write(", ")
21
+ end
22
+
23
+ output.write(predicate)
24
+ end
25
+ output.write("}")
26
+ end
27
+
28
+ def call(assertions, subject)
29
+ assertions.nested(self) do |assertions|
30
+ @predicates.each do |predicate|
31
+ predicate.call(assertions, subject)
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ class Key
38
+ def initialize(name, predicate = nil)
39
+ @name = name
40
+ @predicate = predicate
41
+ end
42
+
43
+ def print(output)
44
+ output.write("key ", :variable, @name.inspect, :reset, " ", @predicate, :reset)
45
+ end
46
+
47
+ def call(assertions, subject)
48
+ assertions.nested(self) do |assertions|
49
+ assertions.assert(subject.key?(@name), "has key")
50
+ @predicate&.call(assertions, subject[@name])
51
+ end
52
+ end
53
+ end
54
+
55
+ class Attribute
56
+ def initialize(name, predicate)
57
+ @name = name
58
+ @predicate = predicate
59
+ end
60
+
61
+ def print(output)
62
+ output.write("attribute ", :variable, @name.to_s, :reset, " ", @predicate, :reset)
63
+ end
64
+
65
+ def call(assertions, subject)
66
+ assertions.nested(self) do |assertions|
67
+ assertions.assert(subject.respond_to?(@name), "has attribute")
68
+ @predicate&.call(assertions, subject.send(@name))
69
+ end
70
+ end
71
+ end
72
+ end
73
+
74
+ class Base
75
+ def have(*predicates)
76
+ Have::Composite.new(predicates)
77
+ end
78
+
79
+ def have_keys(*keys)
80
+ predicates = []
81
+
82
+ keys.each do |key|
83
+ if key.is_a?(Hash)
84
+ key.each do |key, predicate|
85
+ predicates << Have::Key.new(key, predicate)
86
+ end
87
+ else
88
+ predicates << Have::Key.new(key)
89
+ end
90
+ end
91
+
92
+ Have::Composite.new(predicates)
93
+ end
94
+
95
+ def have_attributes(**attributes)
96
+ predicates = attributes.map do |key, value|
97
+ Have::Attribute.new(key, value)
98
+ end
99
+
100
+ Have::Composite.new(predicates)
101
+ end
102
+ end
103
+ end
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
1
5
 
2
6
  module Sus
3
7
  class HaveDuration
data/lib/sus/identity.rb CHANGED
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
1
5
 
2
6
  module Sus
3
7
  class Identity
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
1
5
 
2
6
  require_relative 'context'
3
7
 
data/lib/sus/it.rb CHANGED
@@ -1,9 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
1
5
 
2
6
  require_relative 'context'
3
7
 
4
8
  module Sus
5
9
  module It
6
- def self.build(parent, description, &block)
10
+ def self.build(parent, description = nil, &block)
7
11
  base = Class.new(parent)
8
12
  base.extend(It)
9
13
  base.description = description
@@ -22,7 +26,12 @@ module Sus
22
26
 
23
27
  def print(output)
24
28
  self.superclass.print(output)
25
- output.write(" it ", :it, self.description, :reset, " ", :identity, self.identity.to_s, :reset)
29
+
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
26
35
  end
27
36
 
28
37
  def call(assertions)
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
1
5
 
2
6
  require_relative 'context'
3
7
 
data/lib/sus/let.rb CHANGED
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
1
5
 
2
6
  require_relative 'context'
3
7
 
data/lib/sus/mock.rb CHANGED
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2022, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2022, by Samuel Williams.
22
5
 
23
6
  require_relative 'expect'
24
7
 
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2022, by Samuel Williams.
22
5
 
23
6
  module Sus
24
7
  module Output
@@ -30,7 +13,9 @@ module Sus
30
13
  end
31
14
 
32
15
  def self.for(exception, identity = nil)
33
- self.new(exception.backtrace_locations, identity&.path)
16
+ # I've disabled the root filter here, because partial backtraces are not very useful.
17
+ # We might want to do something to improve presentation of the backtrace based on the root instead.
18
+ self.new(exception.backtrace_locations) # , identity&.path)
34
19
  end
35
20
 
36
21
  def initialize(stack, root = nil, limit = nil)
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
22
5
 
23
6
  module Sus
24
7
  module Output
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
22
5
 
23
6
  require 'io/console'
24
7
  require 'stringio'
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
1
5
 
2
6
  require 'io/console'
3
7
 
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
22
5
 
23
6
  require 'io/console'
24
7
  require 'stringio'
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2022, by Samuel Williams.
22
5
 
23
6
  require_relative 'bar'
24
7
  require_relative 'status'
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
22
5
 
23
6
  module Sus
24
7
  module Output
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
22
5
 
23
6
  require 'io/console'
24
7
  require_relative 'buffered'
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
22
5
 
23
6
  require 'io/console'
24
7
 
data/lib/sus/output.rb CHANGED
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
1
5
 
2
6
  require_relative 'output/bar'
3
7
  require_relative 'output/text'
@@ -1,8 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
5
+
1
6
  module Sus
2
7
  class RaiseException
3
8
  def initialize(exception_class = nil, message: nil)
4
9
  @exception_class = exception_class
5
10
  @message = message
11
+ @predicate = nil
12
+ end
13
+
14
+ def and(predicate)
15
+ @predicate = predicate
16
+ return self
6
17
  end
7
18
 
8
19
  def call(assertions, subject)
@@ -11,14 +22,16 @@ module Sus
11
22
  subject.call
12
23
 
13
24
  # Didn't throw any exception, so the expectation failed:
14
- assertions.assert(false, self)
25
+ assertions.assert(false, "raised")
15
26
  rescue @exception_class => exception
16
27
  # Did it have the right message?
17
28
  if @message
18
- assertions.assert(@message === exception.message)
29
+ assertions.assert(@message === exception.message, "raised with message")
19
30
  else
20
- assertions.assert(true, self)
31
+ assertions.assert(true, "raised")
21
32
  end
33
+
34
+ @predicate&.call(assertions, exception)
22
35
  end
23
36
  end
24
37
  end
@@ -33,6 +46,10 @@ module Sus
33
46
  if @message
34
47
  output.write(" with message ", :variable, @message, :reset)
35
48
  end
49
+
50
+ if @predicate
51
+ output.write(" and ", @predicate)
52
+ end
36
53
  end
37
54
  end
38
55
 
data/lib/sus/receive.rb CHANGED
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2022, by Samuel Williams.
1
5
 
2
6
  require_relative 'respond_to'
3
7
 
data/lib/sus/registry.rb CHANGED
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
1
5
 
2
6
  require_relative 'base'
3
7
 
@@ -1,3 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2022, by Samuel Williams.
5
+
1
6
  module Sus
2
7
  class RespondTo
3
8
  class WithParameters
data/lib/sus/shared.rb CHANGED
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
1
5
 
2
6
  require_relative 'context'
3
7
 
data/lib/sus/version.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
5
+
3
6
  module Sus
4
- VERSION = "0.10.1"
7
+ VERSION = "0.11.0"
5
8
  end
data/lib/sus/with.rb CHANGED
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
1
5
 
2
6
  require_relative 'context'
3
7
 
data/lib/sus.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
5
+
3
6
  require_relative 'sus/version'
4
7
  require_relative 'sus/config'
5
8
  require_relative 'sus/registry'
@@ -14,5 +17,6 @@ require_relative 'sus/receive'
14
17
 
15
18
  require_relative 'sus/raise_exception'
16
19
  require_relative 'sus/have_duration'
20
+ require_relative 'sus/have'
17
21
 
18
22
  require_relative 'sus/filter'
data/license.md ADDED
@@ -0,0 +1,21 @@
1
+ # MIT License
2
+
3
+ Copyright, 2021-2022, by Samuel Williams.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/readme.md ADDED
@@ -0,0 +1,69 @@
1
+ # Sus(picious) \[working name\]
2
+
3
+ An opinionated test framework designed with several goals:
4
+
5
+ - As fast as possible, aiming for \~10,000 assertions per second per core.
6
+ - Isolated tests which parallelise easily (including `class` definitions).
7
+ - Native support for balanced (work-stealing) multi-core execution.
8
+ - Incredible test output with detailed failure logging (including nested assertions and predicates).
9
+
10
+ Non-features:
11
+
12
+ - Flexibility at the expense of performance.
13
+ - Backwards compatibility.
14
+
15
+ [![Development Status](https://github.com/ioquatix/sus/workflows/Test/badge.svg)](https://github.com/ioquatix/sus/actions?workflow=Test)
16
+
17
+ ## Ideas
18
+
19
+ I've been thinking about how this should grow long term. I see a separation between "defining tests" and "running tests". I think this gem should be split across those responsibilities. By doing so, defining tests remains relatively static, but can be extended independently of execution model. And execution models which include parallelism, code coverage, multi-server, etc can be implemented effectively.
20
+
21
+ The key point is that we need a well defined interface between defining tests and running tests. This interface is provided by the test registry, which can load test files. The test registry provides a way to enumerate all tests where each test has an identity that uniquely identifies it.
22
+
23
+ ### Sequential vs Parallel
24
+
25
+ `sus` has both sequential and multi-threaded (`sus-parallel`) execution models for tests. Parallel execution is potentially much faster. This is an experimental feature.
26
+
27
+ ![Sequential vs Parallel](https://user-images.githubusercontent.com/30030/144770080-092cf07b-b121-4754-96e0-8ff1d8ea0695.mov)
28
+
29
+ ## Installation
30
+
31
+ ``` shell
32
+ bundle add sus
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ Check `test` directory for examples.
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it.
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`).
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`).
44
+ 4. Push to the branch (`git push origin my-new-feature`).
45
+ 5. Create new Pull Request.
46
+
47
+ ## License
48
+
49
+ Released under the MIT license.
50
+
51
+ Copyright, 2021, by [Samuel G. D. Williams](https://www.codeotaku.com).
52
+
53
+ Permission is hereby granted, free of charge, to any person obtaining a copy
54
+ of this software and associated documentation files (the "Software"), to deal
55
+ in the Software without restriction, including without limitation the rights
56
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
57
+ copies of the Software, and to permit persons to whom the Software is
58
+ furnished to do so, subject to the following conditions:
59
+
60
+ The above copyright notice and this permission notice shall be included in
61
+ all copies or substantial portions of the Software.
62
+
63
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
64
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
65
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
66
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
67
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
68
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
69
+ THE SOFTWARE.
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.10.1
4
+ version: 0.11.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-08-24 00:00:00.000000000 Z
40
+ date: 2022-08-27 00:00:00.000000000 Z
41
41
  dependencies: []
42
42
  description:
43
43
  email:
@@ -62,6 +62,7 @@ files:
62
62
  - lib/sus/file.rb
63
63
  - lib/sus/filter.rb
64
64
  - lib/sus/fixtures.rb
65
+ - lib/sus/have.rb
65
66
  - lib/sus/have_duration.rb
66
67
  - lib/sus/identity.rb
67
68
  - lib/sus/include_context.rb
@@ -86,6 +87,8 @@ files:
86
87
  - lib/sus/shared.rb
87
88
  - lib/sus/version.rb
88
89
  - lib/sus/with.rb
90
+ - license.md
91
+ - readme.md
89
92
  homepage: https://github.com/ioquatix/sus
90
93
  licenses:
91
94
  - MIT
metadata.gz.sig CHANGED
Binary file