Class: Betamax::Player
- Inherits:
-
Object
- Object
- Betamax::Player
- Defined in:
- lib/betamax/player.rb
Instance Attribute Summary collapse
-
#root_proxy ⇒ Object
readonly
Returns the value of attribute root_proxy.
-
#tape ⇒ Object
readonly
Returns the value of attribute tape.
-
#tapes_folder ⇒ Object
readonly
Returns the value of attribute tapes_folder.
Instance Method Summary collapse
-
#initialize(example, tapes_folder:) ⇒ Player
constructor
A new instance of Player.
- #play ⇒ Object
- #record(object) ⇒ Object
Constructor Details
#initialize(example, tapes_folder:) ⇒ Player
Returns a new instance of Player.
5 6 7 8 9 10 |
# File 'lib/betamax/player.rb', line 5 def initialize example, tapes_folder: @example = example @tapes_folder = tapes_folder @tape = Tape.from_rspec_example(example, tapes_folder:) @root_proxy = nil end |
Instance Attribute Details
#root_proxy ⇒ Object (readonly)
Returns the value of attribute root_proxy.
3 4 5 |
# File 'lib/betamax/player.rb', line 3 def root_proxy @root_proxy end |
#tape ⇒ Object (readonly)
Returns the value of attribute tape.
3 4 5 |
# File 'lib/betamax/player.rb', line 3 def tape @tape end |
#tapes_folder ⇒ Object (readonly)
Returns the value of attribute tapes_folder.
3 4 5 |
# File 'lib/betamax/player.rb', line 3 def tapes_folder @tapes_folder end |
Instance Method Details
#play ⇒ Object
12 13 14 15 16 |
# File 'lib/betamax/player.rb', line 12 def play insert_tape @example.run eject_tape unless @example.exception end |
#record(object) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/betamax/player.rb', line 18 def record object recorder = if @tape.exists? MethodPlayer.new recording: @tape.recording else MethodRecorder.new object:, recording: @tape.recording end @root_proxy = RecordedObject.new object:, recorder: end |