Advertisement
Guest User

Untitled

a guest
Jan 24th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.64 KB | None | 0 0
  1. Capybara.configure do |config|
  2. # we must force the value of the capybara server port. We have to do that because puffing-billy
  3. # saves everything locally for a specific host and port. But, capybara starts your rack application
  4. # on a new port each time you run your tests. The consequence is puffing-billy
  5. # is not able to reuse the created cache files and tries to do all the API call again.
  6. # source - kevin.disneur.me/archives/2015-03-05-end-to-end-tests-in-javascript.html
  7. config.server_port = 60001
  8. # source: comments in coderwall.com/p/jsutlq, enable to load save_and_open page with css and js
  9. config.asset_host = 'http://localhost:3000'
  10. end
  11.  
  12. require 'billy/capybara/rspec'
  13. Billy.configure do |c|
  14. c.cache = true
  15. c.cache_request_headers = false
  16. c.persist_cache = true
  17. c.non_successful_cache_disabled = true
  18. c.non_successful_error_level = :warn
  19. c.whitelist = ['localhost', '127.0.0.1', 'https://res.cloudinary.com']
  20. c.ignore_cache_port = true
  21. c.cache_path = "spec/support/http_cache/billy/"
  22. # Only set non_whitelisted_requests_disabled **temporarily**
  23. # to false when first recording a 3rd party interaction. After
  24. # the recording has been stored to cache_path, then set
  25. # non_whitelisted_requests_disabled back to true.
  26. c.non_whitelisted_requests_disabled = true
  27. end
  28.  
  29. context "non signed in visitor", js: true, billy: true do
  30.  
  31. describe "Spinner shows while waiting then disappears" do
  32. it "should work" do proxy.stub("https://res.cloudinary.com/demo/image/upload/sample.jpg").and_return(
  33. Proc.new { |params, headers, body|
  34. sleep 10
  35. {code: 200}
  36. }
  37. )
  38.  
  39. visit actual_deal_page_path(deal)
  40.  
  41. # detect spinner
  42. expect(page).to have_css('div#fullPageLoadingSpinner', visible: :visible)
  43. # check subsequent image elements not yet visible
  44. expect(page).to have_no_css("img[src*='https://res.cloudinary.com/demo/image/upload/sample.jpg']")
  45.  
  46. # then after 15 seconds, the cloudinary image finally is loaded and
  47. # the spinner disappears
  48. sleep 15
  49. expect(page).to have_css('div#fullPageLoadingSpinner', visible: :hidden)
  50. expect(page).to have_css("img[src*='https://res.cloudinary.com/demo/image/upload/sample.jpg']", visible: :visible)
  51. end
  52. end
  53. end
  54.  
  55. <section
  56. id="introImg"
  57. <img src="https://res.cloudinary.com/demo/image/upload/sample.jpg" class="cld-responsive deal-page-bckdImgCover"
  58. </section>
  59.  
  60. puffing-billy: CACHE KEY for 'https://res.cloudinary.com:443/demo/image/upload/sample.jpg' is 'get_res.cloudinary.com_2c4fefdac8978387ee341535c534e21e2588ed76'
  61. puffing-billy: Connection to https://res.cloudinary.com:443/demo/image/upload/sample.jpg not cached and new http connections are disabled
  62. puffing-billy: CACHE KEY for 'https://res.cloudinary.com:443/demo/image/upload/sample.jpg' is 'get_res.cloudinary.com_2c4fefdac8978387ee341535c534e21e2588ed76'
  63. puffing-billy: Connection to https://res.cloudinary.com:443/demo/image/upload/sample.jpg not cached and new http connections are disabled
  64. puffing-billy: CACHE KEY for 'https://res.cloudinary.com:443/demo/image/upload/sample.jpg' is 'get_res.cloudinary.com_2c4fefdac8978387ee341535c534e21e2588ed76'
  65. puffing-billy: Connection to https://res.cloudinary.com:443/demo/image/upload/sample.jpg not cached and new http connections are disabled
  66. puffing-billy: CACHE KEY for 'https://res.cloudinary.com:443/demo/image/upload/sample.jpg' is 'get_res.cloudinary.com_2c4fefdac8978387ee341535c534e21e2588ed76'
  67. puffing-billy: Connection to https://res.cloudinary.com:443/demo/image/upload/sample.jpg not cached and new http connections are disabled
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement