Skip to content
Browse files

dup values so that in-place edits to model values do not update the s…

…tub values
  • Loading branch information...
1 parent 847b4ec commit 7a383da076dac238c718a95a32788643651c6bab @technoweenie committed Jul 6, 2008
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/model_stubbing/stub.rb
View
6 lib/model_stubbing/stub.rb
@@ -137,7 +137,11 @@ def instantiate(this_record_key, attributes)
record.send("#{key}=", records)
record.new_record = nr
else
- record.send("#{key}=", value)
+ duped_value = case value
+ when TrueClass, FalseClass, Fixnum, Float, NilClass, Symbol then value
+ else value.dup
+ end
+ record.send("#{key}=", duped_value)
end
end
record

0 comments on commit 7a383da

Please sign in to comment.
Something went wrong with that request. Please try again.