1
exercism fetch ruby isbn-verifier

isbn_verifier_test.rb

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
require 'minitest/autorun'
require_relative 'isbn_verifier'

# Common test data version: 2.0.0 3251fa6
class IsbnVerifierTest < Minitest::Test
  def test_valid_isbn_number
    # skip
    string = "3-598-21508-8"
    assert IsbnVerifier.valid?(string), "Expected true, '#{string}' is a valid isbn"
  end

  def test_invalid_isbn_check_digit
    skip
    string = "3-598-21508-9"
    refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn"
  end

  def test_valid_isbn_number_with_a_check_digit_of_10
    skip
    string = "3-598-21507-X"
    assert IsbnVerifier.valid?(string), "Expected true, '#{string}' is a valid isbn"
  end

  def test_check_digit_is_a_character_other_than_x
    skip
    string = "3-598-21507-A"
    refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn"
  end

  def test_invalid_character_in_isbn
    skip
    string = "3-598-2K507-0"
    refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn"
  end

  def test_x_is_only_valid_as_a_check_digit
    skip
    string = "3-598-2X507-9"
    refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn"
  end

  def test_valid_isbn_without_separating_dashes
    skip
    string = "3598215088"
    assert IsbnVerifier.valid?(string), "Expected true, '#{string}' is a valid isbn"
  end

  def test_isbn_without_separating_dashes_and_x_as_check_digit
    skip
    string = "359821507X"
    assert IsbnVerifier.valid?(string), "Expected true, '#{string}' is a valid isbn"
  end

  def test_isbn_without_check_digit_and_dashes
    skip
    string = "359821507"
    refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn"
  end

  def test_too_long_isbn_and_no_dashes
    skip
    string = "3598215078X"
    refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn"
  end

  def test_isbn_without_check_digit
    skip
    string = "3-598-21507"
    refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn"
  end

  def test_too_long_isbn
    skip
    string = "3-598-21507-XX"
    refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn"
  end

  def test_check_digit_of_x_should_not_be_used_for_0
    skip
    string = "3-598-21515-X"
    refute IsbnVerifier.valid?(string), "Expected false, '#{string}' is not a valid isbn"
  end

  # Problems in exercism evolve over time, as we find better ways to ask
  # questions.
  # The version number refers to the version of the problem you solved,
  # not your solution.
  #
  # Define a constant named VERSION inside of the top level BookKeeping
  # module, which may be placed near the end of your file.
  #
  # In your file, it will look like this:
  #
  # module BookKeeping
  #   VERSION = 1 # Where the version number matches the one in the test.
  # end
  #
  # If you are curious, read more about constants on RubyDoc:
  # http://ruby-doc.org/docs/ruby-doc-bundle/UsersGuide/rg/constants.html

  def test_bookkeeping
    skip
    assert_equal 1, BookKeeping::VERSION
  end
end