У меня есть набор тестов Rspec, который работал отлично, пока я не установил Redis в свое веб-приложение.
Это две строки кода из файла config / initializer / redis.rb
uri = URI.parse(ENV['REDISTOGO_URL'])
$redis = Redis::Namespace.new("EW", :redis => Redis.new(url: uri))
Когда я комментирую вышесказанное, rspec работает нормально (я еще даже не начал тестировать redis, потому что не могу).
Ниже приведена ошибка, которую дает мне rspec.
An error occurred while loading ./spec/models/waitlist_spec.rb.
Failure/Error: require File.expand_path('../../config/environment', __FILE__)
URI::InvalidURIError:
bad URI(is not URI?):
# ./config/initializers/redis.rb:1:in `<top (required)>'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:286:in `load'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:286:in `block in load'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:258:in `load_dependency'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:286:in `load'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/railties-5.1.0/lib/rails/engine.rb:655:in `block in load_config_initializer'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/activesupport-5.1.0/lib/active_support/notifications.rb:168:in `instrument'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/railties-5.1.0/lib/rails/engine.rb:654:in `load_config_initializer'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/railties-5.1.0/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/railties-5.1.0/lib/rails/engine.rb:611:in `each'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/railties-5.1.0/lib/rails/engine.rb:611:in `block in <class:Engine>'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/railties-5.1.0/lib/rails/initializable.rb:30:in `instance_exec'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/railties-5.1.0/lib/rails/initializable.rb:30:in `run'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/railties-5.1.0/lib/rails/initializable.rb:59:in `block in run_initializers'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/railties-5.1.0/lib/rails/initializable.rb:48:in `each'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/railties-5.1.0/lib/rails/initializable.rb:48:in `tsort_each_child'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/railties-5.1.0/lib/rails/initializable.rb:58:in `run_initializers'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/railties-5.1.0/lib/rails/application.rb:353:in `initialize!'
# ./config/environment.rb:5:in `<top (required)>'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in `require'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in `block in require'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:258:in `load_dependency'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in `require'
# ./spec/rails_helper.rb:3:in `<top (required)>'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in `require'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in `block in require'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:258:in `load_dependency'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in `require'
# ./spec/models/waitlist_spec.rb:1:in `<top (required)>'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:286:in `load'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:286:in `block in load'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:258:in `load_dependency'
# /Users/ptenteromano/.rvm/gems/ruby-2.2.5@new_wardrobe/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:286:in `load'
# ------------------
# --- Caused by: ---
# NoMethodError:
# undefined method `to_str' for nil:NilClass
# ./config/initializers/redis.rb:1:in `<top (required)>'
No examples found.
Randomized with seed 3749
Finished in 0.00061 seconds (files took 9.32 seconds to load)
0 examples, 0 failures, 18 errors occurred outside of examples
Я довольно плохо знаком со сложными веб-приложениями и никогда раньше не использовал Redis, поэтому я немного растерялся.
Ценю любую помощь.