Skip to content

Commit 573da97

Browse files
committed
chore: beta7
1 parent 9fddfc2 commit 573da97

21 files changed

+266
-203
lines changed

.rubocop.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
inherit_from: .rubocop_todo.yml
2-
31
AllCops:
42
NewCops: enable
53
TargetRubyVersion: 2.7
@@ -14,7 +12,6 @@ require:
1412
- rubocop-rspec
1513
- rubocop-thread_safety
1614

17-
# Enforcing double quotes reduces the times where you need to switch to Crystal.
1815
Style/StringLiterals:
1916
EnforcedStyle: double_quotes
2017

@@ -32,6 +29,11 @@ Layout/LineLength:
3229
- README.md
3330
- benchmark/**/*
3431

32+
Metrics/BlockLength:
33+
Exclude:
34+
- examples/**/*
35+
- fix.gemspec
36+
3537
Metrics/ParameterLists:
3638
Max: 6
3739

.rubocop_todo.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.simplecov

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# frozen_string_literal: true
22

33
SimpleCov.command_name "Fix"
4-
54
SimpleCov.start

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
fix (1.0.0.beta6)
4+
fix (1.0.0.beta7)
55
defi (~> 2.0.5)
66
matchi (~> 3.2.0)
77
spectus (~> 4.0.2)

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
Add this line to your application's Gemfile:
2424

2525
```ruby
26-
gem "fix", ">= 1.0.0.beta6"
26+
gem "fix", ">= 1.0.0.beta7"
2727
```
2828

2929
And then execute:
@@ -108,10 +108,6 @@ Success: undefined method `speaks' for #<Duck:0x00007fc55b3c46f0>.
108108
NoMethodError: undefined method `sings' for #<Duck:0x00007fc558aab6d8>.
109109
```
110110

111-
## Test suite
112-
113-
__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.
114-
115111
## Contact
116112

117113
* Home page: [https://fixrb.dev/](https://fixrb.dev/)

VERSION.semver

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.0.beta6
1+
1.0.0.beta7

examples/duck/app.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
# frozen_string_literal: true
22

3+
# A small Duck implementation.
34
class Duck
5+
attr_reader :name
6+
7+
def initialize(name)
8+
@name = name
9+
end
10+
11+
def say_hi
12+
"Hi, my name is #{name}!"
13+
end
14+
415
def walks
516
"Klop klop!"
617
end
@@ -12,4 +23,8 @@ def swims
1223
def quacks
1324
puts "Quaaaaaack!"
1425
end
26+
27+
def inspect
28+
"<#{name}>"
29+
end
1530
end

examples/duck/fix.rb

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,50 @@
33
require_relative File.join("..", "..", "lib", "fix")
44

55
Fix :Duck do
6+
let(:name) { "Bob" }
7+
68
it SHOULD be_an_instance_of :Duck
79

10+
on :say_hi do
11+
let(:name) { "Picsou" }
12+
13+
it MUST eq "Hi, my name is Picsou!"
14+
end
15+
16+
on :say_hi do
17+
with name: "Picsou" do
18+
it MUST eq "Hi, my name is Picsou!"
19+
end
20+
21+
with name: "Donald" do
22+
it MUST eq "Hi, my name is Donald!"
23+
end
24+
end
25+
826
on :swims do
927
it MUST be_an_instance_of :String
10-
it MUST eql "Swoosh..."
28+
it MUST eq "Swoosh..."
29+
30+
on :length do
31+
it MUST be 9
32+
end
1133
end
1234

13-
on :speaks, it(MUST(raise_exception(NoMethodError)))
14-
on :sings, it(MAY(eql "♪... ♫..."))
35+
on :walks do
36+
on :length do
37+
it MUST be 10
38+
end
39+
end
40+
41+
on :speaks do
42+
it MUST raise_exception NoMethodError
43+
end
44+
45+
on :sings do
46+
it MAY eq "♪... ♫..."
47+
end
48+
49+
on :quacks do
50+
it MUST be nil
51+
end
1552
end

examples/duck/test.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
require_relative "app"
44
require_relative "fix"
55

6-
Fix[:Duck].test { Duck.new }
6+
Fix[:Duck].test do
7+
Duck.new(name)
8+
end

examples/magic_number/fix.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,13 @@
33
require_relative File.join("..", "..", "lib", "fix")
44

55
Fix :MagicNumber do
6-
its :abs, MUST(equal(42))
7-
its :next, MUST(equal(-41))
8-
96
on :-, 1 do
10-
its :abs, MUST(equal(43))
11-
its :next, MUST(equal(-42))
12-
137
it MUST equal(-43)
148

159
on :-, 1 do
1610
it MUST equal(-44)
1711

1812
with zero: 0 do
19-
its :boom, MAY(equal(9))
20-
2113
on :-, 3 do
2214
it MUST equal(-47)
2315
end
@@ -53,8 +45,6 @@
5345
number1 = 40
5446
# let(:number1) { number1 + 2 }
5547

56-
zero = 0
57-
5848
foo = "FOO!"
5949

6050
it MUST_NOT equal number1

fix.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Gem::Specification.new do |spec|
55
spec.version = File.read("VERSION.semver").chomp
66
spec.author = "Cyril Kato"
77
spec.email = "[email protected]"
8-
spec.summary = "Specing framework for Ruby."
8+
spec.summary = "Specing framework."
99
spec.description = spec.summary
1010
spec.homepage = "https://fixrb.dev/"
1111
spec.license = "MIT"

lib/fix.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
# frozen_string_literal: true
22

3-
require_relative File.join("fix", "doc")
4-
require_relative File.join("fix", "test")
3+
require_relative File.join("fix", "set")
54

65
require_relative "kernel"
76

87
# Namespace for the Fix framework.
8+
#
9+
# @api public
910
module Fix
1011
# Test a built specification.
1112
#
1213
# @example Run _Answer_ specification against `42`.
13-
# Fix[:Answer].call(42)
14-
#
15-
# @example Test _Answer_ specification against `42`.
16-
# Fix[:Answer].matches? { 42 }
14+
# Fix[:Answer].test(42)
1715
#
1816
# @param name [String, Symbol] The name of the specification document.
1917
#
20-
# @return [::Fix::Dsl] The specification document.
18+
# @return [::Fix::Test] The specification document.
2119
def self.[](name)
22-
Test.new(*Doc.const_get(name).const_get(:CONTEXTS))
20+
::Fix::Set.load(name)
2321
end
2422
end

lib/fix/console.rb

Lines changed: 0 additions & 24 deletions
This file was deleted.

lib/fix/doc.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22

33
module Fix
44
# Module for storing spec documents.
5+
#
6+
# @api private
57
module Doc
8+
# @param name [String, Symbol] The name of the specification document.
9+
def self.fetch(name)
10+
const_get("#{name}::CONTEXTS")
11+
end
12+
13+
# @param contexts [Array<::Fix::Dsl>] The list of contexts document.
14+
def self.specs(*contexts)
15+
contexts.flat_map do |context|
16+
env = context.new
17+
18+
env.public_methods(false).map do |public_method|
19+
[env] + env.public_send(public_method)
20+
end
21+
end
22+
end
623
end
724
end

0 commit comments

Comments
 (0)