I extended the string class as follows:
class String def last_character self[-1] end end
I have a string.rb file in lib as follows:
lib/core_extensions/string.rb
I tested the installation and I can use the last_character method in the Rails console.
However, when I run the RSpec test for a class that uses the extended String class, it gives me an error:
undefined method `last_character' for " ":String
Should I tell RSpec to load these class extensions somehow?
ruby-on-rails-5 rspec
chell
source share