Created
March 28, 2012 21:45
-
-
Save mrdanadams/2230855 to your computer and use it in GitHub Desktop.
Revisions
-
mrdanadams created this gist
Mar 28, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ # do our update @controller.record_votes(winner._id.to_s, loser._id.to_s) # will this pass or fail? who knows!? Item.count(conditions:{ votes:1 }).should == 0 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ # do our update @controller.record_votes(winner._id.to_s, loser._id.to_s) # wait until we get what we want (within reason, of course) wait_until { Item.count(conditions:{ votes:1 }) > 0 } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ RSpec.configure do |config| # ... config.before(:each) do db = Mongoid::Config::master # ignore stuff like system.indexes db.collection_names.reject {|c| c =~ /^system/}.each {|c| db.drop_collection c} end # ... 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ def wait_until i = 0 while !(result = yield) and i < 3 do sleep 1 i += 1 end raise "timed out" if !result end