antonmi / espec

Elixir Behaviour Driven Development
Other
808 stars 62 forks source link

Erlang/OTP 21 Tuple Call support removed #272

Closed tomciopp closed 6 years ago

tomciopp commented 6 years ago

Version 21 of erlang has removed support for tuple calls which breaks compatibility with ESpec. Any thoughts on a migration strategy?

  Support for "tuple calls" have been removed from the
  run-time system. Tuple calls was an undocumented and
  unsupported feature which allowed the module argument
  for an apply operation to be a tuple: Var = dict:new(),
  Var:size(). This "feature" frequently caused confusion,
  especially when such call failed. The stacktrace would
  point out functions that don't exist in the source
  code.

  For legacy code that need to use parameterized modules
  or tuple calls for some other reason, there is a new
  compiler option called tuple_calls. When this option is
  given, the compiler will generate extra code that
  emulates the old behavior for calls where the module is
  a variable.
antonmi commented 6 years ago

Hi, @tomciopp ! It's bad news. I haven't had a chance to try OTP 21 yet, but it seems that we should deprecate "RSpec syntax":

expect(smth).to eq(smth)

And use this one:

expect smth1 |> to(eq smth2)

or this one:

smth1 |> should(eq smth2)

I will investigate soon. Did you have a chance to run ESpec with OTP 21?

tomciopp commented 6 years ago

I've attempted to run ESpec with OTP 21 but it immediately errors in the spec_helper file. It seems that the configuration itself requires tuple calls.

antonmi commented 6 years ago

Hi, guys! This PR removes the support of tuple calls. So, ESpec will work with OTP 21. Could you please fetch the latest master and test if everything ok? Thank you!

bblaszkow06 commented 6 years ago

Hi! I've tested the master and it seemed fine. To make it work I had to remove old syntax from mocks so this example should be removed from README:

context "with old syntax" do
    before do: allow(SomeModule).to accept(:func, fn(a, b) -> a + b end)
    it do: expect SomeModule.func(1, 2) |> to(eq 3)
end
antonmi commented 6 years ago

Thanks @bblaszkow06 ! Yeap, I'm going to make changes in README. And I will release 1.6 version soon.