Last active
December 19, 2015 09:59
-
-
Save cheald/5936864 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [1] pry(#<MongoMapper::Plugins::Keys::Key>)> show-source @default | |
| From: /var/www/repos/mongomapper/spec/unit/keys_spec.rb | |
| Number of lines: 1 | |
| generator = lambda { raise Exception } | |
| [3] pry(#<MongoMapper::Plugins::Keys::Key>)> @default.call | |
| => nil | |
| [4] pry(#<MongoMapper::Plugins::Keys::Key>)> lambda { raise Exception }.call | |
| Exception: Exception | |
| from (pry):3:in `block in default_value' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| context "when loading from the database" do | |
| it "should not set default values for keys that already exist" do | |
| generator = lambda { raise Exception } | |
| klass = Doc do | |
| key :value, Integer, :default => generator | |
| end | |
| generator.should_receive(:call).exactly(2).times | |
| puts "Starting" | |
| instance = klass.create | |
| puts "Finding" | |
| instance.reload.value.should == 3 | |
| instance.value = 4 | |
| instance.save | |
| instance.reload.value.should == 4 | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment