[rspec-users] Rspec: How to mock class method
srshti at gmail.com
Fri Jul 27 06:42:56 UTC 2012
On 27-Jul-2012, at 11:34 AM, Bas Vodde wrote:
> How about:
I think that ought to be:
> On 27-Jul-2012, at 1:31 PM, bill gate wrote:
>> Hi, I have two model: Message, User
>> class Message < ActiveRecord::Base
>> class << self
>> def method_a(args)
>> class User < ActiveRecord::Base
>> def method_user
>> if Message.method_a('anythings')
>> #... some code
>> I want to test method_user,but I don't want to test Message#method_a
>> How I can mock Message with method_a?
>> Posted via http://www.ruby-forum.com/.
>> rspec-users mailing list
>> rspec-users at rubyforge.org
> rspec-users mailing list
> rspec-users at rubyforge.org
I think the thing people don't usually realise is classes in Ruby are also objects in their own right. So, whatever you can do to any other object, you can do to a class.
More information about the rspec-users