<commit_before>require 'spec_helper'

describe Ipaddress do
  it "stores ip address as an integer" do
    ip = Ipaddress.new(address: "127.0.0.1")
    ip.read_attribute(:address).should eq(IPAddr.new("127.0.0.1").to_i)
  end

  it "is able to store large addresses" do
    ip = Ipaddress.new(address: "255.255.255.255")
    ip.read_attribute(:address).should eq(IPAddr.new("255.255.255.255").to_i)
  end

  it "islong to a server" do
    ip = Ipaddress.new(address: "192.168.1.1")
    ip.should_not be_valid
    ip.should have(1).error_on(:server)
    ip.server = FactoryGirl.create(:server)
    ip.should be_valid
  end

  it "leaves ipaddress blank if invalid" do
    ip = Ipaddress.new(address: "abcd", server: FactoryGirl.create(:server))
    ip.should be_valid
    ip.address.should be_blank
    ip.address = "192.168.1.1"
    ip.should be_valid
    ip.address.should eq "192.168.1.1"
  end

  context "#to_s" do
    it "returns an empty string if no address" do<commit_msg>Fixed failing test due to previous commit<commit_after>require 'spec_helper'

describe Ipaddress do
  it "stores ip address as an integer" do
    ip = Ipaddress.new(address: "127.0.0.1")
    ip.read_attribute(:address).should eq(IPAddr.new("127.0.0.1").to_i)
  end

  it "is able to store large addresses" do
    ip = Ipaddress.new(address: "255.255.255.255")
    ip.read_attribute(:address).should eq(IPAddr.new("255.255.255.255").to_i)
  end

  it "islong to a server" do
    ip = Ipaddress.new(address: "192.168.1.1")
    ip.should_not be_valid
    ip.should have(1).error_on(:server)
    ip.server = FactoryGirl.create(:server)
    ip.should be_valid
  end

  it "leaves ipaddress blank if invalid" do
    ip = Ipaddress.new(address: "abcd", server: FactoryGirl.create(:server))
    ip.should_not be_valid
    ip.address.should be_blank
    ip.address = "192.168.1.1"
    ip.should be_valid
    ip.address.should eq "192.168.1.1"
  end

  context "#to_s" do
    it "returns an empty string if no address" do
{'fraction_non_alphanumeric': 0.12663316582914572, 'fraction_numerical': 0.061306532663316586, 'mean_word_length': 3.337690631808279, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 14, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5691652', 'n_tokens_mistral': 799, 'n_tokens_neox': 720, 'n_words': 179}