Sha256: b9a7744e61f75358f5ec3f57654e26d22b4e32100649fbf5d3eb442e5b37ec7b
Contents?: true
Size: 794 Bytes
Versions: 1
Compression:
Stored size: 794 Bytes
Contents
require 'minitest/autorun' require 'test_values' class MyTest < Minitest::Test def test_bad_item_length items = MyItems.new values = StringValues.strings_not_in_length_range((4..8)) puts "Testing with values #{values.inspect}" values.each_pair do |name, value| message = "Value #{value.inspect} should raise an exception because it is #{name}." puts "\n#{message}" e = assert_raises(ArgumentError, message) do items.add_item(value) end puts "Got exception #{e.inspect}" end end end class MyItems attr_accessor :items def initialize self.items = [] end def add_item(item) raise ArgumentError.new(item) unless (4..8).include?(item.length) items.push(item) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
test_values-0.3.0 | markdown/readme/named_values/example.rb |