Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: re-expose GTIN#check_digit as public method #28

Merged
merged 1 commit into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/barcodevalidation/gtin/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ def to_gtin_14
is_a?(GTIN14) ? self : transcode_to(GTIN14)
end

private

def check_digit
CheckDigit.new(last, expected: expected_check_digit)
end

private

def expected_check_digit
(MODULUS - weighted_checkable_digit_sum) % MODULUS
end
Expand Down
4 changes: 4 additions & 0 deletions spec/lib/barcodevalidation/gtin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
context "with a UPC with an invalid check digit" do
let(:input) { 123_456_789_011 }
it { is_expected.to_not be_valid }

it "exposes the CheckDigit" do
expect(gtin.check_digit).to_not be_valid
end
end

context "with a sequence of digits of unknown length" do
Expand Down