Class: RSpec::RfcHelper::Spec
- Inherits:
-
Object
- Object
- RSpec::RfcHelper::Spec
- Defined in:
- lib/rspec/rfc_helper/spec.rb
Overview
Represents one spec
Instance Attribute Summary collapse
-
#examples ⇒ Object
readonly
Returns the value of attribute examples.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#section ⇒ Object
readonly
Returns the value of attribute section.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#verb ⇒ Object
readonly
Returns the value of attribute verb.
Instance Method Summary collapse
-
#add_example(example) ⇒ Object
Adds an RSpec example.
-
#initialize(section:, text:, id: nil) ⇒ Spec
constructor
Initializes a new Spec.
-
#status ⇒ :unknown|:pass|:has_pending|:failing
Determines status from RSpec examples.
Constructor Details
#initialize(section:, text:, id: nil) ⇒ Spec
Initializes a new Spec
text
should have one verb surrounded by brackets, representing what this Spec expects:
bad: It [[MUST]] work with a missing user but [[MAY]] log a warning
Use two Specs instead:
It [[MUST]] work with a missing user but MAY log a warning
It MUST work with a missing user but [[MAY]] log a warning
When nothing is highlighted, spec will appear as a “note”.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rspec/rfc_helper/spec.rb', line 26 def initialize(section:, text:, id: nil) raise "Missing text ({section: #{section}, text: #{text}, id: #{id})" unless text.is_a?(String) && !text.empty? raise "Missing section ({section: #{section}, text: #{text}, id: #{id})" unless section.is_a?(String) && !section.empty? @id = id @section = section.to_s @text = text @examples = [] set_verb end |
Instance Attribute Details
#examples ⇒ Object (readonly)
Returns the value of attribute examples.
8 9 10 |
# File 'lib/rspec/rfc_helper/spec.rb', line 8 def examples @examples end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/rspec/rfc_helper/spec.rb', line 8 def id @id end |
#section ⇒ Object (readonly)
Returns the value of attribute section.
8 9 10 |
# File 'lib/rspec/rfc_helper/spec.rb', line 8 def section @section end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
8 9 10 |
# File 'lib/rspec/rfc_helper/spec.rb', line 8 def text @text end |
#verb ⇒ Object (readonly)
Returns the value of attribute verb.
8 9 10 |
# File 'lib/rspec/rfc_helper/spec.rb', line 8 def verb @verb end |
Instance Method Details
#add_example(example) ⇒ Object
Adds an RSpec example
64 65 66 |
# File 'lib/rspec/rfc_helper/spec.rb', line 64 def add_example(example) @examples << example end |
#status ⇒ :unknown|:pass|:has_pending|:failing
Determines status from RSpec examples
Statuses:
unknown: No test currently covers this spec
failing: At least one example failed
has_pending: Some examples are pending, other passed
pass: All examples passed
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rspec/rfc_helper/spec.rb', line 47 def status value = :unknown @examples.each do |example| return :failing if example.execution_result.status == :failed return :has_pending if example.execution_result.status == :pending raise "Unhandled example status: #{example.execution_result.status}" if example.execution_result.status != :passed value = :pass end value end |