[rspec-users] Spec''ing a block

Morten Møller Riis
Mon, 05 Dec 2011 12:04:38 -0000

Hi folks

How would you spec something like this:

    as_user username do
      FileUtils.chmod_R 0755, "#{directory}/*"
    end

Where as_user fires off a new process (and set uid to username).

It seems that this won''t catch FileUtils.chmod_R:

FileUtils.should_receive(:chmod_R).with(0755,
"#{@domain.directory}/*")

I guess that is because it is passed in the block and fired off in a seperate
process (Process.fork).