<commit_before>require 'spec_helper'

describe OpenShip::Sscc do 

  it "Should persist a company prefix on the model" do
    OpenShip::Sscc.company_prefix = "801234"
    OpenShip::Sscc.company_prefix.should == "801234"
  end

  it "should generate a valid check digit for a given sscc id" do
    # See http://www.gs1us.org/solutions_services/tools/check_digit_calculator
    # for the example from which this is derived.
    sscc = "10614141192837465"
    sscc2 = "10614141192837700"
    expected_digit = "7"
    expected_digit2 = "9"
    OpenShip::Sscc.generate_check_digit(sscc).should == expected_digit
    OpenShip::Sscc.generate_check_digit(sscc2).should == expected_digit2
  end

  it "should return a valid sscc for a sequence number" do
    company_prefix = "0614141"
    serial_reference = "192837465"
    OpenShip::Sscc.company_prefix = company_prefix
    sscc = OpenShip::Sscc.generate_sscc_id(serial_reference)
    sscc.should == "106141411928374657"
  end

  it "should fill in leading zeros in serial_reference if serial_reference + company_prefix + extension_digit adds up to less than 17" do<commit_msg>Made the spec tests respect the company prefix leading zero rule.<commit_after>require 'spec_helper'

describe OpenShip::Sscc do 

  it "Should persist a company prefix on the model" do
    OpenShip::Sscc.company_prefix = "0801234"
    OpenShip::Sscc.company_prefix.should == "0801234"
  end

  it "should generate a valid check digit for a given sscc id" do
    # See http://www.gs1us.org/solutions_services/tools/check_digit_calculator
    # for the example from which this is derived.
    sscc = "10614141192837465"
    sscc2 = "10614141192837700"
    expected_digit = "7"
    expected_digit2 = "9"
    OpenShip::Sscc.generate_check_digit(sscc).should == expected_digit
    OpenShip::Sscc.generate_check_digit(sscc2).should == expected_digit2
  end

  it "should return a valid sscc for a sequence number" do
    company_prefix = "0614141"
    serial_reference = "192837465"
    OpenShip::Sscc.company_prefix = company_prefix
    sscc = OpenShip::Sscc.generate_sscc_id(serial_reference)
    sscc.should == "106141411928374657"
  end

  it "should fill in leading zeros in serial_reference if serial_reference + company_prefix + extension_digit adds up to less than 17" do
{'fraction_non_alphanumeric': 0.07977332170880558, 'fraction_numerical': 0.07846556233653008, 'mean_word_length': 4.288018433179723, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, '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': '3713717', 'n_tokens_mistral': 874, 'n_tokens_neox': 752, 'n_words': 203}