Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-1018

(in tests) User.all.first -> NoMethodError: undefined method `merge' for "primary":String

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 12_01_17
    • Affects Version/s: 2.1.0
    • Component/s: None
    • None
    • Environment:
      mac osx

      Let's say I have a User model.

      In the app or console, I can do User.all.first or User.all.count but if I do the same thing when running rspec, I get this error:

      NoMethodError:
      undefined method `merge' for "primary":String

      This is my first reported bug here. Sorry if I didn't follow guidelines or anything properly.

      Here's the trace:
      Failure/Error: puts Transaction.all.first
      NoMethodError:
      undefined method `merge' for "primary":String

      1. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/mongo-2.1.0.rc0/lib/mongo/client.rb:188:in `read_preference'
      2. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/mongo-2.1.0.rc0/lib/mongo/collection.rb:93:in `read_preference'
      3. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/mongo-2.1.0.rc0/lib/mongo/collection/view/readable.rb:406:in `default_read'
      4. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/mongo-2.1.0.rc0/lib/mongo/collection/view/readable.rb:296:in `read'
      5. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/mongo-2.1.0.rc0/lib/mongo/collection/view/iterable.rb:38:in `each'
      6. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/bundler/gems/mongoid-00511658f12f/lib/mongoid/query_cache.rb:207:in `each'
      7. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/bundler/gems/mongoid-00511658f12f/lib/mongoid/contextual/mongo.rb:240:in `first'
      8. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/bundler/gems/mongoid-00511658f12f/lib/mongoid/contextual/mongo.rb:240:in `block in first'
      9. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/bundler/gems/mongoid-00511658f12f/lib/mongoid/contextual/mongo.rb:489:in `try_cache'
      10. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/bundler/gems/mongoid-00511658f12f/lib/mongoid/contextual/mongo.rb:239:in `first'
      11. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/bundler/gems/mongoid-00511658f12f/lib/mongoid/contextual.rb:20:in `first'
      12. ./spec/controllers/api/v1/transactions_controller.rb:24:in `block (3 levels) in <top (required)>'
      13. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example.rb:206:in `instance_exec'
      14. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example.rb:206:in `block in run'
      15. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example.rb:430:in `block in with_around_and_singleton_context_hooks'
      16. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example.rb:388:in `block in with_around_example_hooks'
      17. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/hooks.rb:478:in `block in run'
      18. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/hooks.rb:618:in `block in run_around_example_hooks_for'
      19. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example.rb:273:in `call'
      20. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example.rb:273:in `call'
      21. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-rails-3.3.3/lib/rspec/rails/example/controller_example_group.rb:190:in `block (2 levels) in <module:ControllerExampleGroup>'
      22. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example.rb:378:in `instance_exec'
      23. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example.rb:378:in `instance_exec'
      24. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/hooks.rb:389:in `execute_with'
      25. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/hooks.rb:620:in `block (2 levels) in run_around_example_hooks_for'
      26. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example.rb:273:in `call'
      27. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example.rb:273:in `call'
      28. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-rails-3.3.3/lib/rspec/rails/adapters.rb:127:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
      29. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example.rb:378:in `instance_exec'
      30. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example.rb:378:in `instance_exec'
      31. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/hooks.rb:389:in `execute_with'
      32. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/hooks.rb:620:in `block (2 levels) in run_around_example_hooks_for'
      33. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example.rb:273:in `call'
      34. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example.rb:273:in `call'
      35. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/hooks.rb:621:in `run_around_example_hooks_for'
      36. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/hooks.rb:478:in `run'
      37. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example.rb:388:in `with_around_example_hooks'
      38. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example.rb:430:in `with_around_and_singleton_context_hooks'
      39. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example.rb:203:in `run'
      40. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example_group.rb:559:in `block in run_examples'
      41. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example_group.rb:555:in `map'
      42. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example_group.rb:555:in `run_examples'
      43. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example_group.rb:521:in `run'
      44. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example_group.rb:522:in `block in run'
      45. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example_group.rb:522:in `map'
      46. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/example_group.rb:522:in `run'
      47. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:115:in `block (3 levels) in run_specs'
      48. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:115:in `map'
      49. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:115:in `block (2 levels) in run_specs'
      50. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1627:in `with_suite_hooks'
      51. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:114:in `block in run_specs'
      52. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/reporter.rb:77:in `report'
      53. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:113:in `run_specs'
      54. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:89:in `run'
      55. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:73:in `run'
      56. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:41:in `invoke'
      57. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/exe/rspec:4:in `<top (required)>'
      58. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/bin/rspec:23:in `load'
      59. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/bin/rspec:23:in `<main>'
      60. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `eval'
      61. /Users/dstldjeans/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `<main>'

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            dameyawn Damien Sutevski
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: