我有这样的RSpec代码:
describe 'self.run' do
context 'if the related object is a subclass' do
it 'ensures proper \'Suggested property - Class\' relationships' do
allow(described_class).to receive(:inherit_suggested_properties)
expect(described_class).to receive(:inherit_suggested_properties).once.with(
CoreObject.find('class-class'),
CoreObject.find('class-instance-class')
)
described_class.run(
observed_object: CoreObject.find('class-class'),
this_change_observer: CoreObject.find('observer'),
related_object: CoreObject.find('class-instance-class'),
relationship: CoreObject.find('class-class--class-instance-class')
)
end
it 'ensures proper \'Change observer - Object\' relationship' do
allow(described_class).to receive(:inherit_change_observer)
expect(described_class).to receive(:inherit_change_observer).once.with(
CoreObject.find('observer'),
CoreObject.find('class-instance-class')
)
described_class.run(
observed_object: CoreObject.find('class-class'),
this_change_observer: CoreObject.find('observer'),
related_object: CoreObject.find('class-instance-class'),
relationship: CoreObject.find('class-class--class-instance-class')
)
end
end
# ...
end
通常它可以工作,但是我注意到这些情况大约需要13秒钟才能运行。奇怪的是,当我只运行其中一个时,它也需要大约13秒钟,因此看起来好像是在准备过程中花费的时间。这里发生了什么?我可以以某种方式对其进行优化吗?