vcr_cable 0.0.3 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +30 -5
- data/lib/vcr_cable.rb +17 -3
- data/lib/vcr_cable/version.rb +1 -1
- data/test/dummy/config/vcr_cable.yml +1 -1
- data/test/dummy/log/test.log +124 -0
- data/test/vcr_cable_test.rb +8 -1
- metadata +5 -5
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# VcrCable
|
2
2
|
|
3
|
-
This gem allows to use VCR in development. This is quite handy when
|
4
|
-
|
5
|
-
want to save bandwidth, or when you have no connection
|
3
|
+
This gem allows to use VCR in development. This is quite handy when your app
|
4
|
+
interacts frequently with external services and you're on a sloppy connection,
|
5
|
+
or when you want to save bandwidth, or when you happent to have no connection
|
6
|
+
at all.
|
7
|
+
|
6
8
|
|
7
9
|
## Usage
|
8
10
|
|
@@ -12,12 +14,35 @@ Add required gems to your Gemfile:
|
|
12
14
|
gem 'vcr_cable'
|
13
15
|
gem 'webmock' # or fakeweb
|
14
16
|
```
|
17
|
+
Now all external requests will hit the remote servers only one time, and the
|
18
|
+
application will subsequently use the recorded data.
|
19
|
+
|
20
|
+
|
21
|
+
## Custom VCR Configuration
|
22
|
+
|
23
|
+
The default VCR configuration values are (extracted from ```lib/vcr_cable.rb```):
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
DEFAULT_CONFIG = {
|
27
|
+
'hook_into' => :fakeweb,
|
28
|
+
'cassette_library_dir' => 'development_cassettes',
|
29
|
+
'allow_http_connections_when_no_cassette' => true
|
30
|
+
}
|
31
|
+
```
|
15
32
|
|
16
|
-
|
33
|
+
If you want to override those values you can generate the vcr_cable.yml config
|
34
|
+
file and edit its params:
|
17
35
|
|
18
36
|
```bash
|
19
37
|
bundle exec rails generate vcr_cable
|
20
38
|
```
|
21
39
|
|
22
|
-
Update config/vcr_cable.yml with your custom settings, if necessary. Done
|
23
40
|
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
1. Fork it
|
44
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
45
|
+
3. Add your feature tests to the rspec/cucumber test suite
|
46
|
+
4. Commit your changes (`git commit -am 'Added some feature'`)
|
47
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
48
|
+
6. Create new Pull Request
|
data/lib/vcr_cable.rb
CHANGED
@@ -2,9 +2,16 @@ require 'vcr'
|
|
2
2
|
require 'vcr_cable/railtie' if defined? Rails
|
3
3
|
|
4
4
|
module VcrCable
|
5
|
+
extend self
|
6
|
+
|
5
7
|
CONFIG_FILE = 'vcr_cable.yml'
|
8
|
+
DEFAULT_CONFIG = {
|
9
|
+
'hook_into' => :fakeweb,
|
10
|
+
'cassette_library_dir' => 'development_cassettes',
|
11
|
+
'allow_http_connections_when_no_cassette' => true
|
12
|
+
}
|
6
13
|
|
7
|
-
def
|
14
|
+
def configure_vcr
|
8
15
|
VCR.configure do |c|
|
9
16
|
c.hook_into config['hook_into']
|
10
17
|
c.cassette_library_dir = config['cassette_library_dir']
|
@@ -12,7 +19,14 @@ module VcrCable
|
|
12
19
|
end
|
13
20
|
end
|
14
21
|
|
15
|
-
def
|
16
|
-
@config ||=
|
22
|
+
def config
|
23
|
+
@config ||= begin
|
24
|
+
config_file = Rails.root.join 'config', CONFIG_FILE
|
25
|
+
if File.file? config_file
|
26
|
+
YAML.load_file(config_file)[Rails.env]
|
27
|
+
else
|
28
|
+
DEFAULT_CONFIG
|
29
|
+
end
|
30
|
+
end
|
17
31
|
end
|
18
32
|
end
|
data/lib/vcr_cable/version.rb
CHANGED
data/test/dummy/log/test.log
CHANGED
@@ -308,3 +308,127 @@ Connecting to database specified by database.yml
|
|
308
308
|
[1m[35m (0.1ms)[0m rollback transaction
|
309
309
|
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
310
310
|
[1m[35m (0.1ms)[0m rollback transaction
|
311
|
+
Connecting to database specified by database.yml
|
312
|
+
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
313
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
314
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
315
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
316
|
+
Connecting to database specified by database.yml
|
317
|
+
[1m[36m (0.3ms)[0m [1mbegin transaction[0m
|
318
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
319
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
320
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
321
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
322
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
323
|
+
Connecting to database specified by database.yml
|
324
|
+
[1m[36m (0.3ms)[0m [1mbegin transaction[0m
|
325
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
326
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
327
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
328
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
329
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
330
|
+
Connecting to database specified by database.yml
|
331
|
+
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
332
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
333
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
334
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
335
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
336
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
337
|
+
Connecting to database specified by database.yml
|
338
|
+
[1m[36m (0.3ms)[0m [1mbegin transaction[0m
|
339
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
340
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
341
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
342
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
343
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
344
|
+
Connecting to database specified by database.yml
|
345
|
+
[1m[36m (0.3ms)[0m [1mbegin transaction[0m
|
346
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
347
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
348
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
349
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
350
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
351
|
+
Connecting to database specified by database.yml
|
352
|
+
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
353
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
354
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
355
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
356
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
357
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
358
|
+
Connecting to database specified by database.yml
|
359
|
+
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
360
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
361
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
362
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
363
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
364
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
365
|
+
Connecting to database specified by database.yml
|
366
|
+
[1m[36m (0.3ms)[0m [1mbegin transaction[0m
|
367
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
368
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
369
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
370
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
371
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
372
|
+
Connecting to database specified by database.yml
|
373
|
+
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
374
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
375
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
376
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
377
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
378
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
379
|
+
Connecting to database specified by database.yml
|
380
|
+
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
381
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
382
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
383
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
384
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
385
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
386
|
+
Connecting to database specified by database.yml
|
387
|
+
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
388
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
389
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
390
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
391
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
392
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
393
|
+
Connecting to database specified by database.yml
|
394
|
+
[1m[36m (0.3ms)[0m [1mbegin transaction[0m
|
395
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
396
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
397
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
398
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
399
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
400
|
+
Connecting to database specified by database.yml
|
401
|
+
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
402
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
403
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
404
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
405
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
406
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
407
|
+
Connecting to database specified by database.yml
|
408
|
+
[1m[36m (0.3ms)[0m [1mbegin transaction[0m
|
409
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
410
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
411
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
412
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
413
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
414
|
+
Connecting to database specified by database.yml
|
415
|
+
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
416
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
417
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
418
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
419
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
420
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
421
|
+
Connecting to database specified by database.yml
|
422
|
+
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
423
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
424
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
425
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
426
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
427
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
428
|
+
Connecting to database specified by database.yml
|
429
|
+
[1m[36m (0.3ms)[0m [1mbegin transaction[0m
|
430
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
431
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
432
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
433
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
434
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
data/test/vcr_cable_test.rb
CHANGED
@@ -2,8 +2,15 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class VcrCableTest < ActiveSupport::TestCase
|
4
4
|
test 'loads the default config' do
|
5
|
+
File.stubs(:file?).returns false
|
6
|
+
VcrCable.instance_variable_set('@config', nil)
|
5
7
|
VcrCable.configure_vcr
|
6
|
-
assert_match /
|
8
|
+
assert_match /development_cassettes$/, VCR.configuration.cassette_library_dir
|
9
|
+
end
|
10
|
+
|
11
|
+
test 'configuration in config/vcr_cable.yml overwrites default values' do
|
12
|
+
VcrCable.configure_vcr
|
13
|
+
assert_match /custom_named_cassettes$/, VCR.configuration.cassette_library_dir
|
7
14
|
end
|
8
15
|
|
9
16
|
test 'adds VCR::Middleware::Rack to the middleware stack' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vcr_cable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -159,7 +159,7 @@ files:
|
|
159
159
|
- test/dummy/script/rails
|
160
160
|
- test/test_helper.rb
|
161
161
|
- test/vcr_cable_test.rb
|
162
|
-
homepage:
|
162
|
+
homepage: https://github.com/spaghetticode/vcr_cable
|
163
163
|
licenses: []
|
164
164
|
post_install_message:
|
165
165
|
rdoc_options: []
|
@@ -173,7 +173,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
173
173
|
version: '0'
|
174
174
|
segments:
|
175
175
|
- 0
|
176
|
-
hash: -
|
176
|
+
hash: -3372546154796512749
|
177
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
178
|
none: false
|
179
179
|
requirements:
|
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
182
|
version: '0'
|
183
183
|
segments:
|
184
184
|
- 0
|
185
|
-
hash: -
|
185
|
+
hash: -3372546154796512749
|
186
186
|
requirements: []
|
187
187
|
rubyforge_project:
|
188
188
|
rubygems_version: 1.8.24
|