PageRenderTime 56ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/spec/configuration/database/mongodb_spec.rb

http://github.com/meskyanichi/backup
Ruby | 56 lines | 50 code | 5 blank | 1 comment | 22 complexity | 5bfc633b03e5be60800009f54e3c6145 MD5 | raw file
  1. # encoding: utf-8
  2. require File.expand_path('../../../spec_helper.rb', __FILE__)
  3. describe Backup::Configuration::Database::MongoDB do
  4. before do
  5. Backup::Configuration::Database::MongoDB.defaults do |db|
  6. db.name = 'mydb'
  7. db.username = 'myuser'
  8. db.password = 'mypassword'
  9. db.host = 'myhost'
  10. db.port = 'myport'
  11. db.only_collections = %w[my other tables]
  12. db.additional_options = %w[my options]
  13. db.ipv6 = true
  14. db.mongodump_utility = '/path/to/mongodump'
  15. db.mongo_utility = '/path/to/mongo'
  16. db.lock = true
  17. end
  18. end
  19. after { Backup::Configuration::Database::MongoDB.clear_defaults! }
  20. it 'should set the default MongoDB configuration' do
  21. db = Backup::Configuration::Database::MongoDB
  22. db.name.should == 'mydb'
  23. db.username.should == 'myuser'
  24. db.password.should == 'mypassword'
  25. db.host.should == 'myhost'
  26. db.port.should == 'myport'
  27. db.only_collections.should == %w[my other tables]
  28. db.additional_options.should == %w[my options]
  29. db.ipv6.should == true
  30. db.mongodump_utility.should == '/path/to/mongodump'
  31. db.mongo_utility.should == '/path/to/mongo'
  32. db.lock.should == true
  33. end
  34. describe '#clear_defaults!' do
  35. it 'should clear all the defaults, resetting them to nil' do
  36. Backup::Configuration::Database::MongoDB.clear_defaults!
  37. db = Backup::Configuration::Database::MongoDB
  38. db.name.should == nil
  39. db.username.should == nil
  40. db.password.should == nil
  41. db.host.should == nil
  42. db.port.should == nil
  43. db.only_collections.should == nil
  44. db.additional_options.should == nil
  45. db.ipv6.should == nil
  46. db.mongodump_utility.should == nil
  47. db.mongo_utility.should == nil
  48. db.lock.should == nil
  49. end
  50. end
  51. end