Class: NanDoc::SpecDoc::Recordings

Inherits:
Array
  • Object
show all
Defined in:
lib/nandoc/spec-doc/support-modules.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(test_case) ⇒ Recordings

Returns a new instance of Recordings.



143
144
145
# File 'lib/nandoc/spec-doc/support-modules.rb', line 143

def initialize test_case
  @test_case = test_case
end

Class Attribute Details

.for_test_caseObject

Returns the value of attribute for_test_case.



118
119
120
# File 'lib/nandoc/spec-doc/support-modules.rb', line 118

def for_test_case
  @for_test_case
end

Instance Attribute Details

#test_caseObject (readonly)

Returns the value of attribute test_case.



155
156
157
# File 'lib/nandoc/spec-doc/support-modules.rb', line 155

def test_case
  @test_case
end

Class Method Details

.get(test_case) ⇒ Object



119
120
121
# File 'lib/nandoc/spec-doc/support-modules.rb', line 119

def get test_case
  @for_test_case[test_case.class] ||= new(test_case.class)
end

.report_test_case_not_found(tc) ⇒ Object



122
123
124
125
# File 'lib/nandoc/spec-doc/support-modules.rb', line 122

def report_test_case_not_found tc
  msgs = ["no recordings found for #{tc}"]
  msgs.join('  ')
end

Instance Method Details

#add(name, *data) ⇒ Object



128
129
130
131
# File 'lib/nandoc/spec-doc/support-modules.rb', line 128

def add name, *data
  # this might change if we need to group by method name
  push [name, *data]
end

#get_first_sexp_for_test_method(meth) ⇒ Object



133
134
135
136
137
138
139
140
141
# File 'lib/nandoc/spec-doc/support-modules.rb', line 133

def get_first_sexp_for_test_method meth
  first = index([:method, meth]) or return nil
  last = (first+1..length-1).detect do |i|
    self[i].first == :method && self[i][1] != meth
  end
  last = last ? (last - 1) : (length - 1)
  ret = self[first..last]
  ret
end

#note(&block) ⇒ Object



147
148
149
# File 'lib/nandoc/spec-doc/support-modules.rb', line 147

def note &block
  push [:note, block]
end

#report_recording_not_found(meth_name) ⇒ Object



151
152
153
# File 'lib/nandoc/spec-doc/support-modules.rb', line 151

def report_recording_not_found meth_name
  "no recordings found for #{meth_name}"
end