Class: VCR::Cassette
- Inherits:
-
Object
- Object
- VCR::Cassette
- Defined in:
- lib/vcr/cassette.rb,
lib/vcr/deprecations.rb
Constant Summary collapse
- VALID_RECORD_MODES =
[:all, :none, :new_episodes].freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#record_mode ⇒ Object
readonly
Returns the value of attribute record_mode.
Instance Method Summary collapse
- #allow_real_http_requests_to?(uri) ⇒ Boolean
- #cache_file(*args) ⇒ Object
- #destroy!(*args) ⇒ Object
- #eject ⇒ Object
- #file ⇒ Object
-
#initialize(name, options = {}) ⇒ Cassette
constructor
A new instance of Cassette.
- #record_http_interaction(interaction) ⇒ Object
- #recorded_interactions ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ Cassette
Returns a new instance of Cassette.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/vcr/cassette.rb', line 10 def initialize(name, = {}) @name = name @record_mode = [:record] || VCR::Config.[:record] @allow_real_http_lambda = allow_real_http_lambda_for([:allow_real_http] || VCR::Config.[:allow_real_http]) deprecate_unregistered_record_mode raise_error_unless_valid_record_mode(record_mode) set_http_connections_allowed load_recorded_interactions end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/vcr/cassette.rb', line 8 def name @name end |
#record_mode ⇒ Object (readonly)
Returns the value of attribute record_mode.
8 9 10 |
# File 'lib/vcr/cassette.rb', line 8 def record_mode @record_mode end |
Instance Method Details
#allow_real_http_requests_to?(uri) ⇒ Boolean
40 41 42 |
# File 'lib/vcr/cassette.rb', line 40 def allow_real_http_requests_to?(uri) @allow_real_http_lambda ? @allow_real_http_lambda.call(uri) : false end |
#cache_file(*args) ⇒ Object
23 24 25 26 |
# File 'lib/vcr/deprecations.rb', line 23 def cache_file(*args) warn "WARNING: VCR::Cassette#cache_file is deprecated. Instead, use: VCR::Cassette#file." file(*args) end |
#destroy!(*args) ⇒ Object
18 19 20 21 |
# File 'lib/vcr/deprecations.rb', line 18 def destroy!(*args) warn "WARNING: VCR::Cassette#destroy! is deprecated. Instead, use: VCR::Cassette#eject." eject(*args) end |
#eject ⇒ Object
22 23 24 25 26 |
# File 'lib/vcr/cassette.rb', line 22 def eject write_recorded_interactions_to_disk VCR.http_stubbing_adapter.restore_stubs_checkpoint(name) restore_http_connections_allowed end |
#file ⇒ Object
36 37 38 |
# File 'lib/vcr/cassette.rb', line 36 def file File.join(VCR::Config.cassette_library_dir, "#{name.to_s.gsub(/[^\w\-\/]+/, '_')}.yml") if VCR::Config.cassette_library_dir end |
#record_http_interaction(interaction) ⇒ Object
32 33 34 |
# File 'lib/vcr/cassette.rb', line 32 def record_http_interaction(interaction) recorded_interactions << interaction end |
#recorded_interactions ⇒ Object
28 29 30 |
# File 'lib/vcr/cassette.rb', line 28 def recorded_interactions @recorded_interactions ||= [] end |