@@ -24,6 +24,10 @@ def session_url(path)
24
24
"http://#{ server . host } :#{ server . port } #{ path } "
25
25
end
26
26
27
+ def non_favicon_exchanges ( network_exchanges )
28
+ network_exchanges . reject { _1 . url == session_url ( '/favicon.ico' ) }
29
+ end
30
+
27
31
it "supports a custom path" do
28
32
original_path = "#{ PROJECT_ROOT } /spec/support/chrome_path"
29
33
File . write ( original_path , @driver . browser . process . path )
@@ -716,40 +720,40 @@ def create_screenshot(file, *args)
716
720
717
721
it "captures responses" do
718
722
@session . visit ( "/cuprite/with_js" )
719
- request = @driver . network_traffic . last
723
+ request = non_favicon_exchanges ( @driver . network_traffic ) . last
720
724
721
725
expect ( request . response . status ) . to eq ( 200 )
722
726
end
723
727
724
728
it "captures errors" do
725
729
@session . visit ( "/cuprite/with_ajax_fail" )
726
730
expect ( @session ) . to have_css ( "h1" , text : "Done" )
727
- error = @driver . network_traffic . last . error
731
+ error = non_favicon_exchanges ( @driver . network_traffic ) . last . error
728
732
729
733
expect ( error ) . to be
730
734
end
731
735
732
736
it "keeps a running list between multiple web page views" do
733
737
@session . visit ( "/cuprite/with_js" )
734
- expect ( @driver . network_traffic . length ) . to eq ( 4 )
738
+ expect ( non_favicon_exchanges ( @driver . network_traffic ) . length ) . to eq ( 4 )
735
739
736
740
@session . visit ( "/cuprite/with_js" )
737
- expect ( @driver . network_traffic . length ) . to eq ( 8 )
741
+ expect ( non_favicon_exchanges ( @driver . network_traffic ) . length ) . to eq ( 8 )
738
742
end
739
743
740
744
it "gets cleared on restart" do
741
745
@session . visit ( "/cuprite/with_js" )
742
- expect ( @driver . network_traffic . length ) . to eq ( 4 )
746
+ expect ( non_favicon_exchanges ( @driver . network_traffic ) . length ) . to eq ( 4 )
743
747
744
748
@driver . restart
745
749
746
750
@session . visit ( "/cuprite/with_js" )
747
- expect ( @driver . network_traffic . length ) . to eq ( 4 )
751
+ expect ( non_favicon_exchanges ( @driver . network_traffic ) . length ) . to eq ( 4 )
748
752
end
749
753
750
754
it "gets cleared when being cleared" do
751
755
@session . visit ( "/cuprite/with_js" )
752
- expect ( @driver . network_traffic . length ) . to eq ( 4 )
756
+ expect ( non_favicon_exchanges ( @driver . network_traffic ) . length ) . to eq ( 4 )
753
757
754
758
@driver . clear_network_traffic
755
759
@@ -787,21 +791,24 @@ def create_screenshot(file, *args)
787
791
@driver . clear_memory_cache
788
792
789
793
@session . visit ( "/cuprite/cacheable" )
790
- expect ( @driver . network_traffic . length ) . to eq ( 1 )
791
- expect ( @driver . network_traffic . last . response . status ) . to eq ( 200 )
792
- expect ( @driver . network_traffic . last . response . params . dig ( "response" , "fromDiskCache" ) ) . to be_falsey
794
+ network_exchanges = non_favicon_exchanges ( @driver . network_traffic )
795
+ expect ( network_exchanges . length ) . to eq ( 1 )
796
+ expect ( network_exchanges . last . response . status ) . to eq ( 200 )
797
+ expect ( network_exchanges . last . response . params . dig ( "response" , "fromDiskCache" ) ) . to be_falsey
793
798
794
799
@session . click_link "click me"
795
- expect ( @driver . network_traffic . length ) . to eq ( 2 )
796
- expect ( @driver . network_traffic . last . response . status ) . to eq ( 200 )
797
- expect ( @driver . network_traffic . last . response . params . dig ( "response" , "fromDiskCache" ) ) . to be_truthy
800
+ network_exchanges = non_favicon_exchanges ( @driver . network_traffic )
801
+ expect ( network_exchanges . length ) . to eq ( 2 )
802
+ expect ( network_exchanges . last . response . status ) . to eq ( 200 )
803
+ expect ( network_exchanges . last . response . params . dig ( "response" , "fromDiskCache" ) ) . to be_truthy
798
804
799
805
@driver . clear_memory_cache
800
806
801
807
@session . click_link "click me"
802
- expect ( @driver . network_traffic . length ) . to eq ( 3 )
803
- expect ( @driver . network_traffic . last . response . status ) . to eq ( 200 )
804
- expect ( @driver . network_traffic . last . response . params . dig ( "response" , "fromDiskCache" ) ) . to be_falsey
808
+ network_exchanges = non_favicon_exchanges ( @driver . network_traffic )
809
+ expect ( network_exchanges . length ) . to eq ( 3 )
810
+ expect ( network_exchanges . last . response . status ) . to eq ( 200 )
811
+ expect ( network_exchanges . last . response . params . dig ( "response" , "fromDiskCache" ) ) . to be_falsey
805
812
end
806
813
807
814
context "status code support" do
@@ -1071,8 +1078,11 @@ def create_screenshot(file, *args)
1071
1078
end
1072
1079
1073
1080
context "basic http authentication" do
1074
- it "denies without credentials" do
1075
- @session . visit "/cuprite/basic_auth"
1081
+ it "raises an error and denies without credentials" do
1082
+ expect { @session . visit "/cuprite/basic_auth" } . to raise_error (
1083
+ Ferrum ::StatusError ,
1084
+ %r{Request to .*/basic_auth failed \( net::ERR_INVALID_AUTH_CREDENTIALS\) }
1085
+ )
1076
1086
1077
1087
expect ( @session . status_code ) . to eq ( 401 )
1078
1088
expect ( @session ) . not_to have_content ( "Welcome, authenticated client" )
0 commit comments