1
私はユニットテストの外でmochaを使ってNet :: HTTPResponseオブジェクトをモックしようとしています。ここでは簡単な例です:ユニットテストの外でモカを使用するには?
#!/usr/bin/env ruby -w
require 'net/http'
require 'rubygems'
require 'mocha'
response = mock('Net::HTTPResponse')
response.stubs(:code => '500', :message => "Failed", :content_type => "text/plaint", :body => '')
私はこのエラーを取得する:
undefined method `mock' for main:Object (NoMethodError)