@@ -77,6 +77,30 @@ def rack_input(json_value)
77
77
expect ( vcr ) . to have_received ( :insert_cassette ) . with ( 'cas1' , persist_with : :file_system )
78
78
end
79
79
end
80
+
81
+ context 'when an error occurs' do
82
+ it 'returns a 500 error with the error message' do
83
+ env [ 'rack.input' ] = rack_input ( [ 'cas1' ] )
84
+ allow ( vcr ) . to receive ( :insert_cassette ) . and_raise ( ArgumentError . new ( 'Invalid cassette name' ) )
85
+
86
+ expect ( response ) . to eq ( [
87
+ 500 ,
88
+ { 'Content-Type' => 'application/json' } ,
89
+ [ '{"message":"Invalid cassette name"}' ]
90
+ ] )
91
+ end
92
+
93
+ it 'returns a 500 error when LoadError occurs' do
94
+ env [ 'rack.input' ] = rack_input ( [ 'cas1' ] )
95
+ allow ( vcr ) . to receive ( :insert_cassette ) . and_raise ( LoadError . new ( 'Cannot load VCR' ) )
96
+
97
+ expect ( response ) . to eq ( [
98
+ 500 ,
99
+ { 'Content-Type' => 'application/json' } ,
100
+ [ '{"message":"Cannot load VCR"}' ]
101
+ ] )
102
+ end
103
+ end
80
104
end
81
105
82
106
describe '/__e2e__/vcr/eject' do
@@ -93,6 +117,28 @@ def rack_input(json_value)
93
117
expect ( vcr ) . to have_received ( :eject_cassette )
94
118
end
95
119
end
120
+
121
+ context 'when an error occurs' do
122
+ it 'returns a 500 error with the error message' do
123
+ allow ( vcr ) . to receive ( :eject_cassette ) . and_raise ( ArgumentError . new ( 'No cassette to eject' ) )
124
+
125
+ expect ( response ) . to eq ( [
126
+ 500 ,
127
+ { 'Content-Type' => 'application/json' } ,
128
+ [ '{"message":"No cassette to eject"}' ]
129
+ ] )
130
+ end
131
+
132
+ it 'returns a 500 error when LoadError occurs' do
133
+ allow ( vcr ) . to receive ( :eject_cassette ) . and_raise ( LoadError . new ( 'Cannot load VCR' ) )
134
+
135
+ expect ( response ) . to eq ( [
136
+ 500 ,
137
+ { 'Content-Type' => 'application/json' } ,
138
+ [ '{"message":"Cannot load VCR"}' ]
139
+ ] )
140
+ end
141
+ end
96
142
end
97
143
98
144
describe '"Other paths"' do
0 commit comments