Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
问题在标题中。例如,我有一个类:
class A def self.something p 'Something' end def call_something self.class.something end end
我想写一个测试,一个instance aonclass A方法调用:a.call_something实际上会调用A.something. 这可能吗?
instance a
class A
a.call_something
A.something
试试看怎么样?我想这行得通
describe '#call_something' do it 'calls something in classA' do a = ClassA.new ClassA.should_receive(:something) a.call_something end end