Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-4302

"LocalJumpError: no block given (yield)” with Rails 5 when running let(){create}

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 12_01_17
    • Affects Version/s: 5.1.3
    • Component/s: None
    • None
    • Environment:
      Ubuntu 16.04. Rails 5.0.0

      Hello,

      I'm in the process of upgrading my app to Rails 5. When running the tests with rails 5 enabled I started to get "LocalJumpError: no block given (yield)" on several object creation sentences like this one:

      let(:entity)

      { create(:entity) }

      This started to happen after I upgraded to Rails 5.0.0
      However, it doesn't happen in all cases where I use 'let' like that (also happens with let! ) So I'm not entirely sure why it is happening.
      I also tried using build instead of create on that line and the error doesn't show up.

      Running rspec -b to see the trace, I identified the issue on this line:

      https://github.com/mongodb/mongoid/blob/master/lib/mongoid/clients/options.rb#L25

      The issue disappears if I replace that line (yield self) with just:

      self

      I'm not sure however if this is a feasible fix, and of course it would be better to include it in a new mongoid version instead, if it's a correct fix. Hence this ticket.

      Can you confirm if someone else has seen this issue when upgrading to Rails 5?

      I'll try to reproduce this in a test on a Pull Request but wanted to report this to get some early feedback if possible.

            Assignee:
            Unassigned Unassigned
            Reporter:
            marcocanderle Marco Canderle
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: