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 =
'0.0.5'
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.cassette ⇒ Object
53
54
55
|
# File 'lib/simple_websocket_vcr.rb', line 53
def cassette
@cassette
end
|
.cassette=(v) ⇒ Object
57
58
59
|
# File 'lib/simple_websocket_vcr.rb', line 57
def cassette=(v)
@cassette = v
end
|
.configuration ⇒ Object
49
50
51
|
# File 'lib/simple_websocket_vcr.rb', line 49
def configuration
@configuration ||= Configuration.new
end
|
45
46
47
|
# File 'lib/simple_websocket_vcr.rb', line 45
def configure
yield configuration
end
|
.disabled ⇒ Object
61
62
63
|
# File 'lib/simple_websocket_vcr.rb', line 61
def disabled
@disabled || false
end
|
.disabled=(v) ⇒ Object
65
66
67
|
# File 'lib/simple_websocket_vcr.rb', line 65
def disabled=(v)
@disabled = v
end
|
.filename_helper(example, context) ⇒ Object
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/simple_websocket_vcr.rb', line 109
def filename_helper(example, context)
if context.class.metadata[:parent_example_group].nil?
example_name = example.description.gsub(/\s+/, '_')
directory = context.class.metadata[:description].gsub(/\s+/, '_')
else
example_name = "#{context.class.metadata[:description]}_#{example.description}".gsub(/\s+/, '_')
directory = context.class.metadata[:parent_example_group][:description].gsub(/\s+/, '_')
end
"#{directory}/#{example_name}"
end
|
.record(example, context, options = {}, &block) ⇒ Object
85
86
87
88
89
|
# File 'lib/simple_websocket_vcr.rb', line 85
def record(example, context, options = {}, &block)
fail ArgumentError, '`VCR.record` requires a block.' unless block_given?
name = filename_helper(example, context)
use_cassette(name, options, &block)
end
|
.save_session ⇒ Object
69
70
|
# File 'lib/simple_websocket_vcr.rb', line 69
def save_session
end
|
.turn_off!(_options = {}) ⇒ Object
91
92
93
|
# File 'lib/simple_websocket_vcr.rb', line 91
def turn_off!(_options = {})
end
|
.turn_on! ⇒ Object
99
100
101
|
# File 'lib/simple_websocket_vcr.rb', line 99
def turn_on!
end
|
.turned_on? ⇒ Boolean
95
96
97
|
# File 'lib/simple_websocket_vcr.rb', line 95
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.
77
78
79
80
81
82
83
|
# File 'lib/simple_websocket_vcr.rb', line 77
def use_cassette(name, options = {})
fail ArgumentError, '`VCR.use_cassette` requires a block.' unless block_given?
self.cassette = Cassette.new(name, options)
yield
cassette.save
self.cassette = nil
end
|
Instance Method Details
#live? ⇒ Boolean
103
104
105
|
# File 'lib/simple_websocket_vcr.rb', line 103
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.
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/simple_websocket_vcr.rb', line 21
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
|