Sha256: 6f467ef46c8c0f402c1a7e17dd299889a00e4fa1adacc2aca0757231d02094d3

Contents?: true

Size: 827 Bytes

Versions: 4

Compression:

Stored size: 827 Bytes

Contents

module RSpecSupportSpecHelpers

  # 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

  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

end

RSpec.configure do |config|
  config.include RSpecSupportSpecHelpers
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
whois-2.6.3 spec/support/helpers/spec_helper.rb
whois-2.6.2 spec/support/helpers/spec_helper.rb
whois-2.6.1 spec/support/helpers/spec_helper.rb
whois-2.6.0 spec/support/helpers/spec_helper.rb