has_guid.rb 318 B

123456789101112
  1. require 'spec_helper'
  2. shared_examples_for HasGuid do
  3. it "gets created before_save, but only if it's not present" do
  4. instance = new_instance
  5. instance.guid.should be_nil
  6. instance.save!
  7. instance.guid.should_not be_nil
  8. lambda { instance.save! }.should_not change { instance.reload.guid }
  9. end
  10. end