Class: NxtVcrHarness::CassetteTracker

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/nxt_vcr_harness/cassette_tracker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCassetteTracker

Returns a new instance of CassetteTracker.



7
8
9
# File 'lib/nxt_vcr_harness/cassette_tracker.rb', line 7

def initialize
  @cassettes = []
end

Instance Attribute Details

#cassettesObject

Returns the value of attribute cassettes.



39
40
41
# File 'lib/nxt_vcr_harness/cassette_tracker.rb', line 39

def cassettes
  @cassettes
end

Instance Method Details

#cassette_file_names_from_used_cassettesObject



27
28
29
# File 'lib/nxt_vcr_harness/cassette_tracker.rb', line 27

def cassette_file_names_from_used_cassettes
  cassettes.map(&:file).uniq
end

#playback_countObject



31
32
33
# File 'lib/nxt_vcr_harness/cassette_tracker.rb', line 31

def playback_count
  cassettes.count
end

#reveal_unused_cassettes(library_dir) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/nxt_vcr_harness/cassette_tracker.rb', line 16

def reveal_unused_cassettes(library_dir)
  all_cassette_paths = Dir.glob("#{library_dir}/**/*.yml")
  unused_cassettes = (all_cassette_paths - cassette_file_names_from_used_cassettes)
  if unused_cassettes.any?
    puts "The following cassettes are unused: "
    puts unused_cassettes.join(' ')
  else
    puts "There are no unused cassettes"
  end
end

#statsObject



11
12
13
14
# File 'lib/nxt_vcr_harness/cassette_tracker.rb', line 11

def stats
  puts '.'
  puts "Stubbed #{playback_count} HTTP requests using #{cassette_file_names_from_used_cassettes.count} cassettes"
end

#track(cassette) ⇒ Object



35
36
37
# File 'lib/nxt_vcr_harness/cassette_tracker.rb', line 35

def track(cassette)
  cassettes << cassette
end