vcr_cable 0.1.3 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # VcrCable
2
2
 
3
+ [![Build Status](https://secure.travis-ci.org/spaghetticode/vcr_cable.png)](http://travis-ci.org/spaghetticode/vcr_cable)
4
+
3
5
  This gem allows to use VCR in development. This is quite handy when your app
4
6
  interacts frequently with external services and you're on a sloppy connection,
5
7
  or when you want to save bandwidth, or when you happent to have no connection
@@ -37,6 +39,8 @@ file and edit its params:
37
39
  bundle exec rails generate vcr_cable
38
40
  ```
39
41
 
42
+ You will find the generated file in the ```config``` folder of your rails
43
+ application.
40
44
 
41
45
  ## Contributing
42
46
 
@@ -1,11 +1,13 @@
1
1
  module VcrCable
2
2
  class Railtie < Rails::Railtie
3
3
  initializer 'vcr_cable.insert_middleware' do |app|
4
- app.config.middleware.use VCR::Middleware::Rack do |cassette|
5
- cassette.name 'vcr_cable'
6
- cassette.options :record => :new_episodes
4
+ if VcrCable.enabled?
5
+ app.config.middleware.use VCR::Middleware::Rack do |cassette|
6
+ cassette.name 'vcr_cable_cassette'
7
+ cassette.options :record => :new_episodes
8
+ end
9
+ VcrCable.configure_vcr
7
10
  end
8
- VcrCable.configure_vcr
9
11
  end
10
12
  end
11
13
  end
@@ -1,3 +1,3 @@
1
1
  module VcrCable
2
- VERSION = '0.1.3'
2
+ VERSION = '0.2.3'
3
3
  end
data/lib/vcr_cable.rb CHANGED
@@ -6,9 +6,11 @@ module VcrCable
6
6
 
7
7
  CONFIG_FILE = 'vcr_cable.yml'
8
8
  DEFAULT_CONFIG = {
9
- 'hook_into' => :fakeweb,
10
- 'cassette_library_dir' => 'development_cassettes',
11
- 'allow_http_connections_when_no_cassette' => true
9
+ 'development' => {
10
+ 'hook_into' => :fakeweb,
11
+ 'cassette_library_dir' => 'development_cassettes',
12
+ 'allow_http_connections_when_no_cassette' => true
13
+ }
12
14
  }
13
15
 
14
16
  def configure_vcr
@@ -20,13 +22,30 @@ module VcrCable
20
22
  end
21
23
 
22
24
  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
25
+ @config ||= global_config[env] || {}
26
+ end
27
+
28
+ def enabled?
29
+ config.present?
30
+ end
31
+
32
+ def reset_config
33
+ %w[global_config env_config config_file config].each do |name|
34
+ instance_variable_set "@#{name}", nil
30
35
  end
31
36
  end
37
+
38
+ def global_config
39
+ @global_config ||= File.file?(config_file) ? YAML.load_file(config_file) : DEFAULT_CONFIG
40
+ end
41
+
42
+ private
43
+
44
+ def env
45
+ Rails.env
46
+ end
47
+
48
+ def config_file
49
+ @config_file ||= Rails.root.join 'config', CONFIG_FILE
50
+ end
32
51
  end
@@ -12,7 +12,7 @@ development:
12
12
  # Warning: The database defined as "test" will be erased and
13
13
  # re-generated from your development database when you run "rake".
14
14
  # Do not set this db to the same as development or production.
15
- test:
15
+ test: &test
16
16
  adapter: sqlite3
17
17
  database: db/test.sqlite3
18
18
  pool: 5
@@ -23,3 +23,6 @@ production:
23
23
  database: db/production.sqlite3
24
24
  pool: 5
25
25
  timeout: 5000
26
+
27
+ no_vcr:
28
+ <<: *test
@@ -0,0 +1,37 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Configure static asset server for tests with Cache-Control for performance
11
+ config.serve_static_assets = true
12
+ config.static_cache_control = "public, max-age=3600"
13
+
14
+ # Log error messages when you accidentally call methods on nil
15
+ config.whiny_nils = true
16
+
17
+ # Show full error reports and disable caching
18
+ config.consider_all_requests_local = true
19
+ config.action_controller.perform_caching = false
20
+
21
+ # Raise exceptions instead of rendering exception templates
22
+ config.action_dispatch.show_exceptions = false
23
+
24
+ # Disable request forgery protection in test environment
25
+ config.action_controller.allow_forgery_protection = false
26
+
27
+ # Tell Action Mailer not to deliver emails to the real world.
28
+ # The :test delivery method accumulates sent emails in the
29
+ # ActionMailer::Base.deliveries array.
30
+ config.action_mailer.delivery_method = :test
31
+
32
+ # Raise exception on mass assignment protection for Active Record models
33
+ config.active_record.mass_assignment_sanitizer = :strict
34
+
35
+ # Print deprecation notices to the stderr
36
+ config.active_support.deprecation = :stderr
37
+ end
@@ -0,0 +1,3 @@
1
+ Connecting to database specified by database.yml
2
+ Connecting to database specified by database.yml
3
+ Connecting to database specified by database.yml
File without changes
@@ -432,3 +432,677 @@ Connecting to database specified by database.yml
432
432
   (0.1ms) rollback transaction
433
433
   (0.0ms) begin transaction
434
434
   (0.1ms) rollback transaction
435
+ Connecting to database specified by database.yml
436
+  (0.4ms) begin transaction
437
+  (0.1ms) rollback transaction
438
+  (0.1ms) begin transaction
439
+  (0.0ms) rollback transaction
440
+  (0.0ms) begin transaction
441
+  (0.1ms) rollback transaction
442
+  (0.0ms) begin transaction
443
+  (0.1ms) rollback transaction
444
+ Connecting to database specified by database.yml
445
+  (0.3ms) begin transaction
446
+  (0.0ms) rollback transaction
447
+  (0.1ms) begin transaction
448
+  (0.0ms) rollback transaction
449
+  (0.0ms) begin transaction
450
+  (0.1ms) rollback transaction
451
+  (0.0ms) begin transaction
452
+  (0.1ms) rollback transaction
453
+ Connecting to database specified by database.yml
454
+  (0.4ms) begin transaction
455
+  (0.0ms) rollback transaction
456
+  (0.0ms) begin transaction
457
+  (0.0ms) rollback transaction
458
+  (0.0ms) begin transaction
459
+  (0.1ms) rollback transaction
460
+  (0.0ms) begin transaction
461
+  (0.1ms) rollback transaction
462
+ Connecting to database specified by database.yml
463
+  (0.3ms) begin transaction
464
+  (0.0ms) rollback transaction
465
+  (0.0ms) begin transaction
466
+  (0.0ms) rollback transaction
467
+  (0.0ms) begin transaction
468
+  (0.1ms) rollback transaction
469
+  (0.1ms) begin transaction
470
+  (0.1ms) rollback transaction
471
+ Connecting to database specified by database.yml
472
+  (0.3ms) begin transaction
473
+  (0.0ms) rollback transaction
474
+  (0.0ms) begin transaction
475
+  (0.0ms) rollback transaction
476
+  (0.0ms) begin transaction
477
+  (0.1ms) rollback transaction
478
+  (0.0ms) begin transaction
479
+  (0.1ms) rollback transaction
480
+ Connecting to database specified by database.yml
481
+  (0.3ms) begin transaction
482
+  (0.0ms) rollback transaction
483
+  (0.0ms) begin transaction
484
+  (0.0ms) rollback transaction
485
+  (0.0ms) begin transaction
486
+  (0.2ms) rollback transaction
487
+  (0.1ms) begin transaction
488
+  (0.1ms) rollback transaction
489
+ Connecting to database specified by database.yml
490
+  (0.3ms) begin transaction
491
+  (0.0ms) rollback transaction
492
+  (0.0ms) begin transaction
493
+  (0.0ms) rollback transaction
494
+  (0.0ms) begin transaction
495
+  (0.1ms) rollback transaction
496
+  (0.0ms) begin transaction
497
+  (0.1ms) rollback transaction
498
+ Connecting to database specified by database.yml
499
+  (0.3ms) begin transaction
500
+  (0.0ms) rollback transaction
501
+  (0.0ms) begin transaction
502
+  (0.0ms) rollback transaction
503
+  (0.0ms) begin transaction
504
+  (0.2ms) rollback transaction
505
+  (0.1ms) begin transaction
506
+  (0.1ms) rollback transaction
507
+ Connecting to database specified by database.yml
508
+  (0.3ms) begin transaction
509
+  (0.0ms) rollback transaction
510
+  (0.0ms) begin transaction
511
+  (0.0ms) rollback transaction
512
+  (0.0ms) begin transaction
513
+  (0.1ms) rollback transaction
514
+  (0.0ms) begin transaction
515
+  (0.1ms) rollback transaction
516
+ Connecting to database specified by database.yml
517
+  (0.3ms) begin transaction
518
+  (0.1ms) rollback transaction
519
+  (0.1ms) begin transaction
520
+  (0.0ms) rollback transaction
521
+  (0.0ms) begin transaction
522
+  (0.1ms) rollback transaction
523
+  (0.0ms) begin transaction
524
+  (0.1ms) rollback transaction
525
+ Connecting to database specified by database.yml
526
+  (0.4ms) begin transaction
527
+  (0.0ms) rollback transaction
528
+  (0.0ms) begin transaction
529
+  (0.0ms) rollback transaction
530
+  (0.0ms) begin transaction
531
+  (0.1ms) rollback transaction
532
+  (0.1ms) begin transaction
533
+  (0.1ms) rollback transaction
534
+ Connecting to database specified by database.yml
535
+  (0.3ms) begin transaction
536
+  (0.0ms) rollback transaction
537
+  (0.0ms) begin transaction
538
+  (0.0ms) rollback transaction
539
+  (0.0ms) begin transaction
540
+  (0.1ms) rollback transaction
541
+  (0.0ms) begin transaction
542
+  (0.1ms) rollback transaction
543
+ Connecting to database specified by database.yml
544
+  (0.4ms) begin transaction
545
+  (0.1ms) rollback transaction
546
+  (0.1ms) begin transaction
547
+  (0.0ms) rollback transaction
548
+  (0.0ms) begin transaction
549
+  (0.1ms) rollback transaction
550
+  (0.0ms) begin transaction
551
+  (0.1ms) rollback transaction
552
+ Connecting to database specified by database.yml
553
+  (0.3ms) begin transaction
554
+  (0.0ms) rollback transaction
555
+  (0.1ms) begin transaction
556
+  (0.0ms) rollback transaction
557
+  (0.0ms) begin transaction
558
+  (0.1ms) rollback transaction
559
+  (0.0ms) begin transaction
560
+  (0.1ms) rollback transaction
561
+ Connecting to database specified by database.yml
562
+  (0.3ms) begin transaction
563
+  (0.1ms) rollback transaction
564
+  (0.0ms) begin transaction
565
+  (0.1ms) rollback transaction
566
+  (0.0ms) begin transaction
567
+  (0.1ms) rollback transaction
568
+  (0.1ms) begin transaction
569
+  (0.1ms) rollback transaction
570
+ Connecting to database specified by database.yml
571
+  (0.3ms) begin transaction
572
+  (0.0ms) rollback transaction
573
+  (0.0ms) begin transaction
574
+  (0.0ms) rollback transaction
575
+  (0.0ms) begin transaction
576
+  (0.1ms) rollback transaction
577
+  (0.0ms) begin transaction
578
+  (0.1ms) rollback transaction
579
+ Connecting to database specified by database.yml
580
+  (0.4ms) begin transaction
581
+  (0.0ms) rollback transaction
582
+  (0.1ms) begin transaction
583
+  (0.1ms) rollback transaction
584
+  (0.1ms) begin transaction
585
+  (0.1ms) rollback transaction
586
+  (0.0ms) begin transaction
587
+  (0.1ms) rollback transaction
588
+ Connecting to database specified by database.yml
589
+  (0.3ms) begin transaction
590
+  (0.1ms) rollback transaction
591
+  (0.0ms) begin transaction
592
+  (0.1ms) rollback transaction
593
+  (0.0ms) begin transaction
594
+  (0.1ms) rollback transaction
595
+  (0.1ms) begin transaction
596
+  (0.1ms) rollback transaction
597
+ Connecting to database specified by database.yml
598
+  (0.3ms) begin transaction
599
+  (0.0ms) rollback transaction
600
+  (0.2ms) begin transaction
601
+  (0.0ms) rollback transaction
602
+  (0.0ms) begin transaction
603
+  (0.1ms) rollback transaction
604
+  (0.0ms) begin transaction
605
+  (0.1ms) rollback transaction
606
+ Connecting to database specified by database.yml
607
+  (0.3ms) begin transaction
608
+  (0.0ms) rollback transaction
609
+  (0.0ms) begin transaction
610
+  (0.0ms) rollback transaction
611
+  (0.0ms) begin transaction
612
+  (0.1ms) rollback transaction
613
+  (0.0ms) begin transaction
614
+  (0.1ms) rollback transaction
615
+ Connecting to database specified by database.yml
616
+  (0.3ms) begin transaction
617
+  (0.0ms) rollback transaction
618
+  (0.0ms) begin transaction
619
+  (0.0ms) rollback transaction
620
+  (0.0ms) begin transaction
621
+  (0.1ms) rollback transaction
622
+  (0.0ms) begin transaction
623
+  (0.1ms) rollback transaction
624
+ Connecting to database specified by database.yml
625
+  (0.3ms) begin transaction
626
+  (0.0ms) rollback transaction
627
+  (0.0ms) begin transaction
628
+  (0.0ms) rollback transaction
629
+  (0.0ms) begin transaction
630
+  (0.1ms) rollback transaction
631
+  (0.9ms) begin transaction
632
+  (0.1ms) rollback transaction
633
+ Connecting to database specified by database.yml
634
+  (0.3ms) begin transaction
635
+  (0.0ms) rollback transaction
636
+  (0.0ms) begin transaction
637
+  (0.0ms) rollback transaction
638
+  (0.0ms) begin transaction
639
+  (0.1ms) rollback transaction
640
+  (0.0ms) begin transaction
641
+  (0.1ms) rollback transaction
642
+ Connecting to database specified by database.yml
643
+  (0.3ms) begin transaction
644
+  (0.1ms) rollback transaction
645
+  (0.0ms) begin transaction
646
+  (0.1ms) rollback transaction
647
+  (0.0ms) begin transaction
648
+  (0.2ms) rollback transaction
649
+  (0.0ms) begin transaction
650
+  (0.1ms) rollback transaction
651
+ Connecting to database specified by database.yml
652
+  (0.3ms) begin transaction
653
+  (0.1ms) rollback transaction
654
+  (0.0ms) begin transaction
655
+  (0.1ms) rollback transaction
656
+  (0.1ms) begin transaction
657
+  (0.1ms) rollback transaction
658
+  (0.1ms) begin transaction
659
+  (0.1ms) rollback transaction
660
+ Connecting to database specified by database.yml
661
+  (0.4ms) begin transaction
662
+  (0.1ms) rollback transaction
663
+  (0.0ms) begin transaction
664
+  (0.1ms) rollback transaction
665
+  (0.0ms) begin transaction
666
+  (0.1ms) rollback transaction
667
+  (0.1ms) begin transaction
668
+  (0.1ms) rollback transaction
669
+ Connecting to database specified by database.yml
670
+  (0.4ms) begin transaction
671
+  (0.1ms) rollback transaction
672
+  (0.0ms) begin transaction
673
+  (0.1ms) rollback transaction
674
+  (0.0ms) begin transaction
675
+  (0.1ms) rollback transaction
676
+  (0.1ms) begin transaction
677
+  (0.1ms) rollback transaction
678
+ Connecting to database specified by database.yml
679
+  (0.4ms) begin transaction
680
+  (0.0ms) rollback transaction
681
+  (0.1ms) begin transaction
682
+  (0.0ms) rollback transaction
683
+  (0.0ms) begin transaction
684
+  (0.4ms) rollback transaction
685
+ Connecting to database specified by database.yml
686
+  (0.4ms) begin transaction
687
+  (0.0ms) rollback transaction
688
+  (0.0ms) begin transaction
689
+  (0.0ms) rollback transaction
690
+  (0.0ms) begin transaction
691
+  (0.1ms) rollback transaction
692
+  (0.1ms) begin transaction
693
+  (0.1ms) rollback transaction
694
+ Connecting to database specified by database.yml
695
+  (0.3ms) begin transaction
696
+  (0.0ms) rollback transaction
697
+  (0.0ms) begin transaction
698
+  (0.0ms) rollback transaction
699
+  (0.0ms) begin transaction
700
+  (0.2ms) rollback transaction
701
+  (0.1ms) begin transaction
702
+  (0.1ms) rollback transaction
703
+ Connecting to database specified by database.yml
704
+  (0.4ms) begin transaction
705
+  (0.1ms) rollback transaction
706
+  (0.1ms) begin transaction
707
+  (0.1ms) rollback transaction
708
+  (0.0ms) begin transaction
709
+  (0.1ms) rollback transaction
710
+  (0.1ms) begin transaction
711
+  (0.1ms) rollback transaction
712
+ Connecting to database specified by database.yml
713
+  (0.3ms) begin transaction
714
+  (0.0ms) rollback transaction
715
+  (0.1ms) begin transaction
716
+  (0.0ms) rollback transaction
717
+  (0.0ms) begin transaction
718
+  (0.2ms) rollback transaction
719
+  (0.1ms) begin transaction
720
+  (0.1ms) rollback transaction
721
+ Connecting to database specified by database.yml
722
+  (0.4ms) begin transaction
723
+  (0.0ms) rollback transaction
724
+  (0.0ms) begin transaction
725
+  (0.0ms) rollback transaction
726
+  (0.0ms) begin transaction
727
+  (0.1ms) rollback transaction
728
+  (0.1ms) begin transaction
729
+  (0.1ms) rollback transaction
730
+ Connecting to database specified by database.yml
731
+  (0.4ms) begin transaction
732
+  (0.0ms) rollback transaction
733
+  (0.0ms) begin transaction
734
+  (0.0ms) rollback transaction
735
+  (0.0ms) begin transaction
736
+  (0.2ms) rollback transaction
737
+  (0.1ms) begin transaction
738
+  (0.1ms) rollback transaction
739
+ Connecting to database specified by database.yml
740
+  (0.4ms) begin transaction
741
+  (0.0ms) rollback transaction
742
+  (0.0ms) begin transaction
743
+  (0.0ms) rollback transaction
744
+  (0.0ms) begin transaction
745
+  (0.1ms) rollback transaction
746
+  (0.1ms) begin transaction
747
+  (0.1ms) rollback transaction
748
+ Connecting to database specified by database.yml
749
+  (0.3ms) begin transaction
750
+  (0.0ms) rollback transaction
751
+  (0.0ms) begin transaction
752
+  (0.0ms) rollback transaction
753
+  (0.0ms) begin transaction
754
+  (0.1ms) rollback transaction
755
+  (0.1ms) begin transaction
756
+  (0.1ms) rollback transaction
757
+ Connecting to database specified by database.yml
758
+  (0.3ms) begin transaction
759
+  (0.0ms) rollback transaction
760
+  (0.0ms) begin transaction
761
+  (0.0ms) rollback transaction
762
+  (0.0ms) begin transaction
763
+  (0.1ms) rollback transaction
764
+  (0.1ms) begin transaction
765
+  (0.1ms) rollback transaction
766
+ Connecting to database specified by database.yml
767
+  (0.4ms) begin transaction
768
+  (0.0ms) rollback transaction
769
+  (0.0ms) begin transaction
770
+  (0.0ms) rollback transaction
771
+  (0.0ms) begin transaction
772
+  (0.1ms) rollback transaction
773
+  (0.1ms) begin transaction
774
+  (0.1ms) rollback transaction
775
+ Connecting to database specified by database.yml
776
+  (0.3ms) begin transaction
777
+  (0.0ms) rollback transaction
778
+  (0.0ms) begin transaction
779
+  (0.0ms) rollback transaction
780
+  (0.0ms) begin transaction
781
+  (0.1ms) rollback transaction
782
+  (0.1ms) begin transaction
783
+  (0.1ms) rollback transaction
784
+  (0.1ms) begin transaction
785
+  (0.1ms) rollback transaction
786
+ Connecting to database specified by database.yml
787
+  (0.3ms) begin transaction
788
+  (0.0ms) rollback transaction
789
+  (0.0ms) begin transaction
790
+  (0.0ms) rollback transaction
791
+  (0.0ms) begin transaction
792
+  (0.2ms) rollback transaction
793
+  (0.1ms) begin transaction
794
+  (0.1ms) rollback transaction
795
+  (0.0ms) begin transaction
796
+  (0.1ms) rollback transaction
797
+ Connecting to database specified by database.yml
798
+  (0.3ms) begin transaction
799
+  (0.0ms) rollback transaction
800
+  (0.1ms) begin transaction
801
+  (0.0ms) rollback transaction
802
+  (0.0ms) begin transaction
803
+  (0.1ms) rollback transaction
804
+  (0.0ms) begin transaction
805
+  (0.1ms) rollback transaction
806
+  (0.1ms) begin transaction
807
+  (0.1ms) rollback transaction
808
+  (0.1ms) begin transaction
809
+  (0.1ms) rollback transaction
810
+ Connecting to database specified by database.yml
811
+  (0.4ms) begin transaction
812
+  (0.1ms) rollback transaction
813
+  (0.1ms) begin transaction
814
+  (0.1ms) rollback transaction
815
+  (0.0ms) begin transaction
816
+  (0.1ms) rollback transaction
817
+  (0.0ms) begin transaction
818
+  (0.1ms) rollback transaction
819
+  (0.1ms) begin transaction
820
+  (0.1ms) rollback transaction
821
+  (0.1ms) begin transaction
822
+  (0.1ms) rollback transaction
823
+ Connecting to database specified by database.yml
824
+  (0.3ms) begin transaction
825
+  (0.0ms) rollback transaction
826
+  (0.0ms) begin transaction
827
+  (0.0ms) rollback transaction
828
+  (0.0ms) begin transaction
829
+  (0.0ms) rollback transaction
830
+  (0.0ms) begin transaction
831
+  (0.1ms) rollback transaction
832
+  (0.1ms) begin transaction
833
+  (0.1ms) rollback transaction
834
+  (0.1ms) begin transaction
835
+  (0.1ms) rollback transaction
836
+ Connecting to database specified by database.yml
837
+  (0.3ms) begin transaction
838
+  (0.0ms) rollback transaction
839
+  (0.0ms) begin transaction
840
+  (0.0ms) rollback transaction
841
+  (0.0ms) begin transaction
842
+  (0.0ms) rollback transaction
843
+  (0.0ms) begin transaction
844
+  (0.1ms) rollback transaction
845
+ Connecting to database specified by database.yml
846
+  (0.4ms) begin transaction
847
+  (0.0ms) rollback transaction
848
+  (0.1ms) begin transaction
849
+  (0.0ms) rollback transaction
850
+  (0.0ms) begin transaction
851
+  (0.0ms) rollback transaction
852
+  (0.0ms) begin transaction
853
+  (0.1ms) rollback transaction
854
+  (0.1ms) begin transaction
855
+  (0.1ms) rollback transaction
856
+  (0.1ms) begin transaction
857
+  (0.1ms) rollback transaction
858
+ Connecting to database specified by database.yml
859
+  (0.3ms) begin transaction
860
+  (0.0ms) rollback transaction
861
+  (0.0ms) begin transaction
862
+  (0.0ms) rollback transaction
863
+  (0.0ms) begin transaction
864
+  (0.0ms) rollback transaction
865
+  (0.0ms) begin transaction
866
+  (0.1ms) rollback transaction
867
+  (0.0ms) begin transaction
868
+  (0.1ms) rollback transaction
869
+  (0.1ms) begin transaction
870
+  (0.1ms) rollback transaction
871
+ Connecting to database specified by database.yml
872
+  (0.4ms) begin transaction
873
+  (0.1ms) rollback transaction
874
+  (0.1ms) begin transaction
875
+  (0.1ms) rollback transaction
876
+  (0.2ms) begin transaction
877
+  (0.1ms) rollback transaction
878
+  (0.0ms) begin transaction
879
+  (0.1ms) rollback transaction
880
+  (0.1ms) begin transaction
881
+  (0.1ms) rollback transaction
882
+  (0.0ms) begin transaction
883
+  (0.1ms) rollback transaction
884
+ Connecting to database specified by database.yml
885
+  (0.3ms) begin transaction
886
+  (0.0ms) rollback transaction
887
+  (0.1ms) begin transaction
888
+  (0.0ms) rollback transaction
889
+  (0.0ms) begin transaction
890
+  (0.1ms) rollback transaction
891
+  (0.0ms) begin transaction
892
+  (0.0ms) rollback transaction
893
+  (0.0ms) begin transaction
894
+  (0.1ms) rollback transaction
895
+  (0.1ms) begin transaction
896
+  (0.1ms) rollback transaction
897
+ Connecting to database specified by database.yml
898
+  (0.3ms) begin transaction
899
+  (0.0ms) rollback transaction
900
+  (0.1ms) begin transaction
901
+  (0.0ms) rollback transaction
902
+  (0.0ms) begin transaction
903
+  (0.1ms) rollback transaction
904
+  (0.0ms) begin transaction
905
+  (0.0ms) rollback transaction
906
+  (0.0ms) begin transaction
907
+  (0.2ms) rollback transaction
908
+  (0.0ms) begin transaction
909
+  (0.1ms) rollback transaction
910
+ Connecting to database specified by database.yml
911
+  (0.4ms) begin transaction
912
+  (0.0ms) rollback transaction
913
+  (0.1ms) begin transaction
914
+  (0.0ms) rollback transaction
915
+  (0.0ms) begin transaction
916
+  (0.0ms) rollback transaction
917
+  (0.0ms) begin transaction
918
+  (0.1ms) rollback transaction
919
+  (0.1ms) begin transaction
920
+  (0.1ms) rollback transaction
921
+ Connecting to database specified by database.yml
922
+  (0.4ms) begin transaction
923
+  (0.0ms) rollback transaction
924
+  (0.1ms) begin transaction
925
+  (0.0ms) rollback transaction
926
+  (0.0ms) begin transaction
927
+  (0.0ms) rollback transaction
928
+  (0.0ms) begin transaction
929
+  (0.1ms) rollback transaction
930
+  (0.0ms) begin transaction
931
+  (0.1ms) rollback transaction
932
+ Connecting to database specified by database.yml
933
+  (0.3ms) begin transaction
934
+  (0.0ms) rollback transaction
935
+  (0.0ms) begin transaction
936
+  (0.0ms) rollback transaction
937
+  (0.0ms) begin transaction
938
+  (0.0ms) rollback transaction
939
+  (0.0ms) begin transaction
940
+  (0.0ms) rollback transaction
941
+  (0.0ms) begin transaction
942
+  (0.0ms) rollback transaction
943
+  (0.0ms) begin transaction
944
+  (0.1ms) rollback transaction
945
+  (0.1ms) begin transaction
946
+  (0.1ms) rollback transaction
947
+ Connecting to database specified by database.yml
948
+  (0.3ms) begin transaction
949
+  (0.0ms) rollback transaction
950
+  (0.1ms) begin transaction
951
+  (0.1ms) rollback transaction
952
+  (0.1ms) begin transaction
953
+  (0.0ms) rollback transaction
954
+  (0.0ms) begin transaction
955
+  (0.0ms) rollback transaction
956
+  (0.0ms) begin transaction
957
+  (0.0ms) rollback transaction
958
+  (0.0ms) begin transaction
959
+  (0.1ms) rollback transaction
960
+  (0.1ms) begin transaction
961
+  (0.1ms) rollback transaction
962
+ Connecting to database specified by database.yml
963
+  (0.4ms) begin transaction
964
+  (0.0ms) rollback transaction
965
+  (0.0ms) begin transaction
966
+  (0.0ms) rollback transaction
967
+  (0.0ms) begin transaction
968
+  (0.0ms) rollback transaction
969
+  (0.0ms) begin transaction
970
+  (0.0ms) rollback transaction
971
+  (0.0ms) begin transaction
972
+  (0.0ms) rollback transaction
973
+  (0.0ms) begin transaction
974
+  (0.1ms) rollback transaction
975
+  (0.1ms) begin transaction
976
+  (0.1ms) rollback transaction
977
+ Connecting to database specified by database.yml
978
+  (0.4ms) begin transaction
979
+  (0.0ms) rollback transaction
980
+  (0.0ms) begin transaction
981
+  (0.0ms) rollback transaction
982
+  (0.0ms) begin transaction
983
+  (0.0ms) rollback transaction
984
+  (0.0ms) begin transaction
985
+  (0.0ms) rollback transaction
986
+  (0.0ms) begin transaction
987
+  (0.0ms) rollback transaction
988
+  (0.0ms) begin transaction
989
+  (0.1ms) rollback transaction
990
+  (0.1ms) begin transaction
991
+  (0.1ms) rollback transaction
992
+ Connecting to database specified by database.yml
993
+  (0.4ms) begin transaction
994
+  (0.0ms) rollback transaction
995
+  (0.1ms) begin transaction
996
+  (0.0ms) rollback transaction
997
+  (0.0ms) begin transaction
998
+  (0.0ms) rollback transaction
999
+  (0.0ms) begin transaction
1000
+  (0.0ms) rollback transaction
1001
+  (0.0ms) begin transaction
1002
+  (0.0ms) rollback transaction
1003
+  (0.0ms) begin transaction
1004
+  (0.1ms) rollback transaction
1005
+  (0.1ms) begin transaction
1006
+  (0.1ms) rollback transaction
1007
+ Connecting to database specified by database.yml
1008
+  (0.3ms) begin transaction
1009
+  (0.0ms) rollback transaction
1010
+  (0.0ms) begin transaction
1011
+  (0.0ms) rollback transaction
1012
+  (0.0ms) begin transaction
1013
+  (0.0ms) rollback transaction
1014
+  (0.0ms) begin transaction
1015
+  (0.0ms) rollback transaction
1016
+  (0.0ms) begin transaction
1017
+  (0.0ms) rollback transaction
1018
+  (0.0ms) begin transaction
1019
+  (0.0ms) rollback transaction
1020
+  (0.0ms) begin transaction
1021
+  (0.1ms) rollback transaction
1022
+  (0.0ms) begin transaction
1023
+  (0.1ms) rollback transaction
1024
+ Connecting to database specified by database.yml
1025
+  (0.4ms) begin transaction
1026
+  (0.0ms) rollback transaction
1027
+  (0.0ms) begin transaction
1028
+  (0.0ms) rollback transaction
1029
+  (0.0ms) begin transaction
1030
+  (0.0ms) rollback transaction
1031
+  (0.0ms) begin transaction
1032
+  (0.0ms) rollback transaction
1033
+  (0.0ms) begin transaction
1034
+  (0.0ms) rollback transaction
1035
+  (0.0ms) begin transaction
1036
+  (0.0ms) rollback transaction
1037
+  (0.0ms) begin transaction
1038
+  (0.2ms) rollback transaction
1039
+  (0.1ms) begin transaction
1040
+  (0.1ms) rollback transaction
1041
+ Connecting to database specified by database.yml
1042
+  (0.3ms) begin transaction
1043
+  (0.0ms) rollback transaction
1044
+  (0.1ms) begin transaction
1045
+  (0.0ms) rollback transaction
1046
+  (0.0ms) begin transaction
1047
+  (0.0ms) rollback transaction
1048
+  (0.0ms) begin transaction
1049
+  (0.0ms) rollback transaction
1050
+  (0.0ms) begin transaction
1051
+  (0.0ms) rollback transaction
1052
+  (0.0ms) begin transaction
1053
+  (0.0ms) rollback transaction
1054
+  (0.0ms) begin transaction
1055
+  (0.1ms) rollback transaction
1056
+  (0.1ms) begin transaction
1057
+  (0.1ms) rollback transaction
1058
+ Connecting to database specified by database.yml
1059
+  (0.3ms) begin transaction
1060
+  (0.0ms) rollback transaction
1061
+  (0.1ms) begin transaction
1062
+  (0.1ms) rollback transaction
1063
+  (0.0ms) begin transaction
1064
+  (0.0ms) rollback transaction
1065
+  (0.0ms) begin transaction
1066
+  (0.0ms) rollback transaction
1067
+  (0.0ms) begin transaction
1068
+  (0.0ms) rollback transaction
1069
+  (0.0ms) begin transaction
1070
+  (0.0ms) rollback transaction
1071
+  (0.0ms) begin transaction
1072
+  (0.1ms) rollback transaction
1073
+  (0.1ms) begin transaction
1074
+  (0.1ms) rollback transaction
1075
+ Connecting to database specified by database.yml
1076
+  (0.3ms) begin transaction
1077
+  (0.0ms) rollback transaction
1078
+  (0.1ms) begin transaction
1079
+  (0.0ms) rollback transaction
1080
+  (0.0ms) begin transaction
1081
+  (0.0ms) rollback transaction
1082
+  (0.0ms) begin transaction
1083
+  (0.0ms) rollback transaction
1084
+  (0.0ms) begin transaction
1085
+  (0.0ms) rollback transaction
1086
+  (0.0ms) begin transaction
1087
+  (0.0ms) rollback transaction
1088
+  (0.0ms) begin transaction
1089
+  (0.2ms) rollback transaction
1090
+  (0.1ms) begin transaction
1091
+  (0.1ms) rollback transaction
1092
+ Connecting to database specified by database.yml
1093
+  (0.3ms) begin transaction
1094
+  (0.0ms) rollback transaction
1095
+  (0.0ms) begin transaction
1096
+  (0.0ms) rollback transaction
1097
+  (0.0ms) begin transaction
1098
+  (0.0ms) rollback transaction
1099
+  (0.0ms) begin transaction
1100
+  (0.1ms) rollback transaction
1101
+  (0.0ms) begin transaction
1102
+  (0.0ms) rollback transaction
1103
+  (0.0ms) begin transaction
1104
+  (0.0ms) rollback transaction
1105
+  (0.0ms) begin transaction
1106
+  (0.1ms) rollback transaction
1107
+  (0.1ms) begin transaction
1108
+  (0.1ms) rollback transaction
@@ -1,19 +1,48 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class VcrCableTest < ActiveSupport::TestCase
4
- test 'loads the default config' do
5
- File.stubs(:file?).returns false
6
- VcrCable.instance_variable_set('@config', nil)
4
+ setup { VcrCable.reset_config }
5
+
6
+ test 'is enabled when config is present' do
7
+ VcrCable.stubs(:config).returns({:some => :conf})
8
+ assert VcrCable.enabled?
9
+ end
10
+
11
+ test 'is not enabled when config is not present' do
12
+ VcrCable.stubs(:config).returns({})
13
+ assert !VcrCable.enabled?
14
+ end
15
+
16
+ test 'loads the default config when current env has configuration' do
17
+ File.stubs(:file?).returns(false)
18
+ VcrCable.stubs(:env).returns('development')
7
19
  VcrCable.configure_vcr
8
20
  assert_match /development_cassettes$/, VCR.configuration.cassette_library_dir
9
21
  end
10
22
 
11
- test 'configuration in config/vcr_cable.yml overwrites default values' do
23
+ test 'has no config when the current env has no configuration' do
24
+ VcrCable.stubs(:env).returns('without_vcr_cable')
25
+ assert !VcrCable.config.present?
26
+ end
27
+
28
+ test 'config in config/vcr_cable.yml overwrites default values' do
12
29
  VcrCable.configure_vcr
13
30
  assert_match /custom_named_cassettes$/, VCR.configuration.cassette_library_dir
14
31
  end
15
32
 
33
+ test 'global_config contains all env specific configs' do
34
+ %w[test development].each do |env_name|
35
+ VcrCable.global_config.keys.include?(env_name)
36
+ end
37
+ end
38
+
16
39
  test 'adds VCR::Middleware::Rack to the middleware stack' do
17
40
  assert Rails.configuration.middleware.any? {|name| name == 'VCR::Middleware::Rack'}
18
41
  end
42
+
43
+ test 'it does not add VCR::Middleware::Rack to environments that are not enabled' do
44
+ list = Dir.chdir(Rails.root) {`bundle exec rake middleware RAILS_ENV=no_vcr`}
45
+ assert_not_match /VCR::Middleware::Rack/, list
46
+ end
47
+
19
48
  end
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.1.3
4
+ version: 0.2.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-27 00:00:00.000000000 Z
12
+ date: 2012-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -133,6 +133,7 @@ files:
133
133
  - test/dummy/config/database.yml
134
134
  - test/dummy/config/environment.rb
135
135
  - test/dummy/config/environments/development.rb
136
+ - test/dummy/config/environments/no_vcr.rb
136
137
  - test/dummy/config/environments/production.rb
137
138
  - test/dummy/config/environments/test.rb
138
139
  - test/dummy/config/initializers/backtrace_silencers.rb
@@ -149,6 +150,8 @@ files:
149
150
  - test/dummy/db/schema.rb
150
151
  - test/dummy/db/test.sqlite3
151
152
  - test/dummy/log/development.log
153
+ - test/dummy/log/no_vcr.log
154
+ - test/dummy/log/no_vcr_cable.log
152
155
  - test/dummy/log/test.log
153
156
  - test/dummy/public/404.html
154
157
  - test/dummy/public/422.html
@@ -173,7 +176,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
173
176
  version: '0'
174
177
  segments:
175
178
  - 0
176
- hash: -3372546154796512749
179
+ hash: -2234079835404851201
177
180
  required_rubygems_version: !ruby/object:Gem::Requirement
178
181
  none: false
179
182
  requirements:
@@ -182,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
185
  version: '0'
183
186
  segments:
184
187
  - 0
185
- hash: -3372546154796512749
188
+ hash: -2234079835404851201
186
189
  requirements: []
187
190
  rubyforge_project:
188
191
  rubygems_version: 1.8.24
@@ -200,6 +203,7 @@ test_files:
200
203
  - test/dummy/config/database.yml
201
204
  - test/dummy/config/environment.rb
202
205
  - test/dummy/config/environments/development.rb
206
+ - test/dummy/config/environments/no_vcr.rb
203
207
  - test/dummy/config/environments/production.rb
204
208
  - test/dummy/config/environments/test.rb
205
209
  - test/dummy/config/initializers/backtrace_silencers.rb
@@ -216,6 +220,8 @@ test_files:
216
220
  - test/dummy/db/schema.rb
217
221
  - test/dummy/db/test.sqlite3
218
222
  - test/dummy/log/development.log
223
+ - test/dummy/log/no_vcr.log
224
+ - test/dummy/log/no_vcr_cable.log
219
225
  - test/dummy/log/test.log
220
226
  - test/dummy/public/404.html
221
227
  - test/dummy/public/422.html