2011-09-08 88 views
1

我不斷收到此錯誤模擬對象...無法創建與摩卡

mockresponse.rb:4:in `createResponseObject': undefined method `mock' for main:Object (NoMethodError) 

這裏是我的代碼(代碼示例我刷):

require 'mocha' 

def createResponseObject 
@http_mock = mock('Net::HTTPResponse') 
@http_mock .stubs(:code => '200', :message => "OK", :content_type => "text/html", :body => '<title>Test</title><body>Body of the page</body>') 
end 

createResponseObject() 

任何幫助將不勝感激!

回答