spec/helpers.rb in games_dice-0.3.11 vs spec/helpers.rb in games_dice-0.3.12

- old
+ new

@@ -42,13 +42,13 @@ RSpec::Matchers.define :be_valid_distribution do match do |given| @error = nil if ! given.is_a?(Hash) @error = "distribution should be a Hash, but it is a #{given.class}" - elsif given.keys.any? { |k| ! k.is_a?(Fixnum) } - bad_key = given.keys.first { |k| ! k.is_a?(Fixnum) } - @error = "all keys should be Fixnums, but found '#{bad_key.inspect}' which is a #{bad_key.class}" + elsif given.keys.any? { |k| ! k.is_a?(Integer) } + bad_key = given.keys.first { |k| ! k.is_a?(Integer) } + @error = "all keys should be Integers, but found '#{bad_key.inspect}' which is a #{bad_key.class}" elsif given.values.any? { |v| ! v.is_a?(Float) } bad_value = given.values.find { |v| ! v.is_a?(Float) } @error = "all values should be Floats, but found '#{bad_value.inspect}' which is a #{bad_value.class}" elsif given.values.any? { |v| v < 0.0 || v > 1.0 } bad_value = given.values.find { |v| v < 0.0 || v > 1.0 } @@ -58,14 +58,14 @@ @error = "sum of values should be 1.0, but got #{total_probs}" end ! @error end - failure_message_for_should do |given| + failure_message do |given| @error ? @error : 'Distribution is valid and complete' end - failure_message_for_should_not do |given| + failure_message_when_negated do |given| @error ? @error : 'Distribution is valid and complete' end description do |given| "a hash describing a complete probability distribution of integer results"