fix 1.0.0.beta2 → 1.0.0.beta6

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: efd28aa8b034a7e70f2ffcbe7ad441aeeb93bbd3e35ab1bc31ca66f231589232
4
- data.tar.gz: fca05e03672e0f3f5b51c943bc78234882f83eb14acf99c3fa7a7abc99e4be9b
3
+ metadata.gz: 361429a943a5149aeea4da4dd83150360db392275ec4d9d98e76969e60768dce
4
+ data.tar.gz: 6df8aaff424652d4e73cb163cc1dfd973c9a4a03ec2e2d6e351db5f87b0674a8
5
5
  SHA512:
6
- metadata.gz: d758dd2de2e9ef7273eb90eb15e9366e8ff4ed6594a772a1de14f6e1ed3b1df03be8170f133671a0b571da4a583363f9f871a219de2c52bd5c724452e62b18a7
7
- data.tar.gz: 29a3b83203f004d42d5824e384f4f022ccedecaaf32957a48ca8204d4a8778fc9da8759e5ad8f8a38579d8d599c81c55210260fe11c0ec6980e5bf49c30418e5
6
+ metadata.gz: 24a1c58a8e0db0ef62d97881eabc8a4ff0596d82c96f1dee40fc68edffdc17f0206c6d45aa11040e3b11af35038df58ee7bca1f6190330f91b1b384304dcc304
7
+ data.tar.gz: 0a5ff783abf6bce80c8ff4a3e3f2e938c004bf5cd02e8300f56650e6312638e911638ed41c9293047aa757ae73048cd412bae5b6cc031e43bab82a2f4b92e41c
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014-2020 Cyril Kato
3
+ Copyright (c) 2014-2021 Cyril Kato
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,31 +1,37 @@
1
1
  # Fix
2
2
 
3
- [![Build Status](https://api.travis-ci.org/fixrb/fix.svg?branch=master)][travis]
4
- [![Code Climate](https://codeclimate.com/github/fixrb/fix/badges/gpa.svg)][codeclimate]
5
- [![Gem Version](https://badge.fury.io/rb/fix.svg)][gem]
6
- [![Inline docs](https://inch-ci.org/github/fixrb/fix.svg?branch=master)][inchpages]
7
- [![Documentation](https://img.shields.io/:yard-docs-38c800.svg)][rubydoc]
8
- [![Gitter](https://badges.gitter.im/Join%20Chat.svg)][gitter]
3
+ [![Home](https://img.shields.io/badge/Home-fixrb.dev-00af8b)](https://fixrb.dev/)
4
+ [![Version](https://img.shields.io/github/v/tag/fixrb/fix?label=Version&logo=github)](https://github.com/fixrb/fix/releases)
5
+ [![Yard documentation](https://img.shields.io/badge/Yard-documentation-blue.svg?logo=github)](https://rubydoc.info/github/fixrb/fix/main)
6
+ [![CI](https://github.com/fixrb/fix/workflows/CI/badge.svg?branch=main)](https://github.com/fixrb/fix/actions?query=workflow%3Aci+branch%3Amain)
7
+ [![RuboCop](https://github.com/fixrb/fix/workflows/RuboCop/badge.svg?branch=main)](https://github.com/fixrb/fix/actions?query=workflow%3Arubocop+branch%3Amain)
8
+ [![License](https://img.shields.io/github/license/fixrb/fix?label=License&logo=github)](https://github.com/fixrb/fix/raw/main/LICENSE.md)
9
9
 
10
- > Specing framework for Ruby.
10
+ ⚠️ This project is still in the experimental phase. May be used at your own risk.
11
+
12
+ ![Fix specing framework for Ruby](https://github.com/fixrb/fix/raw/main/img/fix.jpg)
11
13
 
12
14
  ## Installation
13
15
 
14
16
  Add this line to your application's Gemfile:
15
17
 
16
18
  ```ruby
17
- gem 'fix', '>= 1.0.0.beta2'
19
+ gem "fix", ">= 1.0.0.beta6"
18
20
  ```
19
21
 
20
22
  And then execute:
21
23
 
22
- $ bundle
24
+ ```sh
25
+ bundle
26
+ ```
23
27
 
24
28
  Or install it yourself as:
25
29
 
26
- $ gem install fix --pre
30
+ ```sh
31
+ gem install fix --pre
32
+ ```
27
33
 
28
- ## Usage
34
+ ## Example
29
35
 
30
36
  Given this app:
31
37
 
@@ -33,59 +39,76 @@ Given this app:
33
39
  # examples/duck/app.rb
34
40
  class Duck
35
41
  def walks
36
- 'Klop klop!'
42
+ "Klop klop!"
37
43
  end
38
44
 
39
45
  def swims
40
- 'Swoosh...'
46
+ "Swoosh..."
41
47
  end
42
48
 
43
49
  def quacks
44
- puts 'Quaaaaaack!'
50
+ puts "Quaaaaaack!"
45
51
  end
46
52
  end
47
53
  ```
48
54
 
49
- When you run this:
55
+ And this fixed behavior:
50
56
 
51
57
  ```ruby
52
58
  # examples/duck/fix.rb
53
- require_relative 'app'
54
- require_relative '../../lib/fix'
55
59
 
56
- @bird = Duck.new
60
+ relative "fix"
61
+
62
+ Fix :Duck do
63
+ it MUST be_an_instance_of :Duck
57
64
 
58
- Fix(@bird) do
59
65
  on :swims do
60
- it { MUST eql 'Swoosh...' }
66
+ it MUST eql "Swoosh..."
61
67
  end
62
68
 
63
69
  on :speaks do
64
- it { MUST raise_exception NoMethodError }
70
+ it MUST raise_exception NoMethodError
65
71
  end
66
72
 
67
73
  on :sings do
68
- it { MAY eql '♪... ♫...' }
74
+ it MAY eql "♪... ♫..."
69
75
  end
70
76
  end
71
77
  ```
72
78
 
73
- Then the output should look like this:
79
+ When I run this test:
80
+
81
+ ```ruby
82
+ # examples/duck/test.rb
83
+
84
+ require_relative "app"
85
+ require_relative "fix"
86
+
87
+ Fix[:Duck].test { Duck.new }
88
+ ```
74
89
 
75
90
  ```sh
76
- ruby examples/duck/fix.rb
91
+ ruby examples/duck/test.rb
77
92
  ```
78
93
 
94
+ I should see this output:
95
+
79
96
  ```txt
80
- examples/duck/fix.rb:8: Success: expected to eql "Swoosh...".
81
- examples/duck/fix.rb:12: Success: undefined method `speaks' for #<Duck:0x00007fe3be868ea0>.
82
- examples/duck/fix.rb:16: NoMethodError: undefined method `sings' for #<Duck:0x00007fe3be868ea0>.
97
+ NoMethodError: undefined method `sings' for #<Duck:0x00007fc5289bcf68>.
98
+ Success: expected to eql "Swoosh...".
99
+ Success: undefined method `speaks' for #<Duck:0x00007fc5289bcf68>.
83
100
  ```
84
101
 
102
+ ## Test suite
103
+
104
+ __Fix__'s specifications will be [fixed here](https://github.com/fixrb/fix/blob/main/fix/) and will be tested against __Fix__'s codebase executing [test/*](https://github.com/fixrb/fix/blob/main/test/)'s files.
105
+
85
106
  ## Contact
86
107
 
87
- * Home page: https://fixrb.dev/
88
- * Source code: https://github.com/fixrb/fix/issues
108
+ * Home page: [https://fixrb.dev/](https://fixrb.dev/)
109
+ * Source code: [https://github.com/fixrb/fix](https://github.com/fixrb/fix)
110
+ * API Doc: [https://rubydoc.info/gems/fix](https://rubydoc.info/gems/fix)
111
+ * Twitter: [https://twitter.com/fix\_rb](https://twitter.com/fix\_rb)
89
112
 
90
113
  ## Versioning
91
114
 
@@ -93,20 +116,13 @@ __Fix__ follows [Semantic Versioning 2.0](https://semver.org/).
93
116
 
94
117
  ## License
95
118
 
96
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
119
+ The [gem](https://rubygems.org/gems/fix) is available as open source under the terms of the [MIT License](https://github.com/fixrb/fix/raw/main/LICENSE.md).
97
120
 
98
121
  ***
99
122
 
100
123
  <p>
101
124
  This project is sponsored by:<br />
102
125
  <a href="https://sashite.com/"><img
103
- src="https://github.com/fixrb/fix/raw/master/img/sashite.png"
126
+ src="https://github.com/fixrb/fix/raw/main/img/sashite.png"
104
127
  alt="Sashite" /></a>
105
128
  </p>
106
-
107
- [travis]: https://travis-ci.org/fixrb/fix
108
- [codeclimate]: https://codeclimate.com/github/fixrb/fix
109
- [gem]: https://rubygems.org/gems/fix
110
- [inchpages]: https://inch-ci.org/github/fixrb/fix
111
- [rubydoc]: https://rubydoc.info/gems/fix/frames
112
- [gitter]: https://gitter.im/fixrb/fix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
data/lib/fix.rb CHANGED
@@ -1,25 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative File.join("fix", "doc")
4
+ require_relative File.join("fix", "test")
5
+
6
+ require_relative "kernel"
7
+
3
8
  # Namespace for the Fix framework.
4
- #
5
9
  module Fix
6
- # Specs are built with this method.
10
+ # Test a built specification.
7
11
  #
8
- # @example 42 must be equal to 42
9
- # describe(42) do
10
- # it { MUST equal 42 }
11
- # end
12
+ # @example Run _Answer_ specification against `42`.
13
+ # Fix[:Answer].call(42)
12
14
  #
13
- # @param front_object [BasicObject] The front object.
14
- # @param options [Hash] Some options.
15
- # @param specs [Proc] The set of specs.
15
+ # @example Test _Answer_ specification against `42`.
16
+ # Fix[:Answer].matches? { 42 }
16
17
  #
17
- # @raise [SystemExit] The result of the test.
18
- def self.describe(front_object, **lets, &block)
19
- c = Context.new(front_object, ::Defi.send(:itself), **lets)
20
- c.instance_eval(&block)
18
+ # @param name [String, Symbol] The name of the specification document.
19
+ #
20
+ # @return [::Fix::Dsl] The specification document.
21
+ def self.[](name)
22
+ Test.new(*Doc.const_get(name).const_get(:CONTEXTS))
21
23
  end
22
24
  end
23
-
24
- require_relative 'kernel'
25
- require_relative File.join('fix', 'context')
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fix
4
+ # Send log messages to the console.
5
+ module Console
6
+ # @param report [::Expresenter::Pass] Passed expectation result presenter.
7
+ #
8
+ # @see https://github.com/fixrb/expresenter
9
+ #
10
+ # @return [nil] Add a colored message to `$stdout`.
11
+ def self.passed_spec(report)
12
+ puts report.colored_string
13
+ end
14
+
15
+ # @param report [::Expresenter::Fail] Failed expectation result presenter.
16
+ #
17
+ # @see https://github.com/fixrb/expresenter
18
+ #
19
+ # @raise [SystemExit] Terminate execution immediately with colored message.
20
+ def self.failed_spec(report)
21
+ abort report.colored_string
22
+ end
23
+ end
24
+ end
data/lib/fix/doc.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fix
4
+ # Module for storing spec documents.
5
+ module Doc
6
+ end
7
+ end
data/lib/fix/dsl.rb ADDED
@@ -0,0 +1,164 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "defi"
4
+ require "matchi/helper"
5
+ require "spectus"
6
+
7
+ require_relative "test"
8
+
9
+ module Fix
10
+ # Abstract class for handling the domain-specific language.
11
+ class Dsl
12
+ include ::Matchi::Helper
13
+
14
+ # Sets a user-defined property.
15
+ #
16
+ # @example
17
+ # require "fix"
18
+ #
19
+ # Fix do
20
+ # let(:name) { "Bob" }
21
+ # end
22
+ #
23
+ # @param name [String, Symbol] The name of the property.
24
+ # @param block [Proc] The content of the method to define.
25
+ #
26
+ # @return [Symbol] A private method that define the block content.
27
+ #
28
+ # @api public
29
+ def self.let(name, &block)
30
+ private define_method(name, &block)
31
+ end
32
+
33
+ # Defines an example group with user-defined properties that describes a
34
+ # unit to be tested.
35
+ #
36
+ # @example
37
+ # require "fix"
38
+ #
39
+ # Fix do
40
+ # with :password, "secret" do
41
+ # it MUST equal true
42
+ # end
43
+ # end
44
+ #
45
+ # @param kwargs [Hash] The list of propreties.
46
+ # @param block [Proc] The block to define the specs.
47
+ #
48
+ # @api public
49
+ def self.with(**kwargs, &block)
50
+ klass = ::Class.new(self)
51
+ klass.const_get(:CONTEXTS) << klass
52
+ kwargs.each { |name, value| klass.let(name) { value } }
53
+ klass.instance_eval(&block)
54
+ klass
55
+ end
56
+
57
+ # Defines an example group that describes a unit to be tested.
58
+ #
59
+ # @example
60
+ # require "fix"
61
+ #
62
+ # Fix do
63
+ # on :+, 2 do
64
+ # it MUST be 42
65
+ # end
66
+ # end
67
+ #
68
+ # @param method_name [String, Symbol] The method to send to the subject.
69
+ # @param block [Proc] The block to define the specs.
70
+ #
71
+ # @api public
72
+ def self.on(method_name, *args, **kwargs, &block)
73
+ klass = ::Class.new(self)
74
+ klass.const_get(:CONTEXTS) << klass
75
+
76
+ const_set("Child#{block.object_id}", klass)
77
+
78
+ klass.define_singleton_method(:challenges) do
79
+ super() + [::Defi.send(method_name, *args, **kwargs)]
80
+ end
81
+
82
+ def klass.initialize
83
+ if subject.raised?
84
+ subject
85
+ else
86
+ challenge = ::Defi.send(method_name, *args, **kwargs)
87
+ challenge.to(subject.call)
88
+ end
89
+ end
90
+
91
+ klass.instance_eval(&block)
92
+ klass
93
+ end
94
+
95
+ # Defines a concrete spec definition.
96
+ #
97
+ # @example
98
+ # require "fix"
99
+ #
100
+ # Fix { it MUST equal 42 }
101
+ #
102
+ # @api public
103
+ def self.it(requirement)
104
+ define_method("test_#{requirement.object_id}") { requirement }
105
+ end
106
+
107
+ # @todo Move this method inside "fix-its" gem.
108
+ def self.its(method_name, requirement)
109
+ klass = ::Class.new(self)
110
+ klass.const_get(:CONTEXTS) << klass
111
+
112
+ const_set("Child#{requirement.object_id}", klass)
113
+
114
+ klass.define_singleton_method(:challenges) do
115
+ super() + [::Defi.send(method_name)]
116
+ end
117
+
118
+ def klass.initialize
119
+ if subject.raised?
120
+ subject
121
+ else
122
+ challenge = ::Defi.send(method_name, *args, **kwargs)
123
+ challenge.to(subject.call)
124
+ end
125
+ end
126
+
127
+ klass.it(requirement)
128
+ end
129
+
130
+ def self.challenges
131
+ []
132
+ end
133
+
134
+ def self.test(&subject)
135
+ Test.new(self).test(&subject)
136
+ end
137
+
138
+ private_class_method :challenges
139
+
140
+ private
141
+
142
+ attr_reader :subject
143
+
144
+ def initialize(&subject)
145
+ @subject = ::Defi::Value.new(&subject)
146
+ end
147
+
148
+ ::Matchi::Matcher.constants.each do |matcher_const|
149
+ next if matcher_const.equal?(:Base)
150
+
151
+ matcher_klass = ::Matchi::Matcher.const_get(matcher_const)
152
+
153
+ define_singleton_method(matcher_klass.to_sym) do |*args|
154
+ matcher_klass.new(*args)
155
+ end
156
+ end
157
+
158
+ ::Spectus.methods(false).each do |method_name|
159
+ define_singleton_method(method_name.upcase) do |matcher|
160
+ ::Spectus.public_send(method_name, matcher)
161
+ end
162
+ end
163
+ end
164
+ end
data/lib/fix/test.rb ADDED
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "expresenter/fail"
4
+
5
+ require_relative "console"
6
+ require_relative "doc"
7
+
8
+ module Fix
9
+ # Module for testing spec documents.
10
+ class Test
11
+ attr_reader :contexts
12
+
13
+ def initialize(*contexts)
14
+ @contexts = contexts
15
+ end
16
+
17
+ def test(&block)
18
+ requirements(&block)
19
+ exit(true)
20
+ end
21
+
22
+ private
23
+
24
+ def requirements(&block)
25
+ contexts.flat_map do |context|
26
+ sandbox = context.new
27
+ sandbox.public_methods(false).shuffle.map do |public_method|
28
+ definition = sandbox.public_send(public_method)
29
+
30
+ report = begin
31
+ definition.call do
32
+ front_object = instance_eval(&block)
33
+
34
+ context.send(:challenges).inject(front_object) do |object, challenge|
35
+ challenge.to(object).call
36
+ end
37
+ end
38
+ rescue ::Expresenter::Fail => e
39
+ e
40
+ end
41
+
42
+ if report.passed?
43
+ Console.passed_spec report
44
+ else
45
+ Console.failed_spec report
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
data/lib/kernel.rb CHANGED
@@ -1,9 +1,32 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative File.join("fix", "doc")
4
+ require_relative File.join("fix", "dsl")
5
+ require_relative File.join("fix", "test")
6
+
7
+ # The Kernel module.
3
8
  module Kernel
9
+ # Specifications are built with this method.
10
+ #
11
+ # @example Fix 42 such as it must be equal to 42.
12
+ # Fix :Answer do
13
+ # it { MUST equal 42 }
14
+ # end
15
+ #
16
+ # @param name [String, Symbol] The name of the specification document.
17
+ # @param block [Proc] The specifications.
18
+ #
19
+ # @return [Class] The specification document.
20
+ #
4
21
  # rubocop:disable Naming/MethodName
5
- def Fix(subject, **lets, &block)
6
- ::Fix.describe(subject, **lets, &block)
22
+ def Fix(name = nil, &block)
23
+ klass = ::Class.new(::Fix::Dsl)
24
+ klass.const_set(:CONTEXTS, [klass])
25
+ klass.instance_eval(&block)
26
+
27
+ ::Fix::Doc.const_set(name, klass) unless name.nil?
28
+
29
+ ::Fix::Test.new(*klass.const_get(:CONTEXTS))
7
30
  end
8
31
  # rubocop:enable Naming/MethodName
9
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fix
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta2
4
+ version: 1.0.0.beta6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Kato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-12 00:00:00.000000000 Z
11
+ date: 2021-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: defi
@@ -16,70 +16,84 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.4
19
+ version: 2.0.5
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.4
26
+ version: 2.0.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: matchi
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.2.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.2.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: spectus
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: 3.1.2
47
+ version: 4.0.0
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: 3.1.2
54
+ version: 4.0.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - "~>"
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
- version: '2.1'
61
+ version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - "~>"
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
- version: '2.1'
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - "~>"
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
- version: '13.0'
75
+ version: '0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - "~>"
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
- version: '13.0'
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: rubocop
84
+ name: rubocop-md
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - "~>"
87
+ - - ">="
74
88
  - !ruby/object:Gem::Version
75
- version: '0.79'
89
+ version: '0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - "~>"
94
+ - - ">="
81
95
  - !ruby/object:Gem::Version
82
- version: '0.79'
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rubocop-performance
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -94,34 +108,76 @@ dependencies:
94
108
  - - ">="
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-thread_safety
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
97
153
  - !ruby/object:Gem::Dependency
98
154
  name: simplecov
99
155
  requirement: !ruby/object:Gem::Requirement
100
156
  requirements:
101
- - - "~>"
157
+ - - ">="
102
158
  - !ruby/object:Gem::Version
103
- version: '0.17'
159
+ version: '0'
104
160
  type: :development
105
161
  prerelease: false
106
162
  version_requirements: !ruby/object:Gem::Requirement
107
163
  requirements:
108
- - - "~>"
164
+ - - ">="
109
165
  - !ruby/object:Gem::Version
110
- version: '0.17'
166
+ version: '0'
111
167
  - !ruby/object:Gem::Dependency
112
168
  name: yard
113
169
  requirement: !ruby/object:Gem::Requirement
114
170
  requirements:
115
- - - "~>"
171
+ - - ">="
116
172
  - !ruby/object:Gem::Version
117
- version: '0.9'
173
+ version: '0'
118
174
  type: :development
119
175
  prerelease: false
120
176
  version_requirements: !ruby/object:Gem::Requirement
121
177
  requirements:
122
- - - "~>"
178
+ - - ">="
123
179
  - !ruby/object:Gem::Version
124
- version: '0.9'
180
+ version: '0'
125
181
  description: Specing framework for Ruby.
126
182
  email: contact@cyril.email
127
183
  executables: []
@@ -131,16 +187,19 @@ files:
131
187
  - LICENSE.md
132
188
  - README.md
133
189
  - lib/fix.rb
134
- - lib/fix/context.rb
135
- - lib/fix/expectation_result_not_found_error.rb
136
- - lib/fix/it.rb
137
- - lib/fix/suspicious_success_error.rb
190
+ - lib/fix/console.rb
191
+ - lib/fix/doc.rb
192
+ - lib/fix/dsl.rb
193
+ - lib/fix/test.rb
138
194
  - lib/kernel.rb
139
195
  homepage: https://fixrb.dev/
140
196
  licenses:
141
197
  - MIT
142
198
  metadata:
199
+ bug_tracker_uri: https://github.com/fixrb/fix/issues
200
+ documentation_uri: https://rubydoc.info/gems/r_spec-clone
143
201
  source_code_uri: https://github.com/fixrb/fix
202
+ wiki_uri: https://github.com/fixrb/fix/wiki
144
203
  post_install_message:
145
204
  rdoc_options: []
146
205
  require_paths:
@@ -149,14 +208,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
149
208
  requirements:
150
209
  - - ">="
151
210
  - !ruby/object:Gem::Version
152
- version: 2.3.0
211
+ version: 2.7.0
153
212
  required_rubygems_version: !ruby/object:Gem::Requirement
154
213
  requirements:
155
214
  - - ">"
156
215
  - !ruby/object:Gem::Version
157
216
  version: 1.3.1
158
217
  requirements: []
159
- rubygems_version: 3.1.2
218
+ rubygems_version: 3.1.6
160
219
  signing_key:
161
220
  specification_version: 4
162
221
  summary: Specing framework for Ruby.
data/lib/fix/context.rb DELETED
@@ -1,147 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'aw'
4
- require 'defi'
5
-
6
- module Fix
7
- # Wraps the target of challenge.
8
- class Context
9
- RESERVED_KEYWORDS = %i[
10
- alias
11
- and
12
- begin
13
- break
14
- case
15
- catch
16
- class
17
- def
18
- defined?
19
- do
20
- else
21
- elsif
22
- end
23
- ensure
24
- fail
25
- false
26
- for
27
- if
28
- in
29
- module
30
- next
31
- nil
32
- not
33
- or
34
- raise
35
- redo
36
- rescue
37
- retry
38
- return
39
- self
40
- super
41
- then
42
- throw
43
- true
44
- undef
45
- unless
46
- until
47
- when
48
- while
49
- yield
50
- ].freeze
51
-
52
- attr_reader :callable
53
-
54
- def initialize(subject, challenge, before_hooks_counter = 0, *hooks, **lets)
55
- @subject = subject
56
- @callable = challenge.to(subject)
57
- @before_hooks = hooks[0, before_hooks_counter]
58
- @after_hooks = hooks[before_hooks_counter..-1]
59
- @lets = lets
60
- end
61
-
62
- def before(&block)
63
- @before_hooks << block
64
- end
65
-
66
- def after(&block)
67
- @after_hooks << block
68
- end
69
-
70
- def let(name, &block)
71
- raise ::TypeError, "expected a Symbol, got #{name.class}" unless name.is_a?(::Symbol)
72
- raise ::NameError, "wrong method name `#{name}'" unless name.match(/\A[a-z][a-z0-9_]+[?!]?\z/)
73
- raise ::NameError, "reserved keyword name `#{name}'" if RESERVED_KEYWORDS.include?(name)
74
- raise ::NameError, "reserved method name `#{name}'" if respond_to?(name, true) && !@lets.key?(name)
75
-
76
- @lets.update(name => block.call)
77
- rescue ::SystemExit => e
78
- raise SuspiciousSuccessError, "attempt `#{name}' to bypass the tests" if e.success?
79
- raise e
80
- end
81
-
82
- def let!(name, &block)
83
- raise ::TypeError, "expected a Symbol, got #{name.class}" unless name.is_a?(::Symbol)
84
- raise ::NameError, "wrong method name `#{name}'" unless name.match(/\A[a-z][a-z0-9_]+[?!]?\z/)
85
- raise ::NameError, "reserved keyword name `#{name}'" if RESERVED_KEYWORDS.include?(name)
86
- raise ::NameError, "reserved method name `#{name}'" if respond_to?(name, true) && !@lets.key?(name)
87
-
88
- @lets.update(name => ::Aw.fork! { block.call })
89
- rescue ::SystemExit => e
90
- raise SuspiciousSuccessError, "attempt `#{name}' to bypass the tests" if e.success?
91
- raise e
92
- end
93
-
94
- # Verify the expectation.
95
- #
96
- # @param block [Proc] A spec to compare against the computed actual value.
97
- #
98
- # @return [::Spectus::Result::Pass, ::Spectus::Result::Fail] Pass or fail.
99
- def it(_message = nil, &block)
100
- print "#{block.source_location.join(':')}: "
101
- i = It.new(callable, **@lets)
102
- @before_hooks.each { |hook| i.instance_eval(&hook) }
103
- result = i.instance_eval(&block)
104
- puts result.colored_string
105
- rescue ::Spectus::Result::Fail => result
106
- abort result.colored_string
107
- ensure
108
- @after_hooks.each { |hook| i.instance_eval(&hook) }
109
- raise ExpectationResultNotFoundError unless result.is_a?(::Spectus::Result::Common)
110
- end
111
-
112
- def on(name, *args, **options, &block)
113
- if callable.raised?
114
- actual = callable
115
- challenge = ::Defi.send(:call)
116
- else
117
- actual = callable.object
118
- challenge = ::Defi.send(name, *args, **options)
119
- end
120
-
121
- o = Context.new(actual, challenge, @before_hooks.length, *@before_hooks + @after_hooks, **@lets)
122
- o.instance_eval(&block)
123
- end
124
-
125
- def with(_message = nil, **new_lets, &block)
126
- actual = callable.object
127
- challenge = ::Defi.send(:itself)
128
-
129
- c = Context.new(actual, challenge, @before_hooks.length, *@before_hooks + @after_hooks, **@lets.merge(new_lets))
130
- c.instance_eval(&block)
131
- end
132
-
133
- private
134
-
135
- def method_missing(name, *args, &block)
136
- @lets.fetch(name) { super }
137
- end
138
-
139
- def respond_to_missing?(name, include_private = false)
140
- @lets.key?(name) || super
141
- end
142
- end
143
- end
144
-
145
- require_relative 'it'
146
- require_relative 'expectation_result_not_found_error'
147
- require_relative 'suspicious_success_error'
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fix
4
- class ExpectationResultNotFoundError < ::RuntimeError; end
5
- end
data/lib/fix/it.rb DELETED
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spectus/expectation_target'
4
- require 'matchi/helper'
5
-
6
- module Fix
7
- # Wraps the target of an expectation.
8
- class It < ::Spectus::ExpectationTarget
9
- include ::Matchi::Helper
10
-
11
- # Create a new expection target
12
- #
13
- # @param callable [#call] The object to test.
14
- def initialize(callable, **lets)
15
- raise unless callable.respond_to?(:call)
16
-
17
- @callable = callable
18
- @lets = lets
19
- end
20
-
21
- private
22
-
23
- def method_missing(name, *args, &block)
24
- @lets.fetch(name) { super }
25
- end
26
-
27
- def respond_to_missing?(name, include_private = false)
28
- @lets.key?(name) || super
29
- end
30
- end
31
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fix
4
- class SuspiciousSuccessError < ::StandardError; end
5
- end