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 CHANGED
@@ -1,8 +1,10 @@
1
1
  # VcrCable
2
2
 
3
- This gem allows to use VCR in development. This is quite handy when you're on
4
- a sloppy connection and your app interacts with external services, or when you
5
- want to save bandwidth, or when you have no connection at all.
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
- Generate the vcr_cable.yml file with default VCR config:
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 self.configure_vcr
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 self.config
16
- @config ||= YAML.load_file(Rails.root.join 'config', CONFIG_FILE)[Rails.env]
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
@@ -1,3 +1,3 @@
1
1
  module VcrCable
2
- VERSION = '0.0.3'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -5,5 +5,5 @@ development:
5
5
 
6
6
  test:
7
7
  hook_into: fakeweb
8
- cassette_library_dir: test_cassettes
8
+ cassette_library_dir: custom_named_cassettes
9
9
  allow_http_connections_when_no_cassette: false
@@ -308,3 +308,127 @@ Connecting to database specified by database.yml
308
308
   (0.1ms) rollback transaction
309
309
   (0.1ms) begin transaction
310
310
   (0.1ms) rollback transaction
311
+ Connecting to database specified by database.yml
312
+  (0.4ms) begin transaction
313
+  (0.1ms) rollback transaction
314
+  (0.0ms) begin transaction
315
+  (0.0ms) rollback transaction
316
+ Connecting to database specified by database.yml
317
+  (0.3ms) begin transaction
318
+  (0.0ms) rollback transaction
319
+  (0.1ms) begin transaction
320
+  (0.0ms) rollback transaction
321
+  (0.0ms) begin transaction
322
+  (0.1ms) rollback transaction
323
+ Connecting to database specified by database.yml
324
+  (0.3ms) begin transaction
325
+  (0.0ms) rollback transaction
326
+  (0.0ms) begin transaction
327
+  (0.0ms) rollback transaction
328
+  (0.0ms) begin transaction
329
+  (0.1ms) rollback transaction
330
+ Connecting to database specified by database.yml
331
+  (0.4ms) begin transaction
332
+  (0.0ms) rollback transaction
333
+  (0.0ms) begin transaction
334
+  (0.0ms) rollback transaction
335
+  (0.0ms) begin transaction
336
+  (0.1ms) rollback transaction
337
+ Connecting to database specified by database.yml
338
+  (0.3ms) begin transaction
339
+  (0.1ms) rollback transaction
340
+  (0.1ms) begin transaction
341
+  (0.0ms) rollback transaction
342
+  (0.0ms) begin transaction
343
+  (0.1ms) rollback transaction
344
+ Connecting to database specified by database.yml
345
+  (0.3ms) begin transaction
346
+  (0.0ms) rollback transaction
347
+  (0.0ms) begin transaction
348
+  (0.0ms) rollback transaction
349
+  (0.0ms) begin transaction
350
+  (0.1ms) rollback transaction
351
+ Connecting to database specified by database.yml
352
+  (0.4ms) begin transaction
353
+  (0.0ms) rollback transaction
354
+  (0.0ms) begin transaction
355
+  (0.0ms) rollback transaction
356
+  (0.0ms) begin transaction
357
+  (0.1ms) rollback transaction
358
+ Connecting to database specified by database.yml
359
+  (0.4ms) begin transaction
360
+  (0.0ms) rollback transaction
361
+  (0.0ms) begin transaction
362
+  (0.0ms) rollback transaction
363
+  (0.0ms) begin transaction
364
+  (0.1ms) rollback transaction
365
+ Connecting to database specified by database.yml
366
+  (0.3ms) begin transaction
367
+  (0.0ms) rollback transaction
368
+  (0.1ms) begin transaction
369
+  (0.0ms) rollback transaction
370
+  (0.0ms) begin transaction
371
+  (0.1ms) rollback transaction
372
+ Connecting to database specified by database.yml
373
+  (0.4ms) begin transaction
374
+  (0.0ms) rollback transaction
375
+  (0.0ms) begin transaction
376
+  (0.0ms) rollback transaction
377
+  (0.0ms) begin transaction
378
+  (0.1ms) rollback transaction
379
+ Connecting to database specified by database.yml
380
+  (0.4ms) begin transaction
381
+  (0.0ms) rollback transaction
382
+  (0.0ms) begin transaction
383
+  (0.0ms) rollback transaction
384
+  (0.0ms) begin transaction
385
+  (0.1ms) rollback transaction
386
+ Connecting to database specified by database.yml
387
+  (0.4ms) begin transaction
388
+  (0.0ms) rollback transaction
389
+  (0.0ms) begin transaction
390
+  (0.1ms) rollback transaction
391
+  (0.0ms) begin transaction
392
+  (0.1ms) rollback transaction
393
+ Connecting to database specified by database.yml
394
+  (0.3ms) begin transaction
395
+  (0.0ms) rollback transaction
396
+  (0.0ms) begin transaction
397
+  (0.0ms) rollback transaction
398
+  (0.0ms) begin transaction
399
+  (0.1ms) rollback transaction
400
+ Connecting to database specified by database.yml
401
+  (0.4ms) begin transaction
402
+  (0.0ms) rollback transaction
403
+  (0.1ms) begin transaction
404
+  (0.0ms) rollback transaction
405
+  (0.0ms) begin transaction
406
+  (0.1ms) rollback transaction
407
+ Connecting to database specified by database.yml
408
+  (0.3ms) begin transaction
409
+  (0.0ms) rollback transaction
410
+  (0.1ms) begin transaction
411
+  (0.0ms) rollback transaction
412
+  (0.0ms) begin transaction
413
+  (0.1ms) rollback transaction
414
+ Connecting to database specified by database.yml
415
+  (0.4ms) begin transaction
416
+  (0.0ms) rollback transaction
417
+  (0.0ms) begin transaction
418
+  (0.0ms) rollback transaction
419
+  (0.0ms) begin transaction
420
+  (0.1ms) rollback transaction
421
+ Connecting to database specified by database.yml
422
+  (0.4ms) begin transaction
423
+  (0.0ms) rollback transaction
424
+  (0.0ms) begin transaction
425
+  (0.0ms) rollback transaction
426
+  (0.0ms) begin transaction
427
+  (0.1ms) rollback transaction
428
+ Connecting to database specified by database.yml
429
+  (0.3ms) begin transaction
430
+  (0.0ms) rollback transaction
431
+  (0.1ms) begin transaction
432
+  (0.1ms) rollback transaction
433
+  (0.0ms) begin transaction
434
+  (0.1ms) rollback transaction
@@ -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 /test_cassettes$/, VCR.configuration.cassette_library_dir
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.0.3
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-24 00:00:00.000000000 Z
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: http://github.com/spaghetticode/vcr_cable
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: -2552967238797520619
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: -2552967238797520619
185
+ hash: -3372546154796512749
186
186
  requirements: []
187
187
  rubyforge_project:
188
188
  rubygems_version: 1.8.24