fix 0.18.2 → 0.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +2 -2
  3. data/README.md +384 -84
  4. data/lib/fix/builder.rb +101 -0
  5. data/lib/fix/doc.rb +59 -0
  6. data/lib/fix/dsl.rb +139 -0
  7. data/lib/fix/error/invalid_specification_name.rb +12 -0
  8. data/lib/fix/error/missing_specification_block.rb +14 -0
  9. data/lib/fix/error/missing_subject_block.rb +15 -0
  10. data/lib/fix/error/specification_not_found.rb +12 -0
  11. data/lib/fix/matcher.rb +76 -0
  12. data/lib/fix/requirement.rb +119 -0
  13. data/lib/fix/run.rb +88 -0
  14. data/lib/fix/set.rb +210 -0
  15. data/lib/fix.rb +85 -20
  16. data/lib/kernel.rb +49 -0
  17. metadata +42 -153
  18. data/.gitignore +0 -11
  19. data/.rubocop.yml +0 -1
  20. data/.rubocop_todo.yml +0 -25
  21. data/.travis.yml +0 -28
  22. data/.yardopts +0 -1
  23. data/CODE_OF_CONDUCT.md +0 -13
  24. data/Gemfile +0 -5
  25. data/Rakefile +0 -23
  26. data/VERSION.semver +0 -1
  27. data/bin/console +0 -8
  28. data/bin/setup +0 -6
  29. data/checksum/fix-0.0.1.pre.gem.sha512 +0 -1
  30. data/checksum/fix-0.1.0.gem.sha512 +0 -1
  31. data/checksum/fix-0.1.0.pre.gem.sha512 +0 -1
  32. data/checksum/fix-0.10.0.gem.sha512 +0 -1
  33. data/checksum/fix-0.11.0.gem.sha512 +0 -1
  34. data/checksum/fix-0.11.1.gem.sha512 +0 -1
  35. data/checksum/fix-0.12.0.gem.sha512 +0 -1
  36. data/checksum/fix-0.12.1.gem.sha512 +0 -1
  37. data/checksum/fix-0.12.2.gem.sha512 +0 -1
  38. data/checksum/fix-0.12.3.gem.sha512 +0 -1
  39. data/checksum/fix-0.13.0.gem.sha512 +0 -1
  40. data/checksum/fix-0.14.0.gem.sha512 +0 -1
  41. data/checksum/fix-0.14.1.gem.sha512 +0 -1
  42. data/checksum/fix-0.15.0.gem.sha512 +0 -1
  43. data/checksum/fix-0.15.2.gem.sha512 +0 -1
  44. data/checksum/fix-0.16.0.gem.sha512 +0 -1
  45. data/checksum/fix-0.17.0.gem.sha512 +0 -1
  46. data/checksum/fix-0.17.1.gem.sha512 +0 -1
  47. data/checksum/fix-0.17.2.gem.sha512 +0 -1
  48. data/checksum/fix-0.18.0.gem.sha512 +0 -1
  49. data/checksum/fix-0.18.1.gem.sha512 +0 -1
  50. data/checksum/fix-0.2.0.gem.sha512 +0 -1
  51. data/checksum/fix-0.3.0.gem.sha512 +0 -1
  52. data/checksum/fix-0.4.0.gem.sha512 +0 -1
  53. data/checksum/fix-0.5.0.gem.sha512 +0 -1
  54. data/checksum/fix-0.6.0.gem.sha512 +0 -1
  55. data/checksum/fix-0.6.1.gem.sha512 +0 -1
  56. data/checksum/fix-0.7.0.gem.sha512 +0 -1
  57. data/checksum/fix-0.8.0.gem.sha512 +0 -1
  58. data/checksum/fix-0.9.0.gem.sha512 +0 -1
  59. data/checksum/fix-0.9.1.gem.sha512 +0 -1
  60. data/fix.gemspec +0 -29
  61. data/lib/fix/it.rb +0 -41
  62. data/lib/fix/on.rb +0 -139
  63. data/lib/fix/report.rb +0 -120
  64. data/lib/fix/test.rb +0 -89
  65. data/pkg_checksum +0 -12
data/.travis.yml DELETED
@@ -1,28 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- cache: bundler
4
- before_install:
5
- - gem install bundler
6
- script:
7
- - bundle exec rubocop
8
- - bundle exec rake test
9
- rvm:
10
- - 2.3.8
11
- - 2.4.5
12
- - 2.5.3
13
- - 2.6.3
14
- - ruby-head
15
- - jruby-head
16
- - rbx-3
17
- matrix:
18
- allow_failures:
19
- - rvm: ruby-head
20
- - rvm: jruby-head
21
- - rvm: rbx-3
22
- notifications:
23
- webhooks:
24
- urls:
25
- - https://webhooks.gitter.im/e/a44b19cc5cf6db25fa87
26
- on_success: change
27
- on_failure: always
28
- on_start: never
data/.yardopts DELETED
@@ -1 +0,0 @@
1
- - README.md
data/CODE_OF_CONDUCT.md DELETED
@@ -1,13 +0,0 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
-
5
- We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
-
7
- Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
-
9
- Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
-
11
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
-
13
- This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile DELETED
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- gemspec
data/Rakefile DELETED
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
- require 'rake/testtask'
5
- require 'rubocop/rake_task'
6
-
7
- RuboCop::RakeTask.new
8
-
9
- Rake::TestTask.new do |t|
10
- t.verbose = true
11
- t.warning = true
12
- t.pattern = File.join('test', '**', 'test_*.rb')
13
- end
14
-
15
- namespace :test do
16
- task :coverage do
17
- ENV['COVERAGE'] = 'true'
18
- Rake::Task['test'].invoke
19
- end
20
- end
21
-
22
- task(:doc_stats) { ruby '-S yard stats' }
23
- task default: %i[test doc_stats rubocop]
data/VERSION.semver DELETED
@@ -1 +0,0 @@
1
- 0.18.2
data/bin/console DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'bundler/setup'
5
- require 'fix'
6
-
7
- require 'irb'
8
- IRB.start
data/bin/setup DELETED
@@ -1,6 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -euo pipefail
4
- IFS=$'\n\t'
5
-
6
- bundle install
@@ -1 +0,0 @@
1
- f07e9c106cca645ba0df7a5aee870d07c41879410c2768bfb66c64e930d2b671dab08ded95d94db3f6652a93037eac5009a6b7de980b7a054aed8872fca851fe
@@ -1 +0,0 @@
1
- fa1c66381b7d94687f9562af58230a7d6039adea59a4cad0eb8c04691d620b9f1105e796f311b884f9bdb5d9eda585834be1cafe69d8540141424bfa08df68f3
@@ -1 +0,0 @@
1
- 3ad80f61582fed9e76a0724fd5fff6138b849865a99a1ac6622ec8c29e67ee4eaae4727b97d53fd534a822c82830c57a77ba35aafaf09bff08e6e0385a8864d6
@@ -1 +0,0 @@
1
- f5442fc31ceda7b936fbf29cff21b657dcf65c206cb1af1937453580401dfe62598a88701162a7835470961ddf5fa82ef1bfdd83ca9e3581947cf1505e82f3e1
@@ -1 +0,0 @@
1
- 3205bd172dc4bdbc7ab6f213420e43389278b1138f6cf34a595a227432a00e080513edbed75d4fd6f8387796e403344fa69b05134ca1b917a588012d61e57b52
@@ -1 +0,0 @@
1
- c7c3e73eafdbeecc61073bd643dc7eb6e5f9686fe5e3f4bc4e23889de3dcf3598f3d4b88e813cb5023e06ef4f44c5437f1f80351459668ef8403d3248d27468e
@@ -1 +0,0 @@
1
- b400e64d3b3b8006b6e37459ff5608001bf42d087432e2acae1f28bc56b383ecb97c6dd76c0d24bd4c0f4cc14be59d88121009501b74a8a09a26d3e4a42d7950
@@ -1 +0,0 @@
1
- 3867c77b30709a95156d9910e5be5e87ebdfa2d535c46d776aa0be149e398b660654544d478cdb8353d2ae77c5b258e9db3ef17e7b9326b56d5e5880b7be654b
@@ -1 +0,0 @@
1
- d2bead1bb52e8ba7d03c68bb668f8c064080be66025eea22465f71cbb38f37fda2bd15e4f53ee014b2b665c9a65e5065b3b27c2b351fa17cea7cad3c1799bc3d
@@ -1 +0,0 @@
1
- 966ba13292877a34c883227f8dfe7018f7e2e0f8ac543a1b8e4749540143065ddafed82e283ee5e887c3a84e621d9e362b4ffa6d8aa5621bd3ff69e5305ca250
@@ -1 +0,0 @@
1
- fc5d67a1e3da5d4be5c3adcd2df86b464300fd3d832430392ccc3aba6331be04fa0d827b55a6ea634910c4a46b40c336c713155a0ca5d0d9cbef663643f1bd59
@@ -1 +0,0 @@
1
- 578f4552e1e18fe8e4e8e720718901115ff8f9178f421b694c221299223eab26a2465692f4a5d7a2e03df7a212bcbba5cc2d25f5cb87577d6fe99004cd5152f7
@@ -1 +0,0 @@
1
- 99234a8fbebfeddfbc4d7665ab10b2d2f340f1f10faff21702da4040afb1e3f56041b2fe00d67b16fa0515a768de4767e6bc1fc38d0cb5d3cfcb41163593836f
@@ -1 +0,0 @@
1
- 7a17bcad2a2f195dad9435ea619728b22dbd21624c6b314a1b7901da7e2156184457ceec8871179e882a6bec9900aa625bbc253264c3df48f2fb8539fc512fa8
@@ -1 +0,0 @@
1
- f9c633106487423399e219dc1cdea499e77dc6a9474705002924c38ce01241dbc2fbd95bb84016bcf313e7702a2d2a460b14fabcb36f08ee0c613298203cbd60
@@ -1 +0,0 @@
1
- 896c42559e7d4533e6a947f9b612e8e27f3a8531eeeee4927582cca7dfe2c11303edf3b3fed881a76129a8664235f5b58018bf16dd94b463558041dbeb4f71fe
@@ -1 +0,0 @@
1
- 3742d543a5be6586aff377abb4c97e7d9b2d6fcb8d46dce907d139c3d16a7b98ece77a4fa4acd27c5fc5bca67cd7bdfa988f9f2dd351968586de47bad8c5f4ba
@@ -1 +0,0 @@
1
- ab08823c4799b87b57645665dd628b5bcd4cf4dccf1f10358b240ef4d23af065cc86154f25290a4e5886268a32fda9e3bce75051ba7d8a362fe0c09be6b00928
@@ -1 +0,0 @@
1
- 7f74ff80ef63a93a9baa25a7ece0b596cdb1e0f4a974580728d6f2f95ea8d7ceabd875e0f635e8ddd46b964ab48e0247ae7e9705001f6068e312ec0d8feed4c7
@@ -1 +0,0 @@
1
- 70de02a182976fa1ce086f1d64ce6e96e729a48ea93346a855d3ffdba869cce51501c6ece4f5be74dc1ddf10b85b75c3f772d05fe4e0894c1ac1cf3d36c80200
@@ -1 +0,0 @@
1
- d492e9516ca90eda87fb0b35bc616faa251f1aaf16de21237d85e7b55471242290f31134b0b4f9eedf85c17d112b22ee9c44aaf73cb35513b0a85b3bbd3091d1
@@ -1 +0,0 @@
1
- d36afc6b400b8112517de4c7b40d30047b595918128ac9ef75d5cd248adc8cfd6b0b3f06a71b5fe4541d45050ebbee3d8ae3fc372fd9c13d4666de2c01492044
@@ -1 +0,0 @@
1
- 7505c311763e68d85ea5272485ef103b3406bec7f63195e454586d11b4188b630448a33bd2edc97319ff497f96daa1b67fc8a1848be88cb9ea0c5a089b51bdc4
@@ -1 +0,0 @@
1
- e75b7472e74e27649ab7605bf8cbd5621765798d07796a3d80da3440f3e9f60f5d99049cfe4811a2576d462716ff20509297b0e6b91a5baedd3414ffa43962d3
@@ -1 +0,0 @@
1
- 7c99d0d42ad0031835be2c90bf9451f27e7ee23ad75b2ff8b4ac5ded644b273d5f8af6f78c2d0ff836995d91c1f459a18de867dd6df9e4ae966ffe8012a0db20
@@ -1 +0,0 @@
1
- e9d2df3cb5054a2e9e03e9805980d4b8081b8c25d9fac7596bc7c59f3d337d4a69bce2880b3f204eb29dbf2c2b4e6ae8d3b311bde15da49f4c415fa67bef8ef3
@@ -1 +0,0 @@
1
- 9e1ba1c6efb495ac5452611baf00dc144208c16fa54bcee1fa605bbb6e894e269de716d9b8a51d51e394f45ae85c4efa5fe9cebec433004c9c40ddb0658b024d
@@ -1 +0,0 @@
1
- 8351459bf70306c8ef0bba5d415d74e5f1fa7cfd73b70ba4ac0508989b04f70ce24e2923db1723ddd1fdad38ec2e6ac481df5a4af0adc55dc29e62ae19ed84cb
@@ -1 +0,0 @@
1
- bdf94bb8790d1d0b5524f6ef0e7ac9a2f682cdd3248c52ef069acabbdc17ea685f050d737fa4fc121e9d7688641e2a8cd831b76537e58a6ebb5d169524f961e1
@@ -1 +0,0 @@
1
- 1acbc3c942908b08c055c50f0191f7e16681bb60388cb154bb3ca86ded0764e40438a0c296b651a8a13c4d62f1006b69c17cc69b8b6b963535be02e5fafd0d54
@@ -1 +0,0 @@
1
- c1529ea230a72517e4d15da268661f0c06c0294f456e2bec9dcb455fd85febda7de4237466414d02a662e3a2b370471d20852138f45fc3fbb5d8fef270d9e356
data/fix.gemspec DELETED
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Gem::Specification.new do |spec|
4
- spec.name = 'fix'
5
- spec.version = File.read('VERSION.semver').chomp
6
- spec.authors = ['Cyril Kato']
7
- spec.email = ['contact@cyril.email']
8
-
9
- spec.summary = 'Specing framework.'
10
- spec.description = 'Specing framework for Ruby.'
11
- spec.homepage = 'https://github.com/fixrb/fix'
12
- spec.license = 'MIT'
13
-
14
- spec.files =
15
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^test/}) }
16
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
17
- spec.require_paths = ['lib']
18
-
19
- spec.add_dependency 'aw', '~> 0.1.6'
20
- spec.add_dependency 'defi', '~> 1.1.5'
21
- spec.add_dependency 'spectus', '~> 3.0.9'
22
-
23
- spec.add_development_dependency 'bundler', '~> 2.0'
24
- spec.add_development_dependency 'rake', '~> 13.0'
25
- spec.add_development_dependency 'rubocop', '~> 0.75'
26
- spec.add_development_dependency 'rubocop-performance', '~> 1.5'
27
- spec.add_development_dependency 'simplecov', '~> 0.17'
28
- spec.add_development_dependency 'yard', '~> 0.9'
29
- end
data/lib/fix/it.rb DELETED
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spectus/expectation_target'
4
- require 'spectus/matchers'
5
-
6
- module Fix
7
- # Wraps the target of an expectation.
8
- #
9
- # @api private
10
- #
11
- class It < ::Spectus::ExpectationTarget
12
- include ::Spectus::Matchers
13
-
14
- # Create a new expection target
15
- #
16
- # @param subject [BasicObject] The front object.
17
- # @param challenges [Array] The list of challenges.
18
- # @param helpers [Hash] The list of helpers.
19
- def initialize(subject, challenges, helpers)
20
- @subject = subject
21
- @challenges = challenges
22
-
23
- helpers.each do |method_name, method_block|
24
- define_singleton_method(method_name) do
25
- method_block.call
26
- end
27
- end
28
- end
29
-
30
- # Verify the expectation.
31
- #
32
- # @param spec [Proc] A spec to compare against the computed actual value.
33
- #
34
- # @return [::Spectus::Result::Pass, ::Spectus::Result::Fail] Pass or fail.
35
- def verify(&spec)
36
- instance_eval(&spec)
37
- rescue ::Spectus::Result::Fail => e
38
- e
39
- end
40
- end
41
- end
data/lib/fix/on.rb DELETED
@@ -1,139 +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
- #
9
- # @api private
10
- #
11
- class On
12
- # Initialize the on class.
13
- #
14
- # @param described [#object_id] The front object of the test.
15
- # @param results [Array] The list of collected results.
16
- # @param challenges [Array] The list of challenges to apply.
17
- # @param helpers [Hash] The list of helpers.
18
- # @param configuration [Hash] Settings.
19
- def initialize(described, results, challenges, helpers, configuration)
20
- @described = described
21
- @results = results
22
- @challenges = challenges
23
- @helpers = helpers
24
- @configuration = configuration
25
- end
26
-
27
- # @!attribute [r] described
28
- #
29
- # @return [#object_id] The front object of the test.
30
- attr_reader :described
31
-
32
- # @!attribute [r] results
33
- #
34
- # @return [Array] The list of collected results.
35
- attr_reader :results
36
-
37
- # @!attribute [r] challenges
38
- #
39
- # @return [Array] The list of challenges to apply.
40
- attr_reader :challenges
41
-
42
- # @!attribute [r] helpers
43
- #
44
- # @return [Hash] The list of helpers.
45
- attr_reader :helpers
46
-
47
- # @!attribute [r] configuration
48
- #
49
- # @return [Hash] Settings.
50
- attr_reader :configuration
51
-
52
- # Add it method to the DSL.
53
- #
54
- # @api public
55
- #
56
- # @example It must eql "FOO"
57
- # it { MUST equal 'FOO' }
58
- #
59
- # @param spec [Proc] A spec to compare against the computed actual value.
60
- #
61
- # @return [Array] List of results.
62
- def it(*, &spec)
63
- i = It.new(described, challenges, helpers)
64
-
65
- result = i.verify(&spec)
66
-
67
- if configuration.fetch(:verbose, true)
68
- print result.to_char(configuration.fetch(:color, false))
69
- end
70
-
71
- results << result
72
- end
73
-
74
- # Add on method to the DSL.
75
- #
76
- # @api public
77
- #
78
- # @example On +2, it must equal 44.
79
- # on(:+, 2) do
80
- # it { MUST equal 44 }
81
- # end
82
- #
83
- # @param method_name [Symbol] The identifier of a method.
84
- # @param args [Array] A list of arguments.
85
- # @param block [Proc] A spec to compare against the computed value.
86
- #
87
- # @return [Array] List of results.
88
- def on(method_name, *args, &block)
89
- o = On.new(described,
90
- results,
91
- (challenges + [::Defi.send(method_name, *args)]),
92
- helpers.dup,
93
- configuration)
94
-
95
- o.instance_eval(&block)
96
- end
97
-
98
- # Add let method to the DSL, to define memoized helper methods.
99
- #
100
- # @api public
101
- #
102
- # @example Let's define the answer to the Ultimate Question of Life, the
103
- # Universe, and Everything.
104
- #
105
- # let(:answer) { 42 }
106
- #
107
- # @param method_name [Symbol] The identifier of a method.
108
- # @param block [Proc] A spec to compare against the computed value.
109
- #
110
- # @return [#object_id] List of results.
111
- def let(method_name, &block)
112
- helpers.update(method_name => block)
113
- end
114
-
115
- # Add context method to the DSL, to build an isolated scope.
116
- #
117
- # @api public
118
- #
119
- # @example Context when logged in.
120
- # context 'when logged in' do
121
- # it { MUST equal 200 }
122
- # end
123
- #
124
- # @param block [Proc] A block of specs to test in isolation.
125
- #
126
- # @return [Array] List of results.
127
- def context(*, &block)
128
- o = On.new(described,
129
- [],
130
- challenges,
131
- helpers.dup,
132
- configuration)
133
-
134
- results.concat(::Aw.fork! { o.instance_eval(&block) })
135
- end
136
- end
137
- end
138
-
139
- require_relative 'it'
data/lib/fix/report.rb DELETED
@@ -1,120 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fix
4
- # The class that is responsible for reporting the result of the test.
5
- #
6
- # @api private
7
- #
8
- class Report
9
- # Initialize the report class.
10
- #
11
- # @param test [Test] The test.
12
- def initialize(test)
13
- @test = test
14
- end
15
-
16
- # @!attribute [r] test
17
- #
18
- # @return [Test] The results of the test.
19
- attr_reader :test
20
-
21
- # The report in plain text.
22
- #
23
- # @return [String] The report in plain text.
24
- def to_s
25
- [maybe_thematic_break, maybe_alerts, total_time, statistics].join
26
- end
27
-
28
- private
29
-
30
- # @private
31
- def maybe_thematic_break
32
- test.results.any? && test.configuration.fetch(:verbose) ? "\n\n" : ''
33
- end
34
-
35
- # @private
36
- def total_time
37
- "Ran #{test.results.length} tests in #{test.total_time} seconds\n"
38
- end
39
-
40
- # @private
41
- def alerts
42
- test.results.reject { |r| r.to_sym.equal?(:success) }
43
- end
44
-
45
- # @private
46
- def maybe_alerts
47
- alerts.any? ? "#{results.join("\n")}\n" : ''
48
- end
49
-
50
- # @private
51
- def results
52
- alerts.map.with_index(1) do |r, i|
53
- maybe_results_color("#{i}. #{r.message}\n" + maybe_backtrace(r), r)
54
- end
55
- end
56
-
57
- # @private
58
- def maybe_results_color(string, result)
59
- return string unless test.configuration.fetch(:color)
60
-
61
- color = send("#{result.to_sym}_color")
62
- "\e[#{color}m#{string}\e[0m"
63
- end
64
-
65
- # @private
66
- def maybe_backtrace(result)
67
- result.respond_to?(:backtrace) ? " #{result.backtrace.first}\n" : ''
68
- end
69
-
70
- # @private
71
- def statistics
72
- if test.configuration.fetch(:color)
73
- statistics_color(statistics_text, test.statistics)
74
- else
75
- statistics_text
76
- end
77
- end
78
-
79
- # @private
80
- def statistics_text
81
- "#{test.statistics.fetch(:pass_percent)}% compliant - " \
82
- "#{test.statistics.fetch(:total_infos)} infos, " \
83
- "#{test.statistics.fetch(:total_failures)} failures, " \
84
- "#{test.statistics.fetch(:total_errors)} errors\n"
85
- end
86
-
87
- # @private
88
- def statistics_color(string, stats)
89
- if stats.fetch(:total_errors).positive?
90
- "\e[#{error_color}m#{string}\e[0m"
91
- elsif stats.fetch(:total_failures).positive?
92
- "\e[#{failure_color}m#{string}\e[0m"
93
- elsif stats.fetch(:total_infos).positive?
94
- "\e[#{info_color}m#{string}\e[0m"
95
- else
96
- "\e[#{success_color}m#{string}\e[0m"
97
- end
98
- end
99
-
100
- # @private
101
- def error_color
102
- 31
103
- end
104
-
105
- # @private
106
- def failure_color
107
- 35
108
- end
109
-
110
- # @private
111
- def info_color
112
- 33
113
- end
114
-
115
- # @private
116
- def success_color
117
- 32
118
- end
119
- end
120
- end
data/lib/fix/test.rb DELETED
@@ -1,89 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fix
4
- # Wraps the target of the specs document.
5
- #
6
- # @api private
7
- #
8
- class Test
9
- # Initialize the test class.
10
- #
11
- # @param front_object [BasicObject] The front object of the test.
12
- # @param options [Hash] Some options.
13
- # @param specs [Proc] The specs to test against the object.
14
- def initialize(front_object, verbose: true, color: true, **options, &specs)
15
- @configuration = options.merge(
16
- verbose: verbose,
17
- color: color
18
- )
19
-
20
- start_time = ::Time.now
21
-
22
- g = On.new(front_object, [], [], {}, @configuration)
23
- g.instance_eval(&specs)
24
-
25
- @results = g.results
26
- @total_time = ::Time.now - start_time
27
- end
28
-
29
- # @!attribute [r] configuration
30
- #
31
- # @return [Hash] The settings.
32
- attr_reader :configuration
33
-
34
- # @!attribute [r] results
35
- #
36
- # @return [Array] The results.
37
- attr_reader :results
38
-
39
- # @!attribute [r] total_time
40
- #
41
- # @return [Float] The total time.
42
- attr_reader :total_time
43
-
44
- # Some statistics.
45
- #
46
- # @return [Hash] Some statistics.
47
- def statistics
48
- {
49
- pass_percent: pass_percent,
50
- total_infos: results.count { |r| r.to_sym.equal?(:info) },
51
- total_failures: results.count { |r| r.to_sym.equal?(:failure) },
52
- total_errors: results.count { |r| r.to_sym.equal?(:error) }
53
- }
54
- end
55
-
56
- # The report of the test.
57
- #
58
- # @return [Report] The report of the test.
59
- def report
60
- Report.new(self)
61
- end
62
-
63
- # The state of the test.
64
- #
65
- # @return [Boolean] Return true if the test pass.
66
- def pass?
67
- results.all?(&:result?)
68
- end
69
-
70
- # @return [Boolean] Return false if the test fail.
71
- def fail?
72
- !pass?
73
- end
74
-
75
- private
76
-
77
- # @private
78
- #
79
- # @return [Fixnum] Return the percentage of passing specs.
80
- def pass_percent
81
- return 100 if results.empty?
82
-
83
- (results.count(&:result?) / results.length.to_f * 100).round
84
- end
85
- end
86
- end
87
-
88
- require_relative 'on'
89
- require_relative 'report'
data/pkg_checksum DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'digest/sha2'
5
-
6
- gemname = :fix
7
- ARGV[0] = File.read('VERSION.semver').chomp if ARGV[0].nil?
8
- built_gem_path = "pkg/#{gemname}-#{ARGV[0]}.gem"
9
- checksum = Digest::SHA512.new.hexdigest(File.read(built_gem_path))
10
- checksum_path = "checksum/#{gemname}-#{ARGV[0]}.gem.sha512"
11
-
12
- File.open(checksum_path, 'w') { |f| f.write("#{checksum}\n") }