@@ -24,6 +24,10 @@ def session_url(path)
2424 "http://#{ server . host } :#{ server . port } #{ path } "
2525 end
2626
27+ def non_favicon_exchanges ( network_exchanges )
28+ network_exchanges . reject { _1 . url == session_url ( '/favicon.ico' ) }
29+ end
30+
2731 it "supports a custom path" do
2832 original_path = "#{ PROJECT_ROOT } /spec/support/chrome_path"
2933 File . write ( original_path , @driver . browser . process . path )
@@ -716,40 +720,40 @@ def create_screenshot(file, *args)
716720
717721 it "captures responses" do
718722 @session . visit ( "/cuprite/with_js" )
719- request = @driver . network_traffic . last
723+ request = non_favicon_exchanges ( @driver . network_traffic ) . last
720724
721725 expect ( request . response . status ) . to eq ( 200 )
722726 end
723727
724728 it "captures errors" do
725729 @session . visit ( "/cuprite/with_ajax_fail" )
726730 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
728732
729733 expect ( error ) . to be
730734 end
731735
732736 it "keeps a running list between multiple web page views" do
733737 @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 )
735739
736740 @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 )
738742 end
739743
740744 it "gets cleared on restart" do
741745 @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 )
743747
744748 @driver . restart
745749
746750 @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 )
748752 end
749753
750754 it "gets cleared when being cleared" do
751755 @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 )
753757
754758 @driver . clear_network_traffic
755759
@@ -787,21 +791,24 @@ def create_screenshot(file, *args)
787791 @driver . clear_memory_cache
788792
789793 @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
793798
794799 @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
798804
799805 @driver . clear_memory_cache
800806
801807 @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
805812 end
806813
807814 context "status code support" do
@@ -1071,8 +1078,11 @@ def create_screenshot(file, *args)
10711078 end
10721079
10731080 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+ )
10761086
10771087 expect ( @session . status_code ) . to eq ( 401 )
10781088 expect ( @session ) . not_to have_content ( "Welcome, authenticated client" )
0 commit comments