fix 1.0.0.beta9 → 1.0.0.beta10

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: 0d266f76f9d9f0ee694cade79ee90b02d1a662709bb31c548da80be1ab42d689
4
- data.tar.gz: e38fa445573fe8b23df2cea139c4d2879a49652afdb6543aebd05525a5ca0da9
3
+ metadata.gz: af0a01072f39d7c105aff0bde77c97ce31c9aae8a1144e29a00b9098017cb436
4
+ data.tar.gz: cab7ff1e39fc58599b712ff53597534535e86bf1422f0f10c926e14d1e267e3f
5
5
  SHA512:
6
- metadata.gz: 2496a36150fc8640b16ab0942592dfcb47cf0cc0db0abb9d6c716387e73a8a16f329459be64d74c00a7604ec9081191d0580de45cbe62f585fdc9aff744d2b4f
7
- data.tar.gz: 0b09e865870d08db2b9147fd9977aa7b0df27d44a63e3138c8e699258cc49dfcee3f81000f4491a896275b79d54c45b1e3b1f3e9fe881cc9152fa7e48a1f0f61
6
+ metadata.gz: 90f831b90a8faaabf56db03f17d03905e6c41eb18e0f1873db78e0de30540e46b4b395c7fb19f80b3ccbc6b3e560978c42fb0ff8066b6b912151f2785249b51b
7
+ data.tar.gz: 4b1f58e67584042977f803b53119d090e76f9848b6b470a86aeefaa5f5a195afe11f3ab98d3383e1c5e1e819ff570b890bff58aa734d2c19c6e3079d75a95ffd
data/README.md CHANGED
@@ -21,7 +21,7 @@
21
21
  Add to your Gemfile:
22
22
 
23
23
  ```ruby
24
- gem "fix", ">= 1.0.0.beta9"
24
+ gem "fix", ">= 1.0.0.beta10"
25
25
  ```
26
26
 
27
27
  Then execute:
data/lib/fix/dsl.rb CHANGED
@@ -22,8 +22,9 @@ module Fix
22
22
  # let(:name) { "Bob" }
23
23
  # end
24
24
  #
25
- # @param name [String, Symbol] The name of the property.
26
- # @param block [Proc] The content of the method to define.
25
+ # @param name [String, Symbol] The name of the property.
26
+ # @yield The block that defines the property's value
27
+ # @yieldreturn [Object] The value to be returned by the property
27
28
  #
28
29
  # @return [Symbol] A private method that define the block content.
29
30
  #
@@ -39,13 +40,14 @@ module Fix
39
40
  # require "fix"
40
41
  #
41
42
  # Fix do
42
- # with :password, "secret" do
43
+ # with password: "secret" do
43
44
  # it MUST be true
44
45
  # end
45
46
  # end
46
47
  #
47
48
  # @param kwargs [Hash] The list of propreties.
48
- # @param block [Proc] The block to define the specs.
49
+ # @yield The block that defines the specs for this context
50
+ # @yieldreturn [void]
49
51
  #
50
52
  # @api public
51
53
  def self.with(**kwargs, &)
data/lib/fix/matcher.rb CHANGED
@@ -195,7 +195,9 @@ module Fix
195
195
  # matcher = satisfy { |value| value == 42 }
196
196
  # matcher.matches? { 42 } # => true
197
197
  #
198
- # @param expected [Proc] A block of code.
198
+ # @yield [value] A block that defines the satisfaction criteria
199
+ # @yieldparam value The value to test
200
+ # @yieldreturn [Boolean] true if the value satisfies the criteria
199
201
  #
200
202
  # @return [#matches?] A satisfy matcher.
201
203
  #
data/lib/fix/set.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "English"
4
+
3
5
  require_relative "doc"
4
6
  require_relative "run"
5
7
 
@@ -8,85 +10,58 @@ module Fix
8
10
  #
9
11
  # @api private
10
12
  class Set
11
- # The type of result.
12
- #
13
- # Passed expectations can be classified as:
14
- #
15
- # * `success`
16
- # * `warning`
17
- # * `info`
18
- #
19
- # Failed expectations can be classified as:
20
- #
21
- # * `failure`
22
- # * `error`
23
- LOG_LEVELS = %w[
24
- none
25
- error
26
- failure
27
- warning
28
- info
29
- success
30
- ].freeze
31
-
32
13
  # @return [Array] A list of specifications.
33
14
  attr_reader :specs
34
15
 
16
+ # Load specifications from a constant name.
17
+ #
35
18
  # @param name [String, Symbol] The constant name of the specifications.
19
+ # @return [Set] A new Set instance containing the loaded specifications.
36
20
  #
37
21
  # @api public
38
22
  def self.load(name)
39
23
  new(*Doc.fetch(name))
40
24
  end
41
25
 
26
+ # Initialize a new Set with given contexts.
27
+ #
42
28
  # @param contexts [Array<::Fix::Dsl>] The list of contexts document.
43
29
  def initialize(*contexts)
44
- @specs = Doc.specs(*contexts)
45
- @passed = true
30
+ @specs = Doc.specs(*contexts).shuffle
46
31
  end
47
32
 
48
- # @param subject [Proc] The block of code to be tested.
33
+ # Run the test suite against the provided subject.
49
34
  #
35
+ # @yield The block of code to be tested
36
+ # @yieldreturn [Object] The result of the code being tested
37
+ # @return [Boolean] true if all tests pass, exits with false otherwise
50
38
  # @raise [::SystemExit] The test set failed!
51
39
  #
52
40
  # @api public
53
- def test(log_level: 5, &subject)
54
- randomize!
55
-
56
- specs.each do |environment, location, requirement, challenges|
57
- runner = Run.new(environment, requirement, *challenges)
58
- result = runner.test(&subject)
59
-
60
- failed! if result.failed?
61
- report!(location, result, log_level:)
62
- end
63
-
64
- passed? || ::Kernel.exit(false)
41
+ def test(&)
42
+ suite_passed?(&) || ::Kernel.exit(false)
65
43
  end
66
44
 
67
45
  private
68
46
 
69
- def randomize!
70
- specs.shuffle!
47
+ def suite_passed?(&subject)
48
+ specs.all? { |spec| run_spec(*spec, &subject) }
71
49
  end
72
50
 
73
- def failed!
74
- @passed = false
51
+ def run_spec(env, location, requirement, challenges, &subject)
52
+ ::Process.fork { lab(env, location, requirement, challenges, &subject) }
53
+ ::Process.wait
54
+ $CHILD_STATUS.success?
75
55
  end
76
56
 
77
- # @return [Boolean] The test set passed or failed.
78
- def passed?
79
- @passed
57
+ def lab(env, location, requirement, challenges, &)
58
+ result = Run.new(env, requirement, *challenges).test(&)
59
+ report!(location, result)
60
+ ::Kernel.exit(result.passed?)
80
61
  end
81
62
 
82
- def report!(path, result, log_level:)
83
- return unless report?(result, log_level:)
84
-
63
+ def report!(path, result)
85
64
  puts "#{path} #{result.colored_string}"
86
65
  end
87
-
88
- def report?(result, log_level:)
89
- LOG_LEVELS[1..log_level].any? { |name| result.public_send(:"#{name}?") }
90
- end
91
66
  end
92
67
  end
data/lib/kernel.rb CHANGED
@@ -19,8 +19,9 @@ module Kernel
19
19
  # # A test
20
20
  # Fix[:Answer].test { 42 }
21
21
  #
22
- # @param name [String, Symbol] The constant name of the specifications.
23
- # @param block [Proc] The specifications.
22
+ # @param name [String, Symbol] The constant name of the specifications.
23
+ # @yield The specifications block that defines the test requirements
24
+ # @yieldreturn [void]
24
25
  #
25
26
  # @return [#test] The collection of specifications.
26
27
  #
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fix
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta9
4
+ version: 1.0.0.beta10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Kato
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-01-25 00:00:00.000000000 Z
10
+ date: 2024-12-24 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: defi
@@ -77,7 +76,6 @@ metadata:
77
76
  source_code_uri: https://github.com/fixrb/fix
78
77
  wiki_uri: https://github.com/fixrb/fix/wiki
79
78
  rubygems_mfa_required: 'true'
80
- post_install_message:
81
79
  rdoc_options: []
82
80
  require_paths:
83
81
  - lib
@@ -88,12 +86,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
88
86
  version: 3.2.0
89
87
  required_rubygems_version: !ruby/object:Gem::Requirement
90
88
  requirements:
91
- - - ">"
89
+ - - ">="
92
90
  - !ruby/object:Gem::Version
93
- version: 1.3.1
91
+ version: '0'
94
92
  requirements: []
95
- rubygems_version: 3.4.19
96
- signing_key:
93
+ rubygems_version: 3.6.2
97
94
  specification_version: 4
98
95
  summary: Specing framework.
99
96
  test_files: []