Forum: RSpec Rspec: How to mock class method

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3463579c8daa7b5679ef5e045bc4d168?d=identicon&s=25 bill gate (chucai)
on 2012-07-27 07:31
Hi, I have two model: Message, User

message.rb
```
class Message < ActiveRecord::Base
  class << self
    def method_a(args)
      [1,2]
    end
  end
end
```

user.rb
```
class User < ActiveRecord::Base
  def method_user
    if Message.method_a('anythings')
      #... some code
    end
  end
end
```
I want to test method_user,but I don't want to test Message#method_a
How I can mock Message with method_a?

Thanks!
This topic is locked and can not be replied to.