Say I have a clarification
module RefinedString
refine String do
def remove_latin_letters
end
end
end
and I use it inside my class. Speech:
class Speech
using RefinedString
def initialize(text)
@content = text.remove_latin_letters
end
end
I wrote tests for refinement in RSpec, and now I'm testing Speech class
describe Speech
let(:text) { "ąńńóyińg" }
it 'should call my refinement' do
expect(text).to receive(:remove_latin_letters)
Speech.new(text)
end
end
but i get RSpec::Mocks::MockExpectationError: "ąńńóyińg" does not implement: remove_latin_letter
I don’t think this is taunting, this is a good solution (but I can be wrong! Is the solution taunting here?)
so i tried
let(:text) { described_class::String.new("ąńńóyińg") }
but the result is the same.
I don’t want to explicitly call using RefinedStringinside my RSpec (it should understand this on its own, right?)
How to make RSpec aware of my exquisite techniques?
source
share