fix 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.gitignore +1 -5
  5. data/.rubocop.yml +12 -0
  6. data/.travis.yml +12 -3
  7. data/.yardopts +1 -0
  8. data/CODE_OF_CONDUCT.md +13 -0
  9. data/Gemfile +1 -0
  10. data/LICENSE.md +17 -18
  11. data/README.md +70 -78
  12. data/Rakefile +5 -2
  13. data/VERSION.semver +1 -1
  14. data/bin/console +7 -0
  15. data/bin/setup +5 -0
  16. data/certs/gem-fixrb-public_cert.pem +21 -0
  17. data/fix.gemspec +17 -18
  18. data/lib/fix.rb +20 -98
  19. data/lib/fix/helpers/it_helper.rb +32 -0
  20. data/lib/fix/helpers/on_helper.rb +29 -0
  21. data/lib/fix/it.rb +6 -9
  22. data/lib/fix/on.rb +30 -13
  23. data/lib/fix/report.rb +61 -0
  24. data/lib/fix/sandbox.rb +25 -0
  25. data/lib/fix/test.rb +50 -224
  26. data/pkg_checksum +11 -0
  27. metadata +61 -152
  28. metadata.gz.sig +0 -0
  29. data/.coveralls.yml +0 -1
  30. data/bin/fix +0 -5
  31. data/fix.pem +0 -21
  32. data/lib/fix/db.rb +0 -23
  33. data/lib/fix/dsl.rb +0 -17
  34. data/lib/fix/expectation.rb +0 -80
  35. data/lib/fix/expectation_high.rb +0 -15
  36. data/lib/fix/expectation_low.rb +0 -19
  37. data/lib/fix/expectation_medium.rb +0 -21
  38. data/lib/fix/helper/it_helper.rb +0 -12
  39. data/lib/fix/helper/its_helper.rb +0 -20
  40. data/lib/fix/helper/let_accessor_helper.rb +0 -11
  41. data/lib/fix/helper/let_reader_helper.rb +0 -13
  42. data/lib/fix/helper/let_writer_helper.rb +0 -15
  43. data/lib/fix/helper/on_helper.rb +0 -20
  44. data/lib/fix/helper/requirement_helper.rb +0 -44
  45. data/lib/fix/its.rb +0 -13
  46. data/lib/fix/subject.rb +0 -44
  47. data/lib/fix/version.rb +0 -9
  48. data/spec/fix/bin/color_spec.rb +0 -17
  49. data/spec/fix/bin/exit_status_spec.rb +0 -19
  50. data/spec/fix/bin/help_spec.rb +0 -13
  51. data/spec/fix/bin/hide_progress.rb +0 -17
  52. data/spec/fix/bin/spec_helper.rb +0 -3
  53. data/spec/fix/bin/version_spec.rb +0 -9
  54. data/spec/fix/lib/may/error_spec.rb +0 -9
  55. data/spec/fix/lib/may/info_spec.rb +0 -9
  56. data/spec/fix/lib/may/spec_helper.rb +0 -1
  57. data/spec/fix/lib/may/success_spec.rb +0 -9
  58. data/spec/fix/lib/must/error_spec.rb +0 -9
  59. data/spec/fix/lib/must/failure_spec.rb +0 -9
  60. data/spec/fix/lib/must/spec_helper.rb +0 -1
  61. data/spec/fix/lib/must/success_spec.rb +0 -9
  62. data/spec/fix/lib/should/error_spec.rb +0 -9
  63. data/spec/fix/lib/should/info_spec.rb +0 -9
  64. data/spec/fix/lib/should/spec_helper.rb +0 -1
  65. data/spec/fix/lib/should/success_spec.rb +0 -9
  66. data/spec/fix/lib/spec_helper.rb +0 -1
  67. data/spec/fix/lib/success_spec.rb +0 -9
  68. data/spec/fix/spec_helper.rb +0 -1
  69. data/spec/spec_helper.rb +0 -4
  70. data/spec/support.rb +0 -3
  71. data/spec/support/coverage.rb +0 -9
  72. data/spec/support/env.rb +0 -1
  73. data/spec/support/examples/42/app.rb +0 -1
  74. data/spec/support/examples/42/may/error/spec.rb +0 -7
  75. data/spec/support/examples/42/may/error/test.rb +0 -7
  76. data/spec/support/examples/42/may/info/spec.rb +0 -7
  77. data/spec/support/examples/42/may/info/test.rb +0 -7
  78. data/spec/support/examples/42/may/success/spec.rb +0 -12
  79. data/spec/support/examples/42/may/success/test.rb +0 -7
  80. data/spec/support/examples/42/must/error/spec.rb +0 -11
  81. data/spec/support/examples/42/must/error/test.rb +0 -7
  82. data/spec/support/examples/42/must/failure/spec.rb +0 -7
  83. data/spec/support/examples/42/must/failure/test.rb +0 -7
  84. data/spec/support/examples/42/must/success/spec.rb +0 -7
  85. data/spec/support/examples/42/must/success/test.rb +0 -7
  86. data/spec/support/examples/42/should/error/spec.rb +0 -11
  87. data/spec/support/examples/42/should/error/test.rb +0 -7
  88. data/spec/support/examples/42/should/info/spec.rb +0 -7
  89. data/spec/support/examples/42/should/info/test.rb +0 -7
  90. data/spec/support/examples/42/should/success/spec.rb +0 -7
  91. data/spec/support/examples/42/should/success/test.rb +0 -7
  92. data/spec/support/examples/duck/app.rb +0 -16
  93. data/spec/support/examples/duck/success/spec.rb +0 -80
  94. data/spec/support/examples/duck/success/test.rb +0 -7
  95. data/spec/support/immutable.rb +0 -12
@@ -1,15 +0,0 @@
1
- require_relative 'expectation'
2
-
3
- module Fix
4
- class ExpectationHigh < Expectation
5
- private
6
-
7
- def pass result, _subject
8
- result.equal? true
9
- end
10
-
11
- def level
12
- 1
13
- end
14
- end
15
- end
@@ -1,19 +0,0 @@
1
- require_relative 'expectation_medium'
2
-
3
- module Fix
4
- class ExpectationLow < ExpectationMedium
5
- private
6
-
7
- def pass result, subject
8
- if subject.implemented?
9
- super
10
- else
11
- true
12
- end
13
- end
14
-
15
- def level
16
- 3
17
- end
18
- end
19
- end
@@ -1,21 +0,0 @@
1
- require_relative 'expectation_high'
2
-
3
- module Fix
4
- class ExpectationMedium < ExpectationHigh
5
- private
6
-
7
- def pass result, _subject
8
- if super
9
- true
10
- elsif exception(result).nil?
11
- nil
12
- else
13
- false
14
- end
15
- end
16
-
17
- def level
18
- 2
19
- end
20
- end
21
- end
@@ -1,12 +0,0 @@
1
- module Fix
2
- module Helper
3
- module ItHelper
4
- def it &block
5
- i = It.new @object, @defs, *@args
6
- i.instance_eval(&block)
7
- end
8
- end
9
- end
10
- end
11
-
12
- require_relative File.join '..', 'it'
@@ -1,20 +0,0 @@
1
- module Fix
2
- module Helper
3
- module ItsHelper
4
- def its attribute, *args, &block
5
- unless instance_variable_defined? :@object
6
- raise MissingSubjectError, "Incomplete specifications. " \
7
- "Please specify a `subject` on the top."
8
- end
9
-
10
- @defs = {} unless instance_variable_defined? :@defs
11
- @args = [] unless instance_variable_defined? :@args
12
-
13
- i = Its.new @object, @defs, *(@args + [[attribute] + args])
14
- i.instance_eval(&block)
15
- end
16
- end
17
- end
18
- end
19
-
20
- require_relative File.join '..', 'its'
@@ -1,11 +0,0 @@
1
- require_relative 'let_reader_helper'
2
- require_relative 'let_writer_helper'
3
-
4
- module Fix
5
- module Helper
6
- module LetAccessorHelper
7
- include LetReaderHelper
8
- include LetWriterHelper
9
- end
10
- end
11
- end
@@ -1,13 +0,0 @@
1
- module Fix
2
- module Helper
3
- module LetReaderHelper
4
- def method_missing name, *args, &block
5
- if @defs.key? name
6
- @defs.fetch(name).call
7
- else
8
- super
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,15 +0,0 @@
1
- module Fix
2
- module Helper
3
- module LetWriterHelper
4
- def let name, &block
5
- @defs = {} unless instance_variable_defined? :@defs
6
-
7
- if @defs.key? name
8
- raise IndexError, 'the given key is already present.'
9
- else
10
- @defs.update name => block
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,20 +0,0 @@
1
- module Fix
2
- module Helper
3
- module OnHelper
4
- def on attribute, *args, &block
5
- unless instance_variable_defined? :@object
6
- raise MissingSubjectError, "Incomplete specifications. " \
7
- "Please specify a `subject` on the top."
8
- end
9
-
10
- @defs = {} unless instance_variable_defined? :@defs
11
- @args = [] unless instance_variable_defined? :@args
12
-
13
- i = On.new @object, @defs, *(@args + [[attribute] + args])
14
- i.instance_eval(&block)
15
- end
16
- end
17
- end
18
- end
19
-
20
- require_relative File.join '..', 'on'
@@ -1,44 +0,0 @@
1
- require_relative 'let_reader_helper'
2
-
3
- module Fix
4
- module Helper
5
- module RequirementHelper
6
- include Helper::LetReaderHelper
7
-
8
- def MUST definition
9
- ExpectationHigh.new @object, true, definition, *@args
10
- end
11
-
12
- alias_method :is_REQUIRED_to, :MUST
13
- alias_method :SHALL, :MUST
14
-
15
- def MUST_NOT definition
16
- ExpectationHigh.new @object, false, definition, *@args
17
- end
18
-
19
- alias_method :SHALL_NOT, :MUST_NOT
20
-
21
- def SHOULD definition
22
- ExpectationMedium.new @object, true, definition, *@args
23
- end
24
-
25
- alias_method :is_RECOMMENDED_to, :SHOULD
26
-
27
- def SHOULD_NOT definition
28
- ExpectationMedium.new @object, false, definition, *@args
29
- end
30
-
31
- alias_method :is_NOT_RECOMMENDED_to, :SHOULD_NOT
32
-
33
- def MAY definition
34
- ExpectationLow.new @object, true, definition, *@args
35
- end
36
-
37
- alias_method :is_OPTIONAL_to, :MAY
38
- end
39
- end
40
- end
41
-
42
- require_relative File.join '..', 'expectation_high'
43
- require_relative File.join '..', 'expectation_low'
44
- require_relative File.join '..', 'expectation_medium'
@@ -1,13 +0,0 @@
1
- require_relative File.join 'helper', 'requirement_helper'
2
-
3
- module Fix
4
- class Its
5
- include Helper::RequirementHelper
6
-
7
- def initialize object, defs, *args
8
- @object = object
9
- @defs = defs
10
- @args = args
11
- end
12
- end
13
- end
@@ -1,44 +0,0 @@
1
- module Fix
2
- class Subject
3
- attr_reader :last_arg
4
-
5
- def initialize input, *args
6
- @args = args
7
- @error = nil
8
- @implemented = true
9
- @last_arg = -1
10
-
11
- begin
12
- @cache_value = params.inject input do |mem, param|
13
- @implemented = mem.respond_to? param.first, false
14
- @last_arg = @last_arg.next
15
-
16
- mem.__send__(*param)
17
- end
18
-
19
- @last_arg = @last_arg.next
20
- rescue => @error
21
- end
22
- end
23
-
24
- def actual
25
- if @error.nil?
26
- @cache_value.__send__(*challenge)
27
- else
28
- raise @error
29
- end
30
- end
31
-
32
- def params
33
- @args[0..-2]
34
- end
35
-
36
- def challenge
37
- @args.last
38
- end
39
-
40
- def implemented?
41
- @error.nil? && @implemented && @cache_value.respond_to?(challenge.first, false)
42
- end
43
- end
44
- end
@@ -1,9 +0,0 @@
1
- require 'pathname'
2
-
3
- module Fix
4
-
5
- # Gem version
6
- VERSION = File.open(
7
- Pathname.new(__FILE__).join '..', '..', '..', 'VERSION.semver'
8
- ).read.chomp.to_sym unless defined? VERSION
9
- end
@@ -1,17 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- subject Proc.new {
4
- `#{BIN_PATH} #{Pathname.new(__FILE__).join '..', '..', '..', 'support', 'examples', 'duck', 'success', 'test.rb'}`
5
- }
6
-
7
- its :call do
8
- MUST match: /^......$/
9
- end
10
-
11
- subject Proc.new {
12
- `#{BIN_PATH} #{Pathname.new(__FILE__).join '..', '..', '..', 'support', 'examples', 'duck', 'success', 'test.rb'} --color`
13
- }
14
-
15
- its :call do
16
- MUST match: /^#{Regexp.escape("\e[32m.\e[0m" * 6)}$/
17
- end
@@ -1,19 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- subject Proc.new {
4
- `#{BIN_PATH} #{Pathname.new(__FILE__).join '..', '..', '..', 'support', 'examples', '42', 'must', 'success', 'test.rb'}`
5
- $?
6
- }
7
-
8
- on :call do
9
- its(:exitstatus) { MUST equal: 0 }
10
- end
11
-
12
- subject Proc.new {
13
- `#{BIN_PATH} #{Pathname.new(__FILE__).join '..', '..', '..', 'support', 'examples', '42', 'must', 'error', 'test.rb'}`
14
- $?
15
- }
16
-
17
- on :call do
18
- its(:exitstatus) { MUST equal: 1 }
19
- end
@@ -1,13 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- subject Proc.new { `#{BIN_PATH} --help` }
4
-
5
- its :call do
6
- MUST match: /Usage: fix <files or directories> \[options\]/
7
- MUST match: / --color /
8
- MUST match: / --debug /
9
- MUST match: / --hide_progress /
10
- MUST match: / --seed /
11
- MUST match: / --warnings /
12
- MUST match: / --version /
13
- end
@@ -1,17 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- subject Proc.new {
4
- `#{BIN_PATH} #{Pathname.new(__FILE__).join '..', '..', '..', 'support', 'examples', 'duck', 'success', 'test.rb'}`
5
- }
6
-
7
- its :call do
8
- MUST match: /^......$/
9
- end
10
-
11
- subject Proc.new {
12
- `#{BIN_PATH} #{Pathname.new(__FILE__).join '..', '..', '..', 'support', 'examples', 'duck', 'success', 'test.rb'} --hide_progress`
13
- }
14
-
15
- its :call do
16
- MUST_NOT match: /^......$/
17
- end
@@ -1,3 +0,0 @@
1
- require_relative File.join '..', 'spec_helper'
2
-
3
- BIN_PATH = Pathname.new(__FILE__).join '..', '..', '..', '..', 'bin', 'fix'
@@ -1,9 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- subject Proc.new { `#{BIN_PATH} --version` }
4
-
5
- its :call do
6
- MUST eql: File.open(
7
- Pathname.new(__FILE__).join '..', '..', '..', '..', 'VERSION.semver'
8
- ).read
9
- end
@@ -1,9 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- subject -> {
4
- `ruby #{File.join File.dirname(__FILE__), '..', '..', '..', 'support', 'examples', '42', 'may', 'error', 'test.rb'}`
5
- }
6
-
7
- its :call do
8
- MUST match: /^0% compliant - 0 infos, 0 failures, 1 errors$/
9
- end
@@ -1,9 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- subject -> {
4
- `ruby #{File.join File.dirname(__FILE__), '..', '..', '..', 'support', 'examples', '42', 'may', 'info', 'test.rb'}`
5
- }
6
-
7
- its :call do
8
- MUST match: /^100% compliant - 1 infos, 0 failures, 0 errors$/
9
- end
@@ -1 +0,0 @@
1
- require_relative File.join '..', 'spec_helper'
@@ -1,9 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- subject -> {
4
- `ruby #{File.join File.dirname(__FILE__), '..', '..', '..', 'support', 'examples', '42', 'may', 'success', 'test.rb'}`
5
- }
6
-
7
- its :call do
8
- MUST match: /^100% compliant - 0 infos, 0 failures, 0 errors$/
9
- end
@@ -1,9 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- subject -> {
4
- `ruby #{File.join File.dirname(__FILE__), '..', '..', '..', 'support', 'examples', '42', 'must', 'error', 'test.rb'}`
5
- }
6
-
7
- its :call do
8
- MUST match: /^0% compliant - 0 infos, 0 failures, 2 errors$/
9
- end
@@ -1,9 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- subject -> {
4
- `ruby #{File.join File.dirname(__FILE__), '..', '..', '..', 'support', 'examples', '42', 'must', 'failure', 'test.rb'}`
5
- }
6
-
7
- its :call do
8
- MUST match: /^0% compliant - 0 infos, 1 failures, 0 errors$/
9
- end
@@ -1 +0,0 @@
1
- require_relative File.join '..', 'spec_helper'
@@ -1,9 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- subject -> {
4
- `ruby #{File.join File.dirname(__FILE__), '..', '..', '..', 'support', 'examples', '42', 'must', 'success', 'test.rb'}`
5
- }
6
-
7
- its :call do
8
- MUST match: /^100% compliant - 0 infos, 0 failures, 0 errors$/
9
- end
@@ -1,9 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- subject -> {
4
- `ruby #{File.join File.dirname(__FILE__), '..', '..', '..', 'support', 'examples', '42', 'should', 'error', 'test.rb'}`
5
- }
6
-
7
- its :call do
8
- MUST match: /^0% compliant - 0 infos, 0 failures, 2 errors$/
9
- end