Test Error:
NoMethodError: undefined method `-' for nil
Traceback (most recent call first):
Line 12:in `modifier'
full test:
def test_random_character_stats
skip
100.times do
character = DndCharacter.new
allowed_range = (3..18)
expected_hitpoints = BASE_HITPOINTS +
DndCharacter.modifier(character.constitution)
informative_message = %q(The character's %s must be within %s)
attributes.each do |attribute|
assert_includes allowed_range, character.send(attribute),
informative_message % [attribute, allowed_range]
end
informative_message = %q(The character's %s must be %s)
assert_equal expected_hitpoints, character.hitpoints,
informative_message % ['hitpoints', expected_hitpoints]
end
end
I barely have any code written, not sure how 16 of the 18 tests are passing:
code:
class DndCharacter
def self.modifier(mod_value = 0)
puts mod_value
((mod_value - 10) / 2).round
end
def constitution
end
def initialize
# Your code here
end
end
I interpreted the test error to mean that mod_value was nil, so i added the default of 0.
I feel like something is wrong with the test suite on this one, in that they are not leading me to deeper problems in the code. Now I am almost at the end of the problem, from a testing perspective, only 2 tests left & it's not easy to see what is supposed to be next just by looking at the tests.