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

Error when describing multiple array method names like #[] and #[]? #46

Open
Papierkorb opened this issue Nov 2, 2016 · 1 comment
Open

Comments

@Papierkorb
Copy link

Papierkorb commented Nov 2, 2016

Hello,

Spec2 seems to mangle "#[]" and "#[]?" into the same module name Spec2___Root::Spec2__Array::Spec2___.

This results in the error already initialized constant Spec2___Root::Spec2__Array::Spec2___::SPEC2_FULL_CONTEXT

Platform Crystal 0.19.4 (2016-10-07) on Linux, Spec2 at eef5144

Code snippet

require "spec2"

Spec2.describe Array do
  describe "#[]?" do # Each on their own is fine
    it "returns nil" do
      expect(([ 3, 4 ])[2]?).to be_nil
    end
  end

  describe "#[]" do
    it "raises IndexError" do
      expect{ ([ 3, 4 ])[2] }.to raise_error IndexError
    end
  end
end

Note: This also happens with #[]=

Thanks

@Papierkorb Papierkorb changed the title Error when describing #[] and #[]? Error when describing array method names like #[]? Nov 2, 2016
@Papierkorb Papierkorb changed the title Error when describing array method names like #[]? Error when describing multiple array method names like #[] and #[]? Nov 2, 2016
@waterlink
Copy link
Owner

I guess, we ought to transform special symbols into some meaningful words. For example #[]= will become: __sharp____openbrace____closebrace____equals__. Are you up for making a pull request?

Also, it can be worked around in your code with specifying some sort of conceptual description in your describe after the name of the method:

describe "#[] - index accessing operator" do
  # ..
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants