Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
67 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module ConnectivityHelper | ||
def need_connectivity | ||
if connectivity_available? | ||
yield | ||
end | ||
end | ||
|
||
def connectivity_available? | ||
ENV["ONLINE"].to_i == 1 | ||
end | ||
end | ||
|
||
RSpec.configure do |config| | ||
config.extend ConnectivityHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
module SpecHelper | ||
|
||
private | ||
|
||
# Temporary resets Server @@definitions | ||
# to let the test setup a custom definition list. | ||
def with_definitions | ||
definitions_setup | ||
yield | ||
ensure | ||
definitions_teardown | ||
end | ||
|
||
def definitions_setup | ||
@_definitions = Whois::Server.definitions | ||
Whois::Server.send :class_variable_set, :@@definitions, { :tld => [], :ipv4 =>[], :ipv6 => [] } | ||
end | ||
|
||
def definitions_teardown | ||
Whois::Server.send :class_variable_set, :@@definitions, @_definitions | ||
end | ||
|
||
|
||
# Temporary resets parser @@registry | ||
# to let the test setup a custom registry. | ||
def with_registry | ||
@_property_registry = Whois::Answer::Parser::Base.send :class_variable_get, :@@property_registry | ||
Whois::Answer::Parser::Base.send :class_variable_set, :@@property_registry, {} | ||
yield | ||
ensure | ||
Whois::Answer::Parser::Base.send :class_variable_set, :@@property_registry, @_property_registry | ||
end | ||
|
||
# Gets the currently described class. | ||
# Conversely to +subject+, it returns the class | ||
# instead of an instance. | ||
def klass | ||
described_class | ||
end | ||
|
||
def fixture(*names) | ||
File.join(SPEC_ROOT, "fixtures", *names) | ||
end | ||
|
||
end | ||
|
||
RSpec.configure do |config| | ||
config.include SpecHelper | ||
end |