RSpec with Rails(3.2) and Mongoid / Unexpected behaviour. -


i have rails(3.2) app working mongodb using mongoid.

i'm trying test record update it's updated_at field when make changes, simple like:

  "should modify updated_at when make changes record"       record = create(:record)       previous_updated_at = record.updated_at     record.touch         expect(record.updated_at).not_to eq(previous_updated_at)   end 

the test wont pass, unless add sleep(1). like:

  "should modify updated_at when make changes record"       record = create(:record)       previous_updated_at = record.updated_at     sleep(1)     record.touch         expect(record.updated_at).not_to eq(previous_updated_at)   end 

i'm sure there work around this. please note can check out spec_helper.rb at: https://gist.github.com/eqbal/1a4d96a0e761eb0faf22.

thanks in advance

i had upgrade mongoid gem version "~> 3.0.1".

then had set database session options consistency: :strong, safe: true, neither of default ensure can read data wrote using mongoid.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -