Im trying to pass a test for pushing an item into an array from another class. Here is the method.
require_relative 'message'
class Test
attr_reader :message
def initialize(message = Message.new)
@message = message
end
def push(hello)
@message.array << hello
end
end
The empty array in a different class.
class Message
attr_reader :array
def initialize
@array = []
end
end
and my test.
require 'test'
describe Test do
let(:message) { double(array: [])}
describe '#push' do
it 'pushes an item into an array from the message class' do
subject.push("hello")
expect(message.array).to eq ["hello"]
end
end
end
currenty getting the error
expected: ["hello"]
got: []
(compared using ==)
what am i doing wrong? The method itself is simple and works, why does my test not?