Sha256: 37eb9ded9276a4c8980fb35f1f9e31db90a94818220fb8726614b12c6c9bb7a8

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

require 'fakefs/spec_helpers'

describe Hostsfile do
  describe "::Entry" do
    let(:entry) { Hostsfile::Entry.new ip_address: "0.0.0.0", hostname: "test" }

    context "#parse" do
      it "raises a fatal error if the hostname is missing (considers the first field the IP" do
        expect { Hostsfile::Entry.parse "0.0.0.0"}.to raise_error(ArgumentError, /Hostsfile has a line without hostname/)
        expect { Hostsfile::Entry.parse "       hostname"}.to raise_error(ArgumentError, /Hostsfile has a line without hostname/)
        expect { Hostsfile::Entry.parse "       \thostname"}.to raise_error(ArgumentError, /Hostsfile has a line without hostname/)
        expect { Hostsfile::Entry.parse "\thostname"}.to raise_error(ArgumentError, /Hostsfile has a line without hostname/)
      end
    end

    context "#to_line" do
      it "exists" do
        expect(entry.respond_to? :to_line).to eq(true)
      end

      it "generates a proper line" do
        expect(entry.to_line).to eq("0.0.0.0\ttest")
      end
    end
  end
end

## Entry
#    def parse(line)
#    private
#      def extract_comment(line)
#      def extract_priority(comment)
#      def extract_entries(entry)
#      def presence(string)
#
#  def initialize(options = {})
#  def priority=(new_priority)
#  def to_line
#  def to_s
#  def inspect
#  def calculated_priority?
#  private
#    def calculated_priority

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hostsfile-0.0.2 spec/entry_spec.rb