Module: WebSocketVCR
- Extended by:
- WebSocketVCR
- Includes:
- Errors
- Included in:
- WebSocketVCR
- Defined in:
- lib/simple_websocket_vcr.rb,
lib/simple_websocket_vcr/errors.rb,
lib/simple_websocket_vcr/version.rb,
lib/simple_websocket_vcr/cassette.rb,
lib/simple_websocket_vcr/configuration.rb,
lib/simple_websocket_vcr/recordable_websocket_client.rb
Defined Under Namespace
Modules: Errors Classes: Cassette, Configuration, RecordEntry, RecordableWebsocketClient, RecordedJsonSession, RecordedSession, RecordedYamlSession
Constant Summary collapse
- VERSION =
'1.0.0'
Class Method Summary collapse
-
.cassette ⇒ Object
Returns the value of attribute cassette.
-
.cassette=(value) ⇒ Object
Sets the attribute cassette.
- .configuration ⇒ Object
- .configure {|configuration| ... } ⇒ Object
- .disabled ⇒ Object
- .disabled=(v) ⇒ Object
- .filename_helper(example, context) ⇒ Object
- .record(example, context, options = {}, &block) ⇒ Object
- .save_session ⇒ Object
- .turn_off!(_options = {}) ⇒ Object
- .turn_on! ⇒ Object
- .turned_on? ⇒ Boolean
-
.use_cassette(name, options = {}) ⇒ Object
Use the specified cassette for either recording the real communication or replaying it during the tests.
Instance Method Summary collapse
- #live? ⇒ Boolean
-
#version ⇒ String
The current version.
Class Method Details
.cassette ⇒ Object
Returns the value of attribute cassette.
13 14 15 |
# File 'lib/simple_websocket_vcr.rb', line 13 def cassette @cassette end |
.cassette=(value) ⇒ Object
Sets the attribute cassette
13 14 15 |
# File 'lib/simple_websocket_vcr.rb', line 13 def cassette=(value) @cassette = value end |
.configuration ⇒ Object
50 51 52 |
# File 'lib/simple_websocket_vcr.rb', line 50 def configuration @configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
46 47 48 |
# File 'lib/simple_websocket_vcr.rb', line 46 def configure yield configuration end |
.disabled ⇒ Object
54 55 56 |
# File 'lib/simple_websocket_vcr.rb', line 54 def disabled @disabled || false end |
.disabled=(v) ⇒ Object
58 59 60 |
# File 'lib/simple_websocket_vcr.rb', line 58 def disabled=(v) @disabled = v end |
.filename_helper(example, context) ⇒ Object
104 105 106 107 108 109 110 111 112 113 |
# File 'lib/simple_websocket_vcr.rb', line 104 def filename_helper(example, context) if context.class.[:parent_example_group].nil? example_name = example.description.gsub(/\s+/, '_') directory = context.class.[:description].gsub(/\s+/, '_') else example_name = "#{context.class.[:description]}_#{example.description}".gsub(/\s+/, '_') directory = context.class.[:parent_example_group][:description].gsub(/\s+/, '_') end "#{directory}/#{example_name}" end |
.record(example, context, options = {}, &block) ⇒ Object
80 81 82 83 84 |
# File 'lib/simple_websocket_vcr.rb', line 80 def record(example, context, = {}, &block) fail ArgumentError, '`VCR.record` requires a block.' unless block_given? name = filename_helper(example, context) use_cassette(name, , &block) end |
.save_session ⇒ Object
62 63 |
# File 'lib/simple_websocket_vcr.rb', line 62 def save_session end |
.turn_off!(_options = {}) ⇒ Object
86 87 88 |
# File 'lib/simple_websocket_vcr.rb', line 86 def turn_off!( = {}) # TODO: impl end |
.turn_on! ⇒ Object
94 95 96 |
# File 'lib/simple_websocket_vcr.rb', line 94 def turn_on! # TODO: impl end |
.turned_on? ⇒ Boolean
90 91 92 |
# File 'lib/simple_websocket_vcr.rb', line 90 def turned_on? !@cassette.nil? end |
.use_cassette(name, options = {}) ⇒ Object
Use the specified cassette for either recording the real communication or replaying it during the tests.
72 73 74 75 76 77 78 |
# File 'lib/simple_websocket_vcr.rb', line 72 def use_cassette(name, = {}) fail ArgumentError, '`VCR.use_cassette` requires a block.' unless block_given? self.cassette = Cassette.new(name, ) yield cassette.save self.cassette = nil end |
Instance Method Details
#live? ⇒ Boolean
98 99 100 |
# File 'lib/simple_websocket_vcr.rb', line 98 def live? @cassette && @cassette.recording? end |
#version ⇒ String
Note:
This string also has singleton methods:
-
‘major` [Integer] The major version.
-
‘minor` [Integer] The minor version.
-
‘patch` [Integer] The patch version.
-
‘parts` [Array<Integer>] List of the version parts.
Returns the current version.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/simple_websocket_vcr.rb', line 22 def version @version ||= begin string = WebSocketVCR::VERSION def string.parts split('.').map(&:to_i) end def string.major parts[0] end def string.minor parts[1] end def string.patch parts[2] end string end end |