I am kind of lost in a simple task in testing a Ruby app using RSpec:
class Script
# content does not matter
def initialize
end
def my_timezone_description(timeZoneId)
@timeZonesCache[timeZoneId]
end
end
Specs:
it 'gets the timezone description' do
Script.instance_variable_set(:@timeZonesCache, {123 => '+01:00'} )
expect(Script.new.my_timezone_description(123)).to eq '+01:00'
end
Script.instance_variable_get(:@timeZonesCache) gives me back the correct hash.
Can someone explain why this is not working and how I can get it to work?
instance_variable_setsets a variable on an instance. What instance are you calling it on? What instance are you reading the instance variable back from?