Class: RSpecDocumentation::Spec
- Inherits:
-
Object
- Object
- RSpecDocumentation::Spec
- Defined in:
- lib/rspec_documentation/spec.rb
Overview
Executes specs from a Markdown code block and provides the outcome in the appropriate format.
Class Attribute Summary collapse
-
.durations ⇒ Object
Returns the value of attribute durations.
-
.subjects ⇒ Object
Returns the value of attribute subjects.
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #failure ⇒ Object
-
#initialize(spec:, format:, parent:, location:, path:, index:) ⇒ Spec
constructor
rubocop:disable Metrics/ParameterLists.
- #reporter ⇒ Object
- #run ⇒ Object
- #source ⇒ Object
- #subject ⇒ Object
Constructor Details
#initialize(spec:, format:, parent:, location:, path:, index:) ⇒ Spec
rubocop:disable Metrics/ParameterLists
14 15 16 17 18 19 20 21 22 |
# File 'lib/rspec_documentation/spec.rb', line 14 def initialize(spec:, format:, parent:, location:, path:, index:) # rubocop:disable Metrics/ParameterLists @spec = spec @format = format.empty? ? :plaintext : format.to_sym @parent = parent @location = location @path = path @index = index @failures = [] end |
Class Attribute Details
.durations ⇒ Object
Returns the value of attribute durations.
11 12 13 |
# File 'lib/rspec_documentation/spec.rb', line 11 def durations @durations end |
.subjects ⇒ Object
Returns the value of attribute subjects.
11 12 13 |
# File 'lib/rspec_documentation/spec.rb', line 11 def subjects @subjects end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
6 7 8 |
# File 'lib/rspec_documentation/spec.rb', line 6 def format @format end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
6 7 8 |
# File 'lib/rspec_documentation/spec.rb', line 6 def index @index end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
6 7 8 |
# File 'lib/rspec_documentation/spec.rb', line 6 def location @location end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
6 7 8 |
# File 'lib/rspec_documentation/spec.rb', line 6 def parent @parent end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/rspec_documentation/spec.rb', line 6 def path @path end |
Instance Method Details
#failure ⇒ Object
35 36 37 |
# File 'lib/rspec_documentation/spec.rb', line 35 def failure failures.first end |
#reporter ⇒ Object
39 40 41 |
# File 'lib/rspec_documentation/spec.rb', line 39 def reporter @reporter ||= ::RSpec::Core::Reporter.new(::RSpec::Core::Configuration.new) end |
#run ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rspec_documentation/spec.rb', line 43 def run self.class.subjects = [] RSpec.with_failure_notifier(failure_notifier) do succeeded = example_group.run(reporter) durations << run_time if run_time next succeeded if succeeded notify_failure(reported_failure) succeeded end end |
#source ⇒ Object
31 32 33 |
# File 'lib/rspec_documentation/spec.rb', line 31 def source spec end |