1

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!

Vega
  • 27,856
  • 27
  • 95
  • 103
user479808
  • 643
  • 1
  • 5
  • 6

1 Answers1

1

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

Community
  • 1
  • 1
John Gallagher
  • 6,208
  • 6
  • 40
  • 75