{"action":"created","issue":{"url":"https://api.github.com/repos/rspec/rspec-mocks/issues/964","labels_url":"https://api.github.com/repos/rspec/rspec-mocks/issues/964/labels{/name}","comments_url":"https://api.github.com/repos/rspec/rspec-mocks/issues/964/comments","events_url":"https://api.github.com/repos/rspec/rspec-mocks/issues/964/events","html_url":"https://github.com/rspec/rspec-mocks/issues/964","id":85101442,"number":964,"title":"expect and_call_original messing up with modules build as jruby extensions.","user":{"login":"purbon","id":68540,"avatar_url":"https://avatars.githubusercontent.com/u/68540?v=3","gravatar_id":"","url":"https://api.github.com/users/purbon","html_url":"https://github.com/purbon","followers_url":"https://api.github.com/users/purbon/followers","following_url":"https://api.github.com/users/purbon/following{/other_user}","gists_url":"https://api.github.com/users/purbon/gists{/gist_id}","starred_url":"https://api.github.com/users/purbon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/purbon/subscriptions","organizations_url":"https://api.github.com/users/purbon/orgs","repos_url":"https://api.github.com/users/purbon/repos","events_url":"https://api.github.com/users/purbon/events{/privacy}","received_events_url":"https://api.github.com/users/purbon/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":29,"created_at":"2015-06-04T13:33:28Z","updated_at":"2015-11-21T00:49:36Z","closed_at":"2015-11-21T00:49:36Z","body":"While doing some test to upgrade https://github.com/elastic/logstash to use the last rspec set of gems, I found out an issue with the way expectation with the and_call_orignal call work in the 3.x branch. \r\n\r\n*Situation*\r\n\r\nIn logstash we're using the jruby wrapper of jrjackson [1] as a json lib, so we get a really fast json processing. So to build the test we use calls like:\r\n\r\n```\r\n expect(JrJackson::Raw).to receive(:parse_raw).with(json_hash).and_call_original\r\n expect(LogStash::Json.load(json_hash)).to eql(hash)\r\n```\r\nduring the upgrade to use rspec 3.x I discovered that this kind of expectation were not playing well anymore, as they did with versions < 2.99. There seems to be a regression with using the ```and_call_original``` in modules defined as jruby/java exceptions.\r\n\r\nTo make a bit more easy to reproduce this I made a simple example that you can find at https://github.com/purbon/playground/tree/master/call_origin_with_module, running the test in this dummy gem will:\r\n\r\n* If using the last rspec 3.2.x:\r\n\r\n```\r\nCallOriginWithModule\r\n  calls the generate once\r\n  calls the generate twice (FAILED - 1)\r\n  calls the dump once (FAILED - 2)\r\n  calls the dump twice (FAILED - 3)\r\n  without using call original\r\n    calls the generate once\r\n    calls the generate twice\r\n\r\nFailures:\r\n\r\n  1) CallOriginWithModule calls the generate twice\r\n     Failure/Error: expect(AClass.bar(3)).to eq(\"{\\\"source\\\":3,\\\"target\\\":3}\")\r\n     NoMethodError:\r\n       undefined method `generate' for JrJackson::Raw:Module\r\n     # ./lib/call_origin_with_module.rb:8:in `bar'\r\n     # ./spec/call_origin_with_module_spec.rb:12:in `(root)'\r\n```\r\n\r\nif using a version <= 2.99:\r\n\r\n```\r\n╰─$ bundle exec rspec\r\n\r\nCallOriginWithModule\r\n  calls the generate once\r\n  calls the generate twice\r\n  calls the dump once\r\n  calls the dump twice\r\n  without using call original\r\n    calls the generate once\r\n    calls the generate twice\r\n\r\nFinished in 0.322 seconds\r\n6 examples, 0 failures\r\n```\r\n\r\n[1] https://github.com/guyboertje/jrjackson"},"comment":{"url":"https://api.github.com/repos/rspec/rspec-mocks/issues/comments/158568352","html_url":"https://github.com/rspec/rspec-mocks/issues/964#issuecomment-158568352","issue_url":"https://api.github.com/repos/rspec/rspec-mocks/issues/964","id":158568352,"user":{"login":"samphippen","id":96662,"avatar_url":"https://avatars.githubusercontent.com/u/96662?v=3","gravatar_id":"","url":"https://api.github.com/users/samphippen","html_url":"https://github.com/samphippen","followers_url":"https://api.github.com/users/samphippen/followers","following_url":"https://api.github.com/users/samphippen/following{/other_user}","gists_url":"https://api.github.com/users/samphippen/gists{/gist_id}","starred_url":"https://api.github.com/users/samphippen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samphippen/subscriptions","organizations_url":"https://api.github.com/users/samphippen/orgs","repos_url":"https://api.github.com/users/samphippen/repos","events_url":"https://api.github.com/users/samphippen/events{/privacy}","received_events_url":"https://api.github.com/users/samphippen/received_events","type":"User","site_admin":false},"created_at":"2015-11-21T00:49:36Z","updated_at":"2015-11-21T00:49:36Z","body":"This was fixed by https://github.com/jruby/jruby/issues/3463"}}