spectus 2.8.0 → 2.9.0

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
  SHA1:
3
- metadata.gz: f9c5f017cdf442b8b5b030ba4a89faec996d46d0
4
- data.tar.gz: e92e7bce6997f75a1932d8593cf21e0150e95d08
3
+ metadata.gz: 3f1486affdd6feecdb555121c32c11c69a448e96
4
+ data.tar.gz: 4bd260c2f0295db5d5ffd7ecde20144be6509308
5
5
  SHA512:
6
- metadata.gz: 6ccc7b4ab0aea3ee90b6a9cb28fe62e7d4458118df8cb34ccdbf3fdd530cf1fce8f0c1aab2a9884df30f99a1586708bc071ce5056fb8277d4d94b6e7f7c3ee0e
7
- data.tar.gz: 62c3f9dd0ab650be6226c5564f4df238876683175b9cd20694467674dc6533afcae2f07aef42f4908390a2a56244349dabbf719a9c243af7798b896881df2b94
6
+ metadata.gz: ba367974543e1325be7846b697aa7f14766e1135ecf95f6d7b3af0fd1bed4cd7b805274b85f26b5d5f97b5af29e30c6d5c829cd6635817dcecc8a4bbbf2e5589
7
+ data.tar.gz: 33ed94ab7562d3ecfb0ca19c1efcac1b153bcfee782078fe1b166692bd5770a1803b3fe44823a01b59cfb1060ab1329735b37f0dfa1be16bf48c81e5f4a8f7b1
checksums.yaml.gz.sig CHANGED
Binary file
data/.rubocop_todo.yml CHANGED
@@ -1,15 +1,11 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2015-10-10 17:44:08 +0200 using RuboCop version 0.34.2.
3
+ # on 2015-10-13 23:48:38 +0200 using RuboCop version 0.34.2.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 1
10
- Metrics/AbcSize:
11
- Max: 18
12
-
13
9
  # Offense count: 4
14
10
  # Configuration parameters: CountComments.
15
11
  Metrics/MethodLength:
@@ -25,5 +21,5 @@ Metrics/ParameterLists:
25
21
  # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist.
26
22
  Style/TrivialAccessors:
27
23
  Exclude:
28
- - 'lib/spectus/level/base.rb'
29
24
  - 'lib/spectus/report.rb'
25
+ - 'lib/spectus/requirement_level/base.rb'
data/README.md CHANGED
@@ -51,6 +51,31 @@ An expectation is an assertion that is either `true` or `false`.
51
51
  | Implemented & Exception | `false` | `false` | `false` |
52
52
  | Not implemented | `false` | `false` | `true` |
53
53
 
54
+ ## Isolation
55
+
56
+ There are two cases:
57
+
58
+ * when the requirement level of an expectation ends with `!`, the test is performed in isolation;
59
+ * when the requirement level of an expectation does not end with `!`, the test is performed without isolation.
60
+
61
+ Example of test in isolation:
62
+
63
+ ```ruby
64
+ greeting = 'Hello, world!'
65
+ Spectus.this { greeting.gsub!('world', 'Alice') }.MUST! Eql: 'Hello, Alice!'
66
+ # => #<Spectus::Result::Pass:0x007fd6312e5310 @message="Pass: Expected \"Hello, Alice!\" to eql \"Hello, Alice!\".", @subject=#<Proc:0x007fd6312e6238@(irb):2>, @challenge=#<Defi::Challenge:0x007fd6312e59c8 @method=:call, @args=[]>, @actual="Hello, Alice!", @expected={:Eql=>"Hello, Alice!"}, @got=true, @error=nil, @level=:High, @negate=false, @valid=true>
67
+ greeting # => "Hello, world!"
68
+ ```
69
+
70
+ Example of test without isolation:
71
+
72
+ ```ruby
73
+ greeting = 'Hello, world!'
74
+ Spectus.this { greeting.gsub!('world', 'Alice') }.MUST Eql: 'Hello, Alice!'
75
+ # => #<Spectus::Result::Pass:0x007fabbab88f68 @message="Pass: Expected \"Hello, Alice!\" to eql \"Hello, Alice!\".", @subject=#<Proc:0x007fabbab895a8@(irb):2>, @challenge=#<Defi::Challenge:0x007fabbab89530 @method=:call, @args=[]>, @actual="Hello, Alice!", @expected={:Eql=>"Hello, Alice!"}, @got=true, @error=nil, @level=:High, @negate=false, @valid=true>
76
+ greeting # => "Hello, Alice!"
77
+ ```
78
+
54
79
  ## Results
55
80
 
56
81
  There are two cases:
data/VERSION.semver CHANGED
@@ -1 +1 @@
1
- 2.8.0
1
+ 2.9.0
@@ -0,0 +1 @@
1
+ 2f4cc7cc8d6b32effa58c91d04e2bd2baea946c55782af86b9ac51669af56368ae68bb9dfe12ea702efa88b6b67003944e59ad876899dc950f0f590c9f26bb8f
@@ -39,6 +39,14 @@ module Spectus
39
39
  RequirementLevel::High.new(req, false, subject, *challenges).result
40
40
  end
41
41
 
42
+ # @example _Absolute requirement_ definition with isolation
43
+ # this { 'foo'.upcase }.MUST! Eql: 'FOO'
44
+ #
45
+ # @see MUST
46
+ def MUST!(req)
47
+ RequirementLevel::High.new(req, false, subject, *challenges).result(true)
48
+ end
49
+
42
50
  # This phrase, or the phrase "SHALL NOT", mean that the
43
51
  # definition is an absolute prohibition of the specification.
44
52
  #
@@ -52,6 +60,14 @@ module Spectus
52
60
  RequirementLevel::High.new(req, true, subject, *challenges).result
53
61
  end
54
62
 
63
+ # @example _Absolute prohibition_ definition with isolation
64
+ # this { 'foo'.size }.MUST_NOT! Equal: 42
65
+ #
66
+ # @see MUST_NOT
67
+ def MUST_NOT!(req)
68
+ RequirementLevel::High.new(req, true, subject, *challenges).result(true)
69
+ end
70
+
55
71
  # This word, or the adjective "RECOMMENDED", mean that there
56
72
  # may exist valid reasons in particular circumstances to ignore a
57
73
  # particular item, but the full implications must be understood and
@@ -67,6 +83,15 @@ module Spectus
67
83
  RequirementLevel::Medium.new(req, false, subject, *challenges).result
68
84
  end
69
85
 
86
+ # @example _Recommended_ definition with isolation
87
+ # this { 'foo'.valid_encoding? }.SHOULD! Equal: true
88
+ #
89
+ # @see SHOULD
90
+ def SHOULD!(req)
91
+ RequirementLevel::Medium.new(req, false, subject, *challenges)
92
+ .result(true)
93
+ end
94
+
70
95
  # This phrase, or the phrase "NOT RECOMMENDED" mean that
71
96
  # there may exist valid reasons in particular circumstances when the
72
97
  # particular behavior is acceptable or even useful, but the full
@@ -83,6 +108,14 @@ module Spectus
83
108
  RequirementLevel::Medium.new(req, true, subject, *challenges).result
84
109
  end
85
110
 
111
+ # @example _Not recommended_ definition with isolation
112
+ # this { ''.blank? }.SHOULD_NOT! RaiseException: NoMethodError
113
+ #
114
+ # @see SHOULD_NOT
115
+ def SHOULD_NOT!(req)
116
+ RequirementLevel::Medium.new(req, true, subject, *challenges).result(true)
117
+ end
118
+
86
119
  # This word, or the adjective "OPTIONAL", mean that an item is
87
120
  # truly optional. One vendor may choose to include the item because a
88
121
  # particular marketplace requires it or because the vendor feels that
@@ -104,9 +137,17 @@ module Spectus
104
137
  def MAY(req)
105
138
  RequirementLevel::Low.new(req, false, subject, *challenges).result
106
139
  end
140
+
141
+ # @example _Optional_ definition with isolation
142
+ # this { 'foo'.bar }.MAY! Match: /^foo$/
143
+ #
144
+ # @see MAY
145
+ def MAY!(req)
146
+ RequirementLevel::Low.new(req, false, subject, *challenges).result(true)
147
+ end
107
148
  end
108
149
  end
109
150
 
110
- require_relative File.join 'level', 'high'
111
- require_relative File.join 'level', 'medium'
112
- require_relative File.join 'level', 'low'
151
+ require_relative File.join 'requirement_level', 'high'
152
+ require_relative File.join 'requirement_level', 'medium'
153
+ require_relative File.join 'requirement_level', 'low'
@@ -63,7 +63,7 @@ module Spectus
63
63
  def summary
64
64
  return state.exception.message unless state.valid? || state.exception.nil?
65
65
 
66
- 'Expected ' + state.actual.inspect + maybe_negate + ' to ' + definition
66
+ "Expected #{state.actual.inspect}#{maybe_negate} to #{definition}"
67
67
  end
68
68
 
69
69
  # The negation, if any.
@@ -85,7 +85,7 @@ module Spectus
85
85
  # @return [String] The readable definition string.
86
86
  def definition
87
87
  if req.is_a?(Hash)
88
- snake_case(req.keys.first) + ' ' + req.values.first.inspect
88
+ "#{snake_case(req.keys.first)} #{req.values.first.inspect}"
89
89
  else
90
90
  snake_case(req)
91
91
  end
@@ -84,9 +84,11 @@ module Spectus
84
84
  self.class.name.split('::').last.to_sym
85
85
  end
86
86
 
87
+ # @param isolation [Boolean] Test in isolation.
88
+ #
87
89
  # @return [Sandbox] The sandbox.
88
- def sandbox
89
- Process.respond_to?(:fork) ? fork_and_return { execute } : execute
90
+ def sandbox(isolation)
91
+ isolation ? fork_and_return { execute } : execute
90
92
  end
91
93
 
92
94
  # @return [Sandbox] The sandbox.
@@ -11,8 +11,8 @@ module Spectus
11
11
  #
12
12
  # @return [Result::Fail, Result::Pass] Report if the high expectation
13
13
  # pass or fail.
14
- def result
15
- state = sandbox
14
+ def result(isolation = false)
15
+ state = sandbox(isolation)
16
16
 
17
17
  if state.valid?
18
18
  pass!(state)
@@ -11,8 +11,8 @@ module Spectus
11
11
  #
12
12
  # @return [Result::Fail, Result::Pass] Report if the low expectation
13
13
  # pass or fail.
14
- def result
15
- state = sandbox
14
+ def result(isolation = false)
15
+ state = sandbox(isolation)
16
16
 
17
17
  if state.valid? || state.exception.class.equal?(::NoMethodError)
18
18
  pass!(state)
@@ -11,8 +11,8 @@ module Spectus
11
11
  #
12
12
  # @return [Result::Fail, Result::Pass] Report if the medium expectation
13
13
  # pass or fail.
14
- def result
15
- state = sandbox
14
+ def result(isolation = false)
15
+ state = sandbox(isolation)
16
16
 
17
17
  if state.valid? || state.exception.nil?
18
18
  pass!(state)
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spectus
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.0
4
+ version: 2.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Wack
@@ -30,7 +30,7 @@ cert_chain:
30
30
  dzJvWzQ1+dJU6WQv75E9ddSkaQrK3nhdgQVu+/wgvGSrsMvOGNz+LXaSDxQqZuwX
31
31
  0KNQFuIukfrdk8URwRnHoAnvx4U93iUw
32
32
  -----END CERTIFICATE-----
33
- date: 2015-10-10 00:00:00.000000000 Z
33
+ date: 2015-10-13 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: defi
@@ -168,13 +168,14 @@ files:
168
168
  - checksum/spectus-2.6.0.gem.sha512
169
169
  - checksum/spectus-2.7.0.gem.sha512
170
170
  - checksum/spectus-2.7.1.gem.sha512
171
+ - checksum/spectus-2.8.0.gem.sha512
171
172
  - lib/spectus.rb
172
173
  - lib/spectus/expectation_target.rb
173
- - lib/spectus/level/base.rb
174
- - lib/spectus/level/high.rb
175
- - lib/spectus/level/low.rb
176
- - lib/spectus/level/medium.rb
177
174
  - lib/spectus/report.rb
175
+ - lib/spectus/requirement_level/base.rb
176
+ - lib/spectus/requirement_level/high.rb
177
+ - lib/spectus/requirement_level/low.rb
178
+ - lib/spectus/requirement_level/medium.rb
178
179
  - lib/spectus/result/base.rb
179
180
  - lib/spectus/result/fail.rb
180
181
  - lib/spectus/result/pass.rb
metadata.gz.sig CHANGED
Binary file