Skip to content

Add spec for NameError#receiver - #178

Merged
eregon merged 2 commits into
ruby:masterfrom
yuki24:add-spec-for-name-error-receiver
Dec 27, 2015
Merged

Add spec for NameError#receiver#178
eregon merged 2 commits into
ruby:masterfrom
yuki24:add-spec-for-name-error-receiver

Conversation

@yuki24

@yuki24 yuki24 commented Dec 23, 2015

Copy link
Copy Markdown
Member

No description provided.

@yuki24 yuki24 changed the title Add spec for name error receiver Add spec for name_error#receiver Dec 23, 2015
@yuki24 yuki24 changed the title Add spec for name_error#receiver Add spec for NameError#receiver Dec 23, 2015
Comment thread core/exception/receiver_spec.rb Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this spec be written using an anonymous class (Class.new)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this particular case, a class variable call needs to be made in a subclass' namespace. Anonymous classes don't create namespace, therefore a constant needs to explicitly be defined. It doesn't have to be defined in this file and could be moved to the fixtures dir, though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thanks for the explanation. @@cvar are like constants, I tend to forget 😄
Could you move it to the fixtures? This would also mean the cleanup code (remove_const) is not necessary.

@eregon

eregon commented Dec 24, 2015

Copy link
Copy Markdown
Member

Nice one as well!
Please review my comments.

@yuki24

yuki24 commented Dec 25, 2015

Copy link
Copy Markdown
Member Author

updated the commits. I've also changed the operator to equal since NameError#receiver should return the object that the method is called on.

@eregon

eregon commented Dec 25, 2015

Copy link
Copy Markdown
Member

Thanks, please move the named class to a fixture file and let's merge this!

eregon added a commit that referenced this pull request Dec 27, 2015
@eregon
eregon merged commit d799042 into ruby:master Dec 27, 2015
eregon added a commit that referenced this pull request Dec 27, 2015
@eregon

eregon commented Dec 27, 2015

Copy link
Copy Markdown
Member

I moved the class to the fixtures file, thank you for your contribution and the good specs!

@eregon eregon mentioned this pull request Dec 27, 2015
51 tasks
@yuki24

yuki24 commented Dec 27, 2015

Copy link
Copy Markdown
Member Author

@eregon Thanks for taking care of the class!

@yuki24
yuki24 deleted the add-spec-for-name-error-receiver branch December 27, 2015 13:52
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

Successfully merging this pull request may close these issues.

3 participants