Sorbet: runtime: RSpec's expect_any_instance_of.and_call_original causes sig consistency check failure

Created on 16 Mar 2019  路  4Comments  路  Source: sorbet/sorbet

Running the following spec with rspec --order defined causes a RuntimeError:

`sig` not present for method `bar` but you're trying to run it anyways. This should only be executed if you used `alias_method` to grab a handle to a method after `sig`ing it, but that clearly isn't what you are doing. Maybe look to see if an exception was thrown in your `sig` lambda or somehow else your `sig` wasn't actually applied to the method. Contact #dev-productivity if you're really stuck.
describe 'sig consistency error' do
  class Foo
    sig { returns(String) }
    def bar
      'hello'
    end
  end

  it 'does not error' do
    expect_any_instance_of(Foo).to receive(:bar).and_call_original
    Foo.new.bar
  end

  it 'should not error' do
    Foo.new.bar
  end
end

Something in RSpec's method mocking seems to be messing with sigs method monkey-patching functionality.

runtime

Most helpful comment

Heads-up, we're currently concentrated on productizing srb init and thus we're unlikely to get to this soon.
Is this blocking your adoption? If so, would you be able to investigate a fix for this?

All 4 comments

Heads-up, we're currently concentrated on productizing srb init and thus we're unlikely to get to this soon.
Is this blocking your adoption? If so, would you be able to investigate a fix for this?

No problem. Yes it's blocking adoption; folks are commenting sig from methods to fix order-flaky specs. We can investigate a fix.

Thank you. For context: Stripe does not use RSpec and thus we don't have much experience typing RSpec tests.

@mdehoog https://github.com/sorbet/sorbet/pull/581 This has been merged.

Does this change the situation for you?

Was this page helpful?
0 / 5 - 0 ratings