Make tests run with Rails 4 and update RSpec

Remove `config.threadsafe!` which is deprecated in Rails 4
Update `rspec-rails` gem and replace stub with double to remove deprecation warnings.