stubbing out ActiveRecord models

I have an active record model which roughly looks like this:

require 'soap/rpc/driver'
class Job < ActiveRecord::Base
   def self.submit(item)
     ... do soap call ...
     ... create Job ...
     return job
   end

   def status(status_type)
     ... do soap call ..
     return soap_message
   end
end

I'm trying to stub it out under test/mock/tests/job.rb.

class EnvoyJob

   def self.submit(item)
     j = Job.create({:foo => item, :bar => 'constant value for testing'})
   end

   def availability(status_type)
     case status_type
     when 1
       item = {"Local Channel" => "1 mile", "LoopCost" => 918.24 }
       return item.to_yaml
     end
   end

end

This code doesn't work. What do I need to do to mock out an ActiveRecord model?

I have an active record model which roughly looks like this:

require ‘soap/rpc/driver’
class Job < ActiveRecord::Base
def self.submit(item)
… do soap call …
… create Job …

 return job

end

def status(status_type)
… do soap call …
return soap_message
end
end

I’m trying to stub it out under test/mock/tests/job.rb.

class EnvoyJob

def self.submit(item)
j = Job.create({:foo => item, :bar => ‘constant value for
testing’})
end

def availability(status_type)
case status_type
when 1
item = {“Local Channel” => “1 mile”, “LoopCost” => 918.24 }
return item.to_yaml
end
end

end

This code doesn’t work. What do I need to do to mock out an
ActiveRecord model?


James.
http://blog.floehopper.org