Skip to content

Commit

Permalink
Undefine all #throttle? methods except the one in Whois::Answer::Pars…
Browse files Browse the repository at this point in the history
…er::Base.
  • Loading branch information
weppos committed Jan 28, 2011
1 parent 1932bbd commit 18051e2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 19 deletions.
7 changes: 4 additions & 3 deletions lib/whois/answer.rb
Expand Up @@ -199,15 +199,16 @@ def contacts
parser.contacts
end


# Checks whether this is a throttle response.
#
# @return [Boolean]
#
# @see Whois::Answer::Parser#throttle?
#
def throttle?
parser.throttle?
end
# def throttle?
# parser.throttle?
# end


private
Expand Down
10 changes: 5 additions & 5 deletions lib/whois/answer/parser.rb
Expand Up @@ -106,8 +106,7 @@ def unchanged?(other)
end

equal?(other) ||
parsers.size == other.parsers.size &&
all_with_args?(parsers, other.parsers) { |one, two| one.unchanged?(two) }
parsers.size == other.parsers.size && all_with_args?(parsers, other.parsers) { |one, two| one.unchanged?(two) }
end

# Collects and returns all the contacts from all the answer parts.
Expand All @@ -121,6 +120,7 @@ def contacts
parsers.inject([]) { |all, parser| all.concat(parser.contacts) }
end


# Loop through all the answer parts to check if at least
# one part is a throttle response.
#
Expand All @@ -129,9 +129,9 @@ def contacts
# @see Whois::Answer#throttle?
# @see Whois::Answer::Parser::Base#throttle?
#
def throttle?
parsers.any?(&:throttle?)
end
# def throttle?
# parsers.any?(&:throttle?)
# end


private
Expand Down
5 changes: 1 addition & 4 deletions lib/whois/answer/parser/base.rb
Expand Up @@ -278,6 +278,7 @@ def contacts
contacts.compact
end


# Checks whether this is a throttle response.
# The default implementation always returns +nil+.
#
Expand All @@ -293,10 +294,6 @@ def throttle?
end






protected

def content_for_scanner
Expand Down
6 changes: 6 additions & 0 deletions spec/whois/answer/parser_spec.rb
Expand Up @@ -164,6 +164,12 @@ class Whois::Answer::Parser::ParserUnsupportedTest < Whois::Answer::Parser::Base
end


# describe "#throttle?" do
# it "" do
# end
# end


describe ".parser_klass" do
it "returns the parser hostname converted into a class" do
require 'whois/answer/parser/whois.crsnic.net'
Expand Down
15 changes: 8 additions & 7 deletions spec/whois/answer_spec.rb
Expand Up @@ -304,14 +304,15 @@ class Whois::Answer::Parser::WhoisPropertiesTest < Whois::Answer::Parser::Base
end
end

describe "#throttle?" do
it "delegates to #parser" do
instance = klass.new(nil, @parts)
instance.parser.expects(:throttle?)

instance.throttle?
end
end
# describe "#throttle?" do
# it "delegates to #parser" do
# i = klass.new(nil, @parts)
# i.parser.expects(:throttle?)
#
# i.throttle?
# end
# end


describe "method_missing" do
Expand Down

0 comments on commit 18051e2

Please sign in to comment.