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

Extracted silence_stream method to new module in activesupport/testing #18526

Merged
merged 1 commit into from
Feb 5, 2015

Conversation

vipulnsward
Copy link
Member

  • Extracted silence_stream method to new module in activesupport/testing
  • Added include for the same in ActiveSupport::Test.
  • Removed occurrences of silence_stream being used elsewhere.
  • Reordered activesupport testcase requires alphabetically.

cc @senny

@@ -55,6 +56,7 @@ def test_order
include ActiveSupport::Testing::Assertions
include ActiveSupport::Testing::Deprecation
include ActiveSupport::Testing::TimeHelpers
include ActiveSupport::Testing::SilenceStream

Choose a reason for hiding this comment

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

I don't think we want to make it publicly available for people to use outside of the framework, that's why it was deprecated and moved to the places it's currently in use. The best thing we can do is to find a way to share code between those places, without making it available through AS::TestCase I think.

@senny
Copy link
Member

senny commented Jan 15, 2015

I agree with @carlosantoniodasilva . My #18381 (comment) was probably not descriptive enough. I think we need to find a new place to share code for our test suites without exposing them through ActiveSupport::TestCase.

@vipulnsward
Copy link
Member Author

I removed the inclusion in ActiveSupport::TestCase and made it available as needed in the tests.

module ActiveSupport
module Testing
module SilenceStream
def silence_stream(stream)

Choose a reason for hiding this comment

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

You can make the method private here, no need to do that from the callers.

@vipulnsward
Copy link
Member Author

Done. Can't move in capture(stream) as it is getting mixed in ActiveSupport::TestCase which defeats our purpose again.
On a side note, I see that these methods that were deprecated from Kernel, are still in guides. Will update guides after this.

@carlosantoniodasilva
Copy link
Member

Is it being mixed from as/test_case or in some other abstract unit? I don't think it should be in our test case which would make it available for everyone.

@vipulnsward
Copy link
Member Author

Actually its spread even more- railties abstract unit, railties test isolation, deprecation test, ActiveRecord::TestCase, Rails::Generators::Testing::Behaviour.
Rails::Generators::Testing::Behaviour gets mixed in Rails::Generators::TestCase

@carlosantoniodasilva
Copy link
Member

I see.. it was probably mixed in those base classes to make it easier to share, but I think they should never be publicly available (this was the original intent, right?).

Lets move them out as well, people know these are deprecated and being removed anyway.

@rafaelfranca
Copy link
Member

Generators tests doesn't work without these methods. They are internal of these test cases, are not public available, just private methods of a public interface.

@carlosantoniodasilva
Copy link
Member

Right, so we are good keeping them there. But they should be moved from elsewhere in our suite.

@vipulnsward
Copy link
Member Author

Ok, extracted capture to Stream. Also this shouldn't affect wherever it was getting getting mixed in.

@aditya-kapoor
Copy link
Contributor

It would be also good to focus on those PRs in the recent past where the warnings have been ignored to due non existence of certain instance variables and like. Using this module, we can reduce the unnecessary checks for those variables.
Any thoughts on this?

@carlosantoniodasilva
Copy link
Member

Can you show some examples @aditya-kapoor ? In any case I think it's an unrelated discussion.


module ActiveRecord
# = Active Record Test Case
#
# Defines some test assertions to test against SQL queries.
class TestCase < ActiveSupport::TestCase #:nodoc:
include ActiveSupport::Testing::Stream

Choose a reason for hiding this comment

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

Can you add a blank line after the inclusion here?

…ing.

- Added include for the same in ActiveSupport::Test.
- Removed occurrences of silence_stream being used elsewhere.
- Reordered activesupport testcase requires alphabetically.

- Removed require of silence stream from test_case

- Moved quietly method to stream helper

- Moved capture output to stream helper module and setup requires for the same elsewhere
@vipulnsward
Copy link
Member Author

@carlosantoniodasilva updated.

rafaelfranca added a commit that referenced this pull request Feb 5, 2015
Extracted silence_stream method to new module in activesupport/testing
@rafaelfranca rafaelfranca merged commit 6953f16 into rails:master Feb 5, 2015
@vipulnsward vipulnsward deleted the add-silence-stream branch February 22, 2016 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants