Reputation: 663
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!
Upvotes: 1
Views: 835
Reputation: 6278
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
Upvotes: 1