开发者

Unable to create a mock object with mocha

I keep getting this error...

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

Here's my code (a code example I swiped):

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()

Any help would be greatly appreciated!


I've come across the same issue as well.

I found the answer was to have 'gem mocha, :require => false' in my Gemfile.

My question: NoMethodError: undefined method `mock' with Mocha and Rails 3

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜