Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Extract warning methods into module #40

Merged
merged 2 commits into from
Feb 20, 2014

Conversation

bestie
Copy link
Contributor

@bestie bestie commented Feb 12, 2014

Pairing with @samphippen

Refactoring warnings for PR on RSpec core rspec/rspec-core#1253

@fables-tales
Copy link
Member

I should probably say we have a patch for core that's cooking shortly.

@@ -1,42 +1,38 @@
module RSpec
module Support
module Warnings
extend self
Copy link
Member

Choose a reason for hiding this comment

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

Why extend self? As far as I can see, you're not using any of these methods via RSpec::Support::Warnings.<method_name> and I don't think we want to expand the API like that, anyway.

@myronmarston
Copy link
Member

This LGTM to me besides the extend self line.

@JonRowe
Copy link
Member

JonRowe commented Feb 12, 2014

What's the motivation for this? We took the explicit step of moving these out of a module when we moved them across, as we felt it wasn't necessary given that all we're going to do is then extend it straight back into the original module.

@fables-tales
Copy link
Member

@JonRowe see rspec/rspec-core#1253


unless respond_to?(:deprecate)
Copy link
Member

Choose a reason for hiding this comment

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

I'm assuming this has something to do with the core PR @samphippen mentioned, but currently this can't be merged with this removal, as core has different implementations of these methods and this check is to prevent support overriding core's implementation.

@fables-tales
Copy link
Member

@JonRowe there's a pull on core that needs to be merged at the same time

end
end
subject(:warning_object) {
Object.new.tap {|o| o.extend(RSpec::Support::Warnings)}
Copy link
Member

Choose a reason for hiding this comment

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

We tend to use do/end for multiline blocks.

Copy link
Member

Choose a reason for hiding this comment

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

Also, could this not just be a plain let?

Copy link
Member

Choose a reason for hiding this comment

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

It could be, but it is the subject of the test, so named subject makes more sense IMO.

Copy link
Member

Choose a reason for hiding this comment

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

Except subject is intended for one liners which you're not using, and explicit subject is a bit of a smell, so in general when a vanilla let can be used I favour it.

Copy link
Member

Choose a reason for hiding this comment

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

I completely disagree. Just because it works for one liners does not mean it shouldn't be used elsewhere. Specifically I think it draws attention to the actual object under test, as opposed to collaborators.

Copy link
Member

Choose a reason for hiding this comment

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

We do indeed disagree. I prefer to let my docstrings and let names explain what's under test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have to say I agree with @samphippen subject distinguishes the object from the other collaborators. While it isn't absolutely necessary I think it's a nice hint.

@JonRowe
Copy link
Member

JonRowe commented Feb 12, 2014

I'm with the plan now, left a few minor quibbles but otherwise LGTM

@myronmarston
Copy link
Member

This LGTM.

@fables-tales
Copy link
Member

@myronmarston I think we need to merge this and rspec/rspec-core#1253 simultaneously, so I'll hold off merging until that;s done.

fables-tales pushed a commit that referenced this pull request Feb 20, 2014
Extract warning methods into module
@fables-tales fables-tales merged commit e914012 into rspec:master Feb 20, 2014
@fables-tales fables-tales deleted the warnings-module branch February 20, 2014 14:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants