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

remove mixing enumerable into string #380

Merged
merged 1 commit into from Aug 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 0 additions & 43 deletions lib/spec/util/extensions/miq-string_spec.rb
Expand Up @@ -9,49 +9,6 @@
Kernel.should_receive(:warn).never
Array('somestring')
end

context 'Enumerable' do
it 'included' do
String.include?(Enumerable).should be_true
end

it '#any? warns' do
Kernel.should_receive(:warn).once
"one\ntwo".any? { |str| str == 'two'}.should be_true
end

context '#to_a' do
it 'defined' do
String.method_defined?(:to_a).should be_true
end

it 'does not respond' do
String.respond_to?(:to_a).should_not be_true
end

it 'warns' do
Kernel.should_receive(:warn).once
"one\ntwo".to_a.should == ["one\n", 'two']
end
end
end

context '#each' do
it 'defined' do
String.method_defined?(:each).should be_true
end

it 'does not respond' do
String.respond_to?(:each).should_not be_true
end

it 'calls each_line and warns' do
str = 'one\ntwo'
str.should_receive(:each_line).once
Kernel.should_receive(:warn).once
str.each { |s| s }
end
end
end

it '#<<(exception)' do
Expand Down
20 changes: 0 additions & 20 deletions lib/util/extensions/miq-string.rb
Expand Up @@ -45,26 +45,6 @@ def +(str)
self.original_plus(str.message)
end

unless method_defined?(:each)
include Enumerable

def respond_to?(symbol, include_private=false)
method = symbol.to_sym
return false if method == :each || method == :to_a
super
end

def each(*args, &block)
if !defined?(Rails) || !Rails.env.production?
msg = "[DEPRECATION] String#each has been removed from ruby 1.9. Please use String#each_line instead. At #{caller[0]}"
$log.warn msg if $log
Kernel.warn msg
end

self.each_line(*args, &block)
end
end

unless method_defined?(:ord)
def ord
raise ArgumentError, "empty string" if self.length == 0
Expand Down