Class: Spectus::ExpectationTarget
- Inherits:
- BasicObject
- Defined in:
- lib/spectus/expectation_target.rb
Overview
Wraps the target of an expectation.
Instance Attribute Summary collapse
-
#challenges ⇒ Array
readonly
The challenges to call on the subject.
-
#subject ⇒ BasicObject
readonly
The front object to be tested.
Instance Method Summary collapse
-
#initialize(&subject) ⇒ ExpectationTarget
constructor
Create a new expection target.
-
#MAY(req) ⇒ Result::Fail, Result::Pass
This word, or the adjective “OPTIONAL”, mean that an item is truly optional.
-
#MUST(req) ⇒ Result::Fail, Result::Pass
This word, or the terms “REQUIRED” or “SHALL”, mean that the definition is an absolute requirement of the specification.
-
#MUST_NOT(req) ⇒ Result::Fail, Result::Pass
This phrase, or the phrase “SHALL NOT”, mean that the definition is an absolute prohibition of the specification.
-
#SHOULD(req) ⇒ Result::Fail, Result::Pass
This word, or the adjective “RECOMMENDED”, mean that there may exist valid reasons in particular circumstances to ignore a particular item, but the full implications must be understood and carefully weighed before choosing a different course.
-
#SHOULD_NOT(req) ⇒ Result::Fail, Result::Pass
This phrase, or the phrase “NOT RECOMMENDED” mean that there may exist valid reasons in particular circumstances when the particular behavior is acceptable or even useful, but the full implications should be understood and the case carefully weighed before implementing any behavior described with this label.
Constructor Details
#initialize(&subject) ⇒ ExpectationTarget
Create a new expection target
12 13 14 15 |
# File 'lib/spectus/expectation_target.rb', line 12 def initialize(&subject) @subject = subject @challenges = [::Defi.send(:call)] end |
Instance Attribute Details
#challenges ⇒ Array (readonly)
Returns The challenges to call on the subject.
25 26 27 |
# File 'lib/spectus/expectation_target.rb', line 25 def challenges @challenges end |
#subject ⇒ BasicObject (readonly)
Returns The front object to be tested.
20 21 22 |
# File 'lib/spectus/expectation_target.rb', line 20 def subject @subject end |
Instance Method Details
#MAY(req) ⇒ Result::Fail, Result::Pass
This word, or the adjective “OPTIONAL”, mean that an item is truly optional. One vendor may choose to include the item because a particular marketplace requires it or because the vendor feels that it enhances the product while another vendor may omit the same item. An implementation which does not include a particular option MUST be prepared to interoperate with another implementation which does include the option, though perhaps with reduced functionality. In the same vein an implementation which does include a particular option MUST be prepared to interoperate with another implementation which does not include the option (except, of course, for the feature the option provides.)
104 105 106 |
# File 'lib/spectus/expectation_target.rb', line 104 def MAY(req) RequirementLevel::Low.new(req, false, subject, *challenges).result end |
#MUST(req) ⇒ Result::Fail, Result::Pass
This word, or the terms “REQUIRED” or “SHALL”, mean that the definition is an absolute requirement of the specification.
38 39 40 |
# File 'lib/spectus/expectation_target.rb', line 38 def MUST(req) RequirementLevel::High.new(req, false, subject, *challenges).result end |
#MUST_NOT(req) ⇒ Result::Fail, Result::Pass
This phrase, or the phrase “SHALL NOT”, mean that the definition is an absolute prohibition of the specification.
51 52 53 |
# File 'lib/spectus/expectation_target.rb', line 51 def MUST_NOT(req) RequirementLevel::High.new(req, true, subject, *challenges).result end |
#SHOULD(req) ⇒ Result::Fail, Result::Pass
This word, or the adjective “RECOMMENDED”, mean that there may exist valid reasons in particular circumstances to ignore a particular item, but the full implications must be understood and carefully weighed before choosing a different course.
66 67 68 |
# File 'lib/spectus/expectation_target.rb', line 66 def SHOULD(req) RequirementLevel::Medium.new(req, false, subject, *challenges).result end |
#SHOULD_NOT(req) ⇒ Result::Fail, Result::Pass
This phrase, or the phrase “NOT RECOMMENDED” mean that there may exist valid reasons in particular circumstances when the particular behavior is acceptable or even useful, but the full implications should be understood and the case carefully weighed before implementing any behavior described with this label.
82 83 84 |
# File 'lib/spectus/expectation_target.rb', line 82 def SHOULD_NOT(req) RequirementLevel::Medium.new(req, true, subject, *challenges).result end |