Search code examples
ruby-on-railsrspecrspec-rails

Rspec suddenly only running one test


Trying to run rspec (bin/rspec) from my project root, and suddenly it is not running the full test suite - this is usually over 1,000 examples.

Finished in 1.88 seconds (files took 5.17 seconds to load)
1 example, 0 failures

I can run individual files or sub-directories (e.g. spec/system/*), and it works fine in other projects run as normal.

The only thing I can think of is that I did enter the test console (bin/rails c test) recently where I made a user, then went onto the test server in localhost, afterwards destroying the user when I realised it wasn't what I needed. I've also reset the test database and cleared my tmp cache just in case.

Any ideas on how to troubleshoot the cause would be appreciated!


Solution

  • Problem now fixed - solution:

    I tried running each folder, and I did notice a difference in the focus: true:

    bin/rspec spec/controllers:

    Run options: include {:focus=>true}
    All examples were filtered out; ignoring {:focus=>true}
    

    bin/rspec:

    Run options: include {:focus=>true}
    

    Commented out the lines in spec_helper to check, and it ran everything correctly then:

      # config.filter_run_including focus: true
      # config.run_all_when_everything_filtered = true
    

    Searching for focus showed nothing in specs, so I added something to print the metadata in my spec_helper

    config.before do |x|
      p x.metadata
    end 
    

    and found the one example it was focusing on, and lo and behold the example it happened to have accidentally been pre-pended with 'fit' instead of 'it' from a prior pulled commit which was causing the focus. Thanks for the help :-)