Sha256: 28413b6c2f29b4909291c495804f7953c2a623ff3007e1961d4dd94de458b24e

Contents?: true

Size: 1.12 KB

Versions: 18

Compression:

Stored size: 1.12 KB

Contents

module ParserExampleGroup

  def load_part(path)
    Whois::Record::Part.new(File.read(fixture("responses", @host.to_s, @suffix.to_s, @schema.to_s, path)), @host)
  end

  def _part
    Whois::Record::Part
  end

  def _registrar
    Whois::Record::Registrar
  end

  def _contact
    Whois::Record::Contact
  end

  def _nameserver
    Whois::Record::Nameserver
  end

end

RSpec::Matchers.define :cache_property do |property|
  match do |instance|
    cache = instance.instance_eval do
      @cached_properties = {}
      @cached_properties
    end

    cache.key?(property).should be_false
    value = instance.send(property)

    cache.key?(property).should be_true
    cache[property].should == value

    true
  end

  failure_message_for_should do |instance|
    "expected parser to cache property #{property}"
  end
  failure_message_for_should_not do |instance|
    "expected parser to not cache property #{property}"
  end
end

RSpec::configure do |c|
  def c.escaped_path(*parts)
    /#{parts.join('\/')}/
  end

  c.include ParserExampleGroup, :example_group => {
    :file_path => c.escaped_path(%w( spec whois record parser ))
  }
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
whois-2.6.3 spec/support/example/parser_example_group.rb
whois-2.6.2 spec/support/example/parser_example_group.rb
whois-2.6.1 spec/support/example/parser_example_group.rb
whois-2.6.0 spec/support/example/parser_example_group.rb
whois-2.5.1 spec/support/example/parser_example_group.rb
whois-2.5.0 spec/support/example/parser_example_group.rb
whois-2.4.0 spec/support/example/parser_example_group.rb
whois-2.3.0 spec/support/example/parser_example_group.rb
whois-2.2.0 spec/support/example/parser_example_group.rb
whois-2.1.0 spec/support/example/parser_example_group.rb
whois-2.0.7 spec/support/example/parser_example_group.rb
whois-2.0.6 spec/support/example/parser_example_group.rb
whois-2.0.5 spec/support/example/parser_example_group.rb
whois-2.0.4 spec/support/example/parser_example_group.rb
whois-2.0.3 spec/support/example/parser_example_group.rb
whois-2.0.2 spec/support/example/parser_example_group.rb
whois-2.0.1 spec/support/example/parser_example_group.rb
whois-2.0.0 spec/support/example/parser_example_group.rb