Spring not using bundle (or shoulda-matchers problem)

Thoughtboters and Learners,

I’ve been having some weird issues with spring that came to light after I upgraded to the most recent version of shoulda-matchers (from 2.5 to 2.6). Here’s my setup:

I’m using rbenv, Ruby 2.1.1, Rails 4.0.0, and the first folder in my path is ./bin (using the .git/safe trick so it’s not unsecured). I have binstubs generated by spring that look like this (here’s RSpec as an example:

begin load File.expand_path("../spring", __FILE__) rescue LoadError end require 'bundler/setup' load Gem.bin_path('rspec', 'rspec')

When I type which rspec, I get the path to the binstub, so I’m fairly sure it’s being executed. When I type rspec or the alias s or spring rspec or bin/rspec, I get a massive slew of failures similar to this:

Failure/Error: it { should validate_presence_of(:name) } NoMethodError: undefined method `validate_presence_of' for #<RSpec::Core::ExampleGroup::Nested_69:0x007fbc78f187e0>

All of these failures look like shoulda-matchers for straightforward things like associations and validations are missing. When I run bundle exec rspec, everything passes, but it’s clearly much slower, because I don’t think you’re using spring when you’re loading the application environment with bundle exec. Has anyone else had similar issues? I had a lot of success with Spring before this bump in the road, and really want to be able to keep running my tests quickly!

Could this solve your problem:


1 Like

@dolphorama, that is EXACTLY what I missed when I looked through the issues. Thank you!