test_tube 1.0.0.beta0 → 1.0.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: 3e928758abf1d784bdf93e7d9128f3fc69a48bdcf532769a9f5250a0a09338ac
4
- data.tar.gz: ba835fe5031d9af8fc124f6cb012008923d3080a8de953a0a31c348f693102cd
3
+ metadata.gz: ed96729c5b8c3a0ccef89cc6739da3e46e54c70eaf3e0975ca7af8d74db23d26
4
+ data.tar.gz: b534c7cb0d0e5de7ce02c328b1be76960214ec4e6a4d45b031fafb1d9ffac136
5
5
  SHA512:
6
- metadata.gz: 132fe5f45b2b7317667e868aed913d856caa86fa302a6f954ef3a5ca7c11ac0c8047125df550196999208340f731cb4fc1d296974b465e6bad66afe4c4c2c37f
7
- data.tar.gz: e2d7535593db0618488764c7d1d42ec6902f75912c79f2bd010c7f627722d9ff5c3fb8b8e70ef30a5b6a807a104b65ff0c688dea4c76e8b8f856afb3f002bfab
6
+ metadata.gz: 48ac22dc6ada96e416df896a7c6e4bf7242e2391ce3788c28b2a2aeaa2ee93a18ed5f690be51dc0a434c97a8185c112a796cb7f0985dabe90eb39b33f8b4fee9
7
+ data.tar.gz: 5a508032716cd4836009b9ac4b2b1fcdfa07e7b579fbfae771563bdebb81cf6e68efa2a7edbe897f8162015c8e45c0ba46346785026867f227cae14da4c398ca
data/README.md CHANGED
@@ -28,8 +28,8 @@ gem install test_tube
28
28
 
29
29
  ## Usage
30
30
 
31
- Let's experiment the answer to the Ultimate Question of Life, the Universe, and
32
- Everything:
31
+ Assuming we'd like to experiment on the answer to the Ultimate Question of Life,
32
+ the Universe, and Everything with the following matcher:
33
33
 
34
34
  ```ruby
35
35
  class BeTheAnswer
@@ -37,8 +37,12 @@ class BeTheAnswer
37
37
  42.equal?(yield)
38
38
  end
39
39
  end
40
+ ```
41
+
42
+ One possibility would be to challenge a whole block of code:
40
43
 
41
- tt = TestTube.content(
44
+ ```ruby
45
+ tt = TestTube.invoke(
42
46
  -> { "101010".to_i(2) },
43
47
  isolation: false,
44
48
  matcher: BeTheAnswer.new,
@@ -51,6 +55,21 @@ tt.error # => nil
51
55
  tt.got # => true
52
56
  ```
53
57
 
58
+ An alternative would be to challenge a value passed as a parameter:
59
+
60
+ ```ruby
61
+ tt = TestTube.pass(
62
+ "101010".to_i(2),
63
+ matcher: BeTheAnswer.new,
64
+ negate: false
65
+ )
66
+ # => #<TestTube::Passer:0x00007f85c229c2d8 @actual=42, @got=true>
67
+
68
+ tt.actual # => 42
69
+ tt.error # => nil
70
+ tt.got # => true
71
+ ```
72
+
54
73
  ## Contact
55
74
 
56
75
  * Source code: https://github.com/fixrb/test_tube
data/lib/test_tube.rb CHANGED
@@ -1,26 +1,41 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative File.join("test_tube", "content")
4
- require_relative File.join("test_tube", "liquid")
3
+ require_relative File.join("test_tube", "invoker")
4
+ require_relative File.join("test_tube", "passer")
5
5
 
6
6
  # Namespace for the TestTube library.
7
7
  module TestTube
8
- # @param input [#call] The callable object to test.
9
- # @param isolation [Boolean] Compute in isolation or not.
10
- # @param matcher [#matches?] A matcher.
11
- # @param negate [Boolean] Invert the matcher or not.
8
+ # @param input [#call] The callable object to test.
9
+ # @param isolation [Boolean] Compute in isolation or not.
10
+ # @param matcher [#matches?] A matcher.
11
+ # @param negate [Boolean] Invert the matcher or not.
12
12
  #
13
- # @return [Content] A software experiment.
14
- def self.content(input, isolation:, matcher:, negate:)
15
- Content.new(input, isolation: isolation, matcher: matcher, negate: negate)
13
+ # @example
14
+ # invoke(
15
+ # -> { "101010".to_i(2) },
16
+ # isolation: false,
17
+ # matcher: BeTheAnswer.new,
18
+ # negate: false
19
+ # )
20
+ #
21
+ # @return [Invoker] A software experiment.
22
+ def self.invoke(input, isolation:, matcher:, negate:)
23
+ Invoker.new(input, isolation: isolation, matcher: matcher, negate: negate)
16
24
  end
17
25
 
18
- # @param input [#call] The callable object to test.
19
- # @param matcher [#matches?] A matcher.
20
- # @param negate [Boolean] Invert the matcher or not.
26
+ # @param input [#object_id] The callable object to test.
27
+ # @param matcher [#matches?] A matcher.
28
+ # @param negate [Boolean] Invert the matcher or not.
29
+ #
30
+ # @example
31
+ # pass(
32
+ # "101010".to_i(2),
33
+ # matcher: BeTheAnswer.new,
34
+ # negate: false
35
+ # )
21
36
  #
22
- # @return [Content] A software experiment.
23
- def self.liquid(input, matcher:, negate:)
24
- Liquid.new(input, matcher: matcher, negate: negate)
37
+ # @return [Passer] A software experiment.
38
+ def self.pass(input, matcher:, negate:)
39
+ Passer.new(input, matcher: matcher, negate: negate)
25
40
  end
26
41
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TestTube
4
- # The liquid class is great for values.
4
+ # The base class.
5
5
  class Base
6
6
  # @return [#object_id] The actual value.
7
7
  attr_reader :actual
@@ -5,8 +5,8 @@ require "defi"
5
5
  require_relative "base"
6
6
 
7
7
  module TestTube
8
- # The content class is great for blocks.
9
- class Content < Base
8
+ # The invoker class is great for blocks.
9
+ class Invoker < Base
10
10
  # Software experiments.
11
11
  #
12
12
  # rubocop:disable Lint/RescueException, Metrics/MethodLength
@@ -3,8 +3,8 @@
3
3
  require_relative "base"
4
4
 
5
5
  module TestTube
6
- # The liquid class is great for values.
7
- class Liquid < Base
6
+ # The passer class is great for values.
7
+ class Passer < Base
8
8
  # Software experiments.
9
9
  #
10
10
  # @param input [#object_id] An actual value to test.
@@ -14,7 +14,7 @@ module TestTube
14
14
  super()
15
15
 
16
16
  @actual = input
17
- @got = negate ^ matcher.matches? { @actual }
17
+ @got = negate ^ matcher.matches? { input }
18
18
  end
19
19
  end
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_tube
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Kato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-18 00:00:00.000000000 Z
11
+ date: 2021-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: defi
@@ -160,8 +160,8 @@ files:
160
160
  - README.md
161
161
  - lib/test_tube.rb
162
162
  - lib/test_tube/base.rb
163
- - lib/test_tube/content.rb
164
- - lib/test_tube/liquid.rb
163
+ - lib/test_tube/invoker.rb
164
+ - lib/test_tube/passer.rb
165
165
  homepage: https://github.com/fixrb/test_tube
166
166
  licenses:
167
167
  - MIT
@@ -177,9 +177,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
177
  version: 2.7.0
178
178
  required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  requirements:
180
- - - ">"
180
+ - - ">="
181
181
  - !ruby/object:Gem::Version
182
- version: 1.3.1
182
+ version: '0'
183
183
  requirements: []
184
184
  rubygems_version: 3.1.6
185
185
  signing_key: