Fix deprecation warning and rspec failure