Search code examples
ruby-on-railsruby-on-rails-4rspecrspec-railscapybara-webkit

RSpec: Troubleshooting failing test that works for some devs and not others


Hoping someone can walk me through troubleshooting a failing spec that is passing in CI and on my desktop machine but failing on my laptop (MacBook).

This is the failure:

$ rspec spec/features/media_files_spec.rb

Randomized with seed 39713
WARNING: The next major version of capybara-webkit will require at least version 5.0 of Qt. You're using version 4.8.7.
....F

Failures:

  1) MediaFiles upload additional file to section
     Failure/Error: expect(page).to have_css(".photoset .photo", count: 2)
       expected to find css ".photoset .photo" 2 times, found 1 match: ""
     # ./spec/features/media_files_spec.rb:43: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)>'

Finished in 12 seconds (files took 3.03 seconds to load)
5 examples, 1 failure

Failed examples:

rspec ./spec/features/media_files_spec.rb:24 # MediaFiles upload additional file to section

I'm going to be traveling next week so want to get this laptop stabilized but not sure why this is failing locally while passing elsewhere? Not sure where to begin. Thoughts?


Solution

  • Posting my own answer because maybe this can help others.

    Turns out this was an issue with my .env on the failing machine. Some ENV variables were not in sync.

    Tough nuts!