Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in Spec::BeAExpectation(T) #5729

Closed
Sija opened this issue Feb 18, 2018 · 6 comments
Closed

Regression in Spec::BeAExpectation(T) #5729

Sija opened this issue Feb 18, 2018 · 6 comments
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:specs

Comments

@Sija
Copy link
Contributor

Sija commented Feb 18, 2018

Merging #5646 caused a regression:

require "spec"

describe "Spec::BeAExpectation(T)" do
  it { Int32.should be_a Int32.class }
end

v0.24.1 (carc.in):

.

Finished in 83 microseconds
1 examples, 0 failures, 0 errors, 0 pending

master:

Error in line 1: instantiating 'be_a(Class)'

in /.../crystal/src/spec/expectations.cr:271: can't use Object as generic type argument yet, use a more specific type

      Spec::BeAExpectation(T).new
@luislavena
Copy link
Contributor

I always assumed be_a refers to instances of instead of kind of classes.

If not mistaken, RSpec does the same distinction between be_kind_of and be_instance_of:

Perhaps the same approach needs to be made here in order to properly differentiate kind from instances.

Cheers.

@Sija
Copy link
Contributor Author

Sija commented Mar 12, 2018

IIRC that's what be should do, be_a is/was meant to check for given type, see previous definition:

macro be_a(type)
Spec::BeAExpectation({{type}}).new
end

Now, it reads:

def be_a(type : T.class) forall T
Spec::BeAExpectation(T).new
end

type argument is still there, yet in actual version it seems to work differently.

@luislavena
Copy link
Contributor

@asterite any comment on this?

@Sija
Copy link
Contributor Author

Sija commented Apr 17, 2018

@asterite ping!

@sdogruyol sdogruyol added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:specs labels Apr 17, 2018
@asterite
Copy link
Member

My commit should be reverted

@RX14
Copy link
Contributor

RX14 commented Apr 17, 2018

(just the be_a bit)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:specs
Projects
None yet
Development

No branches or pull requests

5 participants