Class: NanDoc::SpecDoc::Recordings

Inherits:
Array
  • Object
show all
Defined in:
lib/nandoc/spec-doc/recordings.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.



41
42
43
# File 'lib/nandoc/spec-doc/recordings.rb', line 41

def initialize test_case
  @test_case = test_case
end

Class Attribute Details

.for_keyObject

Returns the value of attribute for_key.



13
14
15
# File 'lib/nandoc/spec-doc/recordings.rb', line 13

def for_key
  @for_key
end

.for_test_caseObject

Returns the value of attribute for_test_case.



13
14
15
# File 'lib/nandoc/spec-doc/recordings.rb', line 13

def for_test_case
  @for_test_case
end

Instance Attribute Details

#test_caseObject (readonly)

Returns the value of attribute test_case.



53
54
55
# File 'lib/nandoc/spec-doc/recordings.rb', line 53

def test_case
  @test_case
end

Class Method Details

.get(test_case) ⇒ Object



14
15
16
# File 'lib/nandoc/spec-doc/recordings.rb', line 14

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

.get_for_key(key) ⇒ Object



17
18
19
# File 'lib/nandoc/spec-doc/recordings.rb', line 17

def get_for_key key
  @for_key[key] ||= new(key)
end

.report_test_case_not_found(tc) ⇒ Object



20
21
22
23
# File 'lib/nandoc/spec-doc/recordings.rb', line 20

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

Instance Method Details

#add(name, *data) ⇒ Object



26
27
28
29
# File 'lib/nandoc/spec-doc/recordings.rb', line 26

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



31
32
33
34
35
36
37
38
39
# File 'lib/nandoc/spec-doc/recordings.rb', line 31

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



45
46
47
# File 'lib/nandoc/spec-doc/recordings.rb', line 45

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

#report_recording_not_found(meth_name) ⇒ Object



49
50
51
# File 'lib/nandoc/spec-doc/recordings.rb', line 49

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