Mocking question

Hi,

I am working on creating something that will monitor some files and do
something when they are changed. I am using FSSM for the actual
monitoring. Now I want to verify that it gets initialized with the
correct parameters:

@monitor.path path do
glob = filter
end

So below is my mock setup:

def setup_monitor_mock
mock_monitor = mock(‘monitor’)
#mock_monitor.should_receive(:path).with(".")

FSSM::Monitor.stub!(:new).and_return(mock_monitor)

mock_monitor
end

But the problem is that I don’t know how to verify the values for path
and filter that are used to setup the monitor are correct. I saw some
older posts about the same topic, but I couldn’t find something
definitive.

I hope I explained myself correctly.

-Mark

On Thu, Apr 15, 2010 at 6:39 PM, Mark Nijhof
[email protected] wrote:

But the problem is that I don’t know how to verify the values for path
and filter that are used to setup the monitor are correct. I saw some
older posts about the same topic, but I couldn’t find something
definitive.

I hope I explained myself correctly.

I wouldn’t use a mock for this. Take a look at FSSM’s own specs:
fssm/spec/path_spec.rb at master · ttilley/fssm · GitHub. They
just query the monitor object to make sure it’s configured correctly.
I’d do something like that in this case.

HTH,
David