Search code examples
ruby-on-railsangularjsrspec-railsfilepicker.iocapybara-webkit

RSpec: failure Cabybara Webkit InvalidResponseError


I'm getting this error on a dozen or so failing specs. Other devs on my team (and our CI) aren't seeing these failing specs so it's a problem local to my kit.

Edit: first 6 lines are an excerpt from capybara-webkit's :webkit_debug driver:

...
Started request to "https://dialog.filepicker.io/dialog/comm_iframe/"
Started request to "https://www.filepicker.io/dialog/comm_iframe/"
Received "Evaluate((typeof angular !== 'undefined') && angular.element(document.querySelector('[ng-app]')).length > 0)"
"TimeoutCommand" waiting for load to finish
Received 0 from "https://dialog.filepicker.io/dialog/comm_iframe/"
Page finished with false
...

  1) User edits profile information
     Failure/Error: click_on t('users.edit')
     Capybara::Webkit::InvalidResponseError:
       Unable to load URL: http://127.0.0.1:53899/myprofile?as=1089 because of error loading https://dialog.filepicker.io/dialog/comm_iframe/: Unknown error
     # ./spec/features/users_spec.rb:30:in `block (2 levels) in <top (required)>'
     # ./spec/support/background_jobs.rb:14:in `block (3 levels) in <top (required)>'
     # ./spec/support/background_jobs.rb:5:in `run_background_jobs_immediately'
     # ./spec/support/background_jobs.rb:13:in `block (2 levels) in <top (required)>'

How can I troubleshoot this? Is this somehow AngularJS related?!?

Edit2: error is thrown on visit path (see below). Adding save_and_open_page one line before just opens an empty page. Putting anything after line 30 never gets called because of error. Adding binding.pry on 29 gets me to console but I'm not really sure what I should be looking for to troubleshoot this.

     25:   scenario 'edits profile information', js: true do
     26:     new_avatar = 'http://example.com/avatar.png'
     27:     user = create(:user)
     28:
  => 29:     binding.pry
     30:     visit myprofile_path(as: user)
     31:     click_on t('users.edit')
     32:     edit_profile(name: 'Edit User', avatar: new_avatar)
     33:     visit myprofile_path
     34:
     35:     expect(page).to have_text('Edit User')

Solution

  • Ended up blocking those requests altogether spec_helper.rb:

      config.before :each, js: true do
        page.driver.browser.url_blacklist = [
          "https://dialog.filepicker.io",
          "https://www.filepicker.io"
        ]
      end