Mock Kernel method

I use rspec on rails. I want to test model.

My model has this method:

class My
def self.blabla(url)
open(url) {|f|
#processing
}
end
end

open is Kernel method. How do I mock it? Kernel.expects and
Kernel.should_receive and Kernel.stub! do no good.

To make it more clear, I am looking for something like this:
it “should processing rails.com” do
Kernel.expects(:open).with(‘rails.com’).returns(‘blue’)
My.blabla(‘rails.com’).should == ‘result of self.blabla’
end

On 13/12/2007, rinda [email protected] wrote:

end

open is Kernel method. How do I mock it? Kernel.expects and
Kernel.should_receive and Kernel.stub! do no good.

To make it more clear, I am looking for something like this:
it “should processing rails.com” do
Kernel.expects(:open).with(‘rails.com’).returns(‘blue’)
My.blabla(‘rails.com’).should == ‘result of self.blabla’
end

I don’t know if it’s the same, but with Mocha you can do…

My.expects(:open).with(‘rails.com’).returns(‘blue’)

I hope that helps.


James.

On 14 Des, 00:48, “James M.” [email protected] wrote:

I don’t know if it’s the same, but with Mocha you can do…

My.expects(:open).with(‘rails.com’).returns(‘blue’)

I hope that helps.


James.http://blog.floehopper.orghttp://tumble.floehopper.org

Yes, I have tried that in simple unit testing file. It works, but I
can not figure out integrate that with rspec on rails even using mocha.

On 14 Des, 03:30, “James M.” [email protected] wrote:

On 13/12/2007, rinda [email protected] wrote:

Yes, I have tried that in simple unit testing file. It works, but I
can not figure out integrate that with rspec on rails even using mocha.

Strange. Have you tried the rspec mailing list [1]?

Not yet. Maybe I should.

On 13/12/2007, rinda [email protected] wrote:

Yes, I have tried that in simple unit testing file. It works, but I
can not figure out integrate that with rspec on rails even using mocha.

Strange. Have you tried the rspec mailing list [1]?


James.

[1] http://rubyforge.org/mail/?group_id=797