Class: NxtVcrHarness::CassetteTracker
- Inherits:
-
Object
- Object
- NxtVcrHarness::CassetteTracker
- Includes:
- Singleton
- Defined in:
- lib/nxt_vcr_harness/cassette_tracker.rb
Instance Attribute Summary collapse
-
#cassettes ⇒ Object
Returns the value of attribute cassettes.
Instance Method Summary collapse
- #cassette_file_names_from_used_cassettes ⇒ Object
-
#initialize ⇒ CassetteTracker
constructor
A new instance of CassetteTracker.
- #playback_count ⇒ Object
- #reveal_unused_cassettes(library_dir) ⇒ Object
- #stats ⇒ Object
- #track(cassette) ⇒ Object
Constructor Details
#initialize ⇒ CassetteTracker
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
#cassettes ⇒ Object
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_cassettes ⇒ Object
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_count ⇒ Object
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 |
#stats ⇒ Object
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 |