[rspec-users] Spec''ing a block

Morten Møller Riis
Mon, 05 Dec 2011 13:21:43 -0000

For the moment I have done this:

def Process.fork(&block)
  block.call
end

So that Process.fork doesn''t actually spawn a new process but just runs
it in the current one.

But any better suggestions are welcome :)


Mvh
Morten M?ller Riis



On Dec 5, 2011, at 1:04 PM, Morten M?ller Riis wrote:

> 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).
>
>
> Mvh
> Morten M?ller Riis
>
>
>