Ruby on rails 3 Rspec测试是否更新了属性

Ruby on rails 3 Rspec测试是否更新了属性,ruby-on-rails-3,unit-testing,rspec,mongoid,Ruby On Rails 3,Unit Testing,Rspec,Mongoid,我的模型有一个方法,可以从远程资源更新模型中的多个属性。我想用Rspec来测试它,但找不到如何测试字段是否已创建或更新 一些伪代码来解释这个问题 def update_from_remote attributes = {} fields.each_key do |field_name| attributes[field_name] = scrape_from_remote field_name end update_attributes(attributes) end

我的模型有一个方法,可以从远程资源更新模型中的多个属性。我想用Rspec来测试它,但找不到如何测试字段是否已创建或更新

一些伪代码来解释这个问题

def update_from_remote
  attributes = {}
  fields.each_key do |field_name|
    attributes[field_name] = scrape_from_remote field_name
  end
  update_attributes(attributes)
end
实际上,这段代码要复杂得多,但这只会把我的问题弄得一团糟。
create\u from\u remote
非常类似,只是它不调用
update\u属性
,而是简单地设置属性,然后保存对象

我想测试一下这个。我想要的是一个测试字段是否更新或填充的规范:

it 'should fill or set all local attributes on a new profile' do
  #how to test if a list of fields were updated in the Database?
end
it 'should update all local attributes on an existing profile' do
  #how to test if a list of fields were created in the Database?
end

我正在使用mongoId,但这不会有太大的区别。

我应该在mongoId文档中深入挖掘。有一章可供使用:

it "should be updated"
  @something.field.should be_changed
end