I was using RSpec/Guard without Spring before the upgrade from Rails 4.0 to 4.1 and all my tests were passing without any output other than green dots and green text. After upgrading and installing Spring along with whatever else I supposedly needed, I'm getting errors in my passing tests, and sometimes my tests don't pass due to 'uniqueness' errors.
Common error between passing and failing tests:
An error occurred in an after(:all) hook. NameError: uninitialized constant Recipe occurred at /home/user/.rvm/gems/[email protected]/gems/activesupport-4.1.0/lib/active_support/inflector/methods.rb:238:in 'const_get'
Now the after(:all) hook simply deletes all Manager::Wine objects (and a Manager::Wine object has_many recipes). Manager is a rails engine, and it has Wine and Recipe models. Nowhere in the Wine class does it specify the Recipe constant explicitly. But as I said before, this error didn't show up in regular RSpec/Guard tests until I upgraded and installed Spring.
The other failures are a result of 'attributes already been taken'. For example, a standard 'is valid factory' tests fail upon create() because of this. But I specified in RSpec:
config.before(:each) do DatabaseCleaner.start end
and I wasn't getting these errors in my randomized tests before Spring.
group :development, :test do gem 'spring' gem 'rspec-rails' gem 'guard' gem 'guard-rspec', require: false gem 'spring-commands-rspec' gem 'factory_girl_rails' gem 'database_cleaner' end
guard :rspec, cmd:"spring rspec" do
Rails app_root/bin contains files:
rails rake rspec spring