How to configure RSpec to load monkey patched classes

Viewed 420

I have extended the string class as follows:

class String
  def last_character
    self[-1]
  end
end

I have places the string.rb file in the lib as follows:

lib/core_extensions/string.rb

I have tested the setup and I can use the last_character method in a Rails console.

However, when I run an RSpec test for a class that uses the extended String class it gives me an error:

undefined method `last_character' for " ":String

Do I have to tell RSpec to load these class extension files somehow?

2 Answers
Related