test_values 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +176 -3
  4. data/lib/test_values/string_values.rb +17 -20
  5. data/lib/test_values/values_base.rb +11 -2
  6. data/lib/test_values/version.rb +1 -1
  7. data/markdown/readme/Rakefile +30 -0
  8. data/markdown/readme/classes/string_values/string_of_length/base_string/example.md +14 -0
  9. data/markdown/readme/classes/string_values/string_of_length/base_string/example.rb +4 -0
  10. data/markdown/readme/classes/string_values/string_of_length/base_string/output.txt +1 -0
  11. data/markdown/readme/classes/string_values/string_of_length/base_string/template.md +5 -0
  12. data/markdown/readme/classes/string_values/string_of_length/simple/example.md +14 -0
  13. data/markdown/readme/classes/string_values/string_of_length/simple/example.rb +4 -0
  14. data/markdown/readme/classes/string_values/string_of_length/simple/output.txt +1 -0
  15. data/markdown/readme/classes/string_values/string_of_length/simple/template.md +5 -0
  16. data/markdown/readme/classes/string_values/string_of_length/template.md +5 -0
  17. data/markdown/readme/classes/string_values/strings_in_length_range/base_string/example.md +14 -0
  18. data/markdown/readme/classes/string_values/strings_in_length_range/base_string/example.rb +4 -0
  19. data/markdown/readme/classes/string_values/strings_in_length_range/base_string/output.txt +1 -0
  20. data/markdown/readme/classes/string_values/strings_in_length_range/base_string/template.md +5 -0
  21. data/markdown/readme/classes/string_values/strings_in_length_range/simple/example.md +14 -0
  22. data/markdown/readme/classes/string_values/strings_in_length_range/simple/example.rb +4 -0
  23. data/markdown/readme/classes/string_values/strings_in_length_range/simple/output.txt +1 -0
  24. data/markdown/readme/classes/string_values/strings_in_length_range/simple/template.md +5 -0
  25. data/markdown/readme/classes/string_values/strings_in_length_range/template.md +5 -0
  26. data/markdown/readme/classes/string_values/strings_not_in_length_range/base_string/example.md +14 -0
  27. data/markdown/readme/classes/string_values/strings_not_in_length_range/base_string/example.rb +4 -0
  28. data/markdown/readme/classes/string_values/strings_not_in_length_range/base_string/output.txt +1 -0
  29. data/markdown/readme/classes/string_values/strings_not_in_length_range/base_string/template.md +5 -0
  30. data/markdown/readme/classes/string_values/strings_not_in_length_range/simple/example.md +14 -0
  31. data/markdown/readme/classes/string_values/strings_not_in_length_range/simple/example.rb +4 -0
  32. data/markdown/readme/classes/string_values/strings_not_in_length_range/simple/output.txt +1 -0
  33. data/markdown/readme/classes/string_values/strings_not_in_length_range/simple/template.md +5 -0
  34. data/markdown/readme/classes/string_values/strings_not_in_length_range/template.md +5 -0
  35. data/markdown/readme/classes/string_values/template.md +13 -0
  36. data/markdown/readme/named_values/example.md +66 -0
  37. data/markdown/readme/named_values/example.rb +37 -0
  38. data/markdown/readme/named_values/output.txt +16 -0
  39. data/markdown/readme/named_values/template.md +9 -0
  40. data/markdown/readme/template.md +13 -0
  41. metadata +36 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d70c7bfe9b941510702219a97cb6dbd10135c1ab
4
- data.tar.gz: 337503957c0b9b80233ab2d2b24f161269457480
3
+ metadata.gz: ed1394d81783ca2931dcba4ef9a7d09caa81109c
4
+ data.tar.gz: 165636172a73b2bfbe41b89d702fbe88526ff42e
5
5
  SHA512:
6
- metadata.gz: 848d62c01a29a9f912cedf4e3300625025d4792c3fbe4a14847caac37b276e4d7b8c2bf118dc58e4535c8b18e6c603f67053c90e2d767e3485ba1357d7b3529e
7
- data.tar.gz: 6ae2b10eddcf9e39421bc263f3b88ab01fb30d347ad4fc1aa6460b2064d8b21cb98c309958fd0cc8c523a0bd5fec416f85902ba7398506b1fd7109455032a434
6
+ metadata.gz: 42edc0139467d42f4bc141f4d26451d1fa6f6d2887823163f8e13e591814e7f32226d3f68c4e3cd9c19b1ae04490cce8a05a58d1ad30cf3627d1661bc8ec6049
7
+ data.tar.gz: 0f397f8aeed2f73a8fd2b8ea8be1738ba3f68eac634ab50ca52431bf6f0a2719cd67f3a57b006f98e2b7e1e5c6cd90c71bd683350261b92de230d23bbe44afd2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- test_values (0.2.0)
4
+ test_values (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,7 +1,180 @@
1
1
  # Test Values
2
2
 
3
- Project to support generation of values for testing software.
3
+ [![Gem](https://img.shields.io/gem/v/test_values.svg?style=flat)](http://rubygems.org/gems/test_values "View this project in Rubygems")
4
4
 
5
- At this point, just a few methods.
5
+ This project makes it easy to generate _and utilize_ certain kinds of values for testing software.
6
6
 
7
- Experimenting with YARD documentation.
7
+ ## Named Values
8
+
9
+ Generally speaking, a values method whose name is plural returns a hash of named values.
10
+
11
+ The calling test can iterate over the hash, using the names as labels and the values as test data:
12
+
13
+ ```example.rb```:
14
+ ```ruby
15
+ require 'minitest/autorun'
16
+
17
+ require 'test_values'
18
+
19
+ class MyTest < Minitest::Test
20
+
21
+ def test_bad_item_length
22
+ items = MyItems.new
23
+ values = StringValues.strings_not_in_length_range((4..8))
24
+ puts "Testing with values #{values.inspect}"
25
+ values.each_pair do |name, value|
26
+ message = "Value #{value.inspect} should raise an exception because it is #{name}."
27
+ puts "\n#{message}"
28
+ e = assert_raises(ArgumentError, message) do
29
+ items.add_item(value)
30
+ end
31
+ puts "Got exception #{e.inspect}"
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+
38
+ class MyItems
39
+
40
+ attr_accessor :items
41
+
42
+ def initialize
43
+ self.items = []
44
+ end
45
+
46
+ def add_item(item)
47
+ raise ArgumentError.new(item) unless (4..8).include?(item.length)
48
+ items.push(item)
49
+ end
50
+
51
+ end
52
+ ```
53
+
54
+ ```output.txt```:
55
+ ```
56
+ Run options: --seed 24259
57
+
58
+ # Running:
59
+
60
+ Testing with values {:too_short=>"xxx", :too_long=>"xxxxxxxxx"}
61
+
62
+ Value "xxx" should raise an exception because it is too_short.
63
+ Got exception #<ArgumentError: xxx>
64
+
65
+ Value "xxxxxxxxx" should raise an exception because it is too_long.
66
+ Got exception #<ArgumentError: xxxxxxxxx>
67
+ .
68
+
69
+ Finished in 0.001529s, 653.9277 runs/s, 1307.8554 assertions/s.
70
+
71
+ 1 runs, 2 assertions, 0 failures, 0 errors, 0 skips
72
+ ```
73
+
74
+ ## Classes
75
+
76
+ - [StringValues](#class-stringvalues)
77
+
78
+ ### Class ```StringValues```
79
+
80
+ #### Methods
81
+
82
+ - [strings_in_length_range](#method-strings_in_length_range)
83
+ - [strings_not_in_length_range](#method-strings_not_in_length_range)
84
+ - [string_of_length](#method-string_of_length)
85
+
86
+ #### Method ```strings_in_length_range```
87
+
88
+ ##### Simple
89
+
90
+ ```example.rb```:
91
+ ```ruby
92
+ require 'test_values'
93
+
94
+ values = StringValues.strings_in_length_range((4..10))
95
+ p values
96
+ ```
97
+
98
+ ```output.txt```:
99
+ ```
100
+ {:min_length=>"xxxx", :max_length=>"xxxxxxxxxx"}
101
+ ```
102
+
103
+ ##### Base String
104
+
105
+ ```example.rb```:
106
+ ```ruby
107
+ require 'test_values'
108
+
109
+ values = StringValues.strings_in_length_range((4..10), 'abc')
110
+ p values
111
+ ```
112
+
113
+ ```output.txt```:
114
+ ```
115
+ {:min_length=>"abca", :max_length=>"abcabcabca"}
116
+ ```
117
+
118
+ #### Method ```strings_not_in_length_range```
119
+
120
+ ##### Simple
121
+
122
+ ```example.rb```:
123
+ ```ruby
124
+ require 'test_values'
125
+
126
+ values = StringValues.strings_not_in_length_range((4..10))
127
+ p values
128
+ ```
129
+
130
+ ```output.txt```:
131
+ ```
132
+ {:too_short=>"xxx", :too_long=>"xxxxxxxxxxx"}
133
+ ```
134
+
135
+ ##### Base String
136
+
137
+ ```example.rb```:
138
+ ```ruby
139
+ require 'test_values'
140
+
141
+ values = StringValues.strings_not_in_length_range((4..10), 'abc')
142
+ p values
143
+ ```
144
+
145
+ ```output.txt```:
146
+ ```
147
+ {:too_short=>"abc", :too_long=>"abcabcabcab"}
148
+ ```
149
+
150
+ #### Method ```string_of_length```
151
+
152
+ ##### Simple
153
+
154
+ ```example.rb```:
155
+ ```ruby
156
+ require 'test_values'
157
+
158
+ s = StringValues.string_of_length(5)
159
+ p s
160
+ ```
161
+
162
+ ```output.txt```:
163
+ ```
164
+ "xxxxx"
165
+ ```
166
+
167
+ ##### Base String
168
+
169
+ ```example.rb```:
170
+ ```ruby
171
+ require 'test_values'
172
+
173
+ s = StringValues.string_of_length(5, 'abc')
174
+ p s
175
+ ```
176
+
177
+ ```output.txt```:
178
+ ```
179
+ "abcab"
180
+ ```
@@ -1,41 +1,38 @@
1
1
  class StringValues < ValuesBase
2
2
 
3
3
  BASE_STRING = 'x'
4
- # Return a string of the given +size+,
4
+ # Return a string of the given +length+,
5
5
  # built by trimming or extending the given +base_string+.
6
- # @param size [Integer] the size of the string to be returned.
6
+ # @param length [Integer] the length of the string to be returned.
7
7
  # @param base_string [String] the base string to be trimmed or extended.
8
- # @return [String] a string of the given size.
9
- # @raise [TypeError] if +size+ is not an +Integer+.
8
+ # @return [String] a string of the given length.
9
+ # @raise [TypeError] if +length+ is not an +Integer+.
10
10
  # @raise [TypeError] if +base_string+ is not a +String+.
11
- # @raise [RangeError] if +size+ is negative.
12
- def self.string_of_size(size, base_string=BASE_STRING)
13
- self.verify_class('size', Integer, size)
11
+ # @raise [RangeError] if +length+ is negative.
12
+ def self.string_of_length(length, base_string=BASE_STRING)
13
+ self.verify_class('length', Integer, length)
14
14
  self.verify_class('base_string', String, base_string)
15
- if size < 0
16
- message = "Parameter size must be nonnegative, not #{size}"
17
- raise RangeError.new(message)
18
- end
19
- return '' if size == 0
15
+ self.verify_integer_size('length', (0..Float::INFINITY), length)
16
+ return '' if length == 0
20
17
  s = base_string
21
- while s.size < size
18
+ while s.length < length
22
19
  s = s * 2
23
20
  end
24
- return s[0..size-1]
21
+ return s[0..length-1]
25
22
  end
26
23
 
27
24
  # Return a hash of strings of minimum and maximum length
28
25
  # for the given +range+.
29
26
  # @param range [Range] specifies the minimum and maximum string lengths.
30
27
  # @param base_string [String] specifies the +base_string+
31
- # @see string_of_size string_of_size for exceptions raised.
28
+ # @see string_of_length string_of_length for exceptions raised.
32
29
  # @return [Hash] +Symbol+/+String+ pairs
33
30
  # with keys +:min_length+ and +:max_length+.
34
31
  def self.strings_in_length_range(range, base_string=BASE_STRING)
35
32
  self.verify_class('range', Range, range)
36
33
  {
37
- :min_length => self.string_of_size(range.first, base_string),
38
- :max_length => self.string_of_size(range.last, base_string),
34
+ :min_length => self.string_of_length(range.first, base_string),
35
+ :max_length => self.string_of_length(range.last, base_string),
39
36
  }
40
37
  end
41
38
 
@@ -43,14 +40,14 @@ class StringValues < ValuesBase
43
40
  # for the given +range+.
44
41
  # @param range [Range] specifies the minimum and maximum string lengths.
45
42
  # @param base_string [String] specifies the +base_string+
46
- # @see string_of_size string_of_size for exceptions raised.
43
+ # @see string_of_length string_of_length for exceptions raised.
47
44
  # @return [Hash] +Symbol+/+String+ pairs
48
45
  # with keys +:too_short+ and +:too_long+.
49
46
  def self.strings_not_in_length_range(range, base_string=BASE_STRING)
50
47
  self.verify_class('range', Range, range)
51
48
  {
52
- :too_short => self.string_of_size(range.first - 1, base_string),
53
- :too_long => self.string_of_size(range.last + 1, base_string),
49
+ :too_short => self.string_of_length(range.first - 1, base_string),
50
+ :too_long => self.string_of_length(range.last + 1, base_string),
54
51
  }
55
52
  end
56
53
 
@@ -1,9 +1,18 @@
1
1
  class ValuesBase
2
2
 
3
+ private
4
+
3
5
  def self.verify_class(parameter_name, klass, obj)
4
- return if obj.kind_of?(klass)
6
+ return true if obj.kind_of?(klass)
5
7
  message = "Parameter #{parameter_name} must be instance of #{klass.name}, not #{obj.inspect}"
6
8
  raise TypeError.new(message)
7
9
  end
8
10
 
9
- end
11
+ def self.verify_integer_size(parameter_name, range, obj)
12
+ self.verify_class(parameter_name, Integer, obj)
13
+ return true if range.include?(obj)
14
+ message = "Parameter #{parameter_name} must be in range #{range}, not #{obj}"
15
+ raise RangeError.new(message)
16
+ end
17
+
18
+ end
@@ -1,3 +1,3 @@
1
1
  class TestValues
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -0,0 +1,30 @@
1
+ require 'find'
2
+
3
+ namespace :build do
4
+ desc 'Build README.md'
5
+ task :readme do
6
+ dir_path = File.dirname(__FILE__)
7
+ Dir.chdir(dir_path) do
8
+ ruby_file_name = 'example.rb'
9
+ template_file_name = 'template.md'
10
+ readme_file_path = File.join(
11
+ dir_path,
12
+ '..',
13
+ '..',
14
+ 'README.md',
15
+ )
16
+ readme_file_path = File.absolute_path(readme_file_path)
17
+ puts readme_file_path
18
+ Find.find('.') do |path|
19
+ next unless File.directory?(path)
20
+ Dir.chdir(path) do
21
+ if File.exist?(ruby_file_name) && File.exist?(template_file_name)
22
+ system("ruby #{ruby_file_name} > output.txt")
23
+ system("markdown_helper include --pristine #{template_file_name} example.md")
24
+ end
25
+ end
26
+ end
27
+ system("markdown_helper include --pristine #{template_file_name} #{readme_file_path}")
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,14 @@
1
+ ##### Base String
2
+
3
+ ```example.rb```:
4
+ ```ruby
5
+ require 'test_values'
6
+
7
+ s = StringValues.string_of_length(5, 'abc')
8
+ p s
9
+ ```
10
+
11
+ ```output.txt```:
12
+ ```
13
+ "abcab"
14
+ ```
@@ -0,0 +1,4 @@
1
+ require 'test_values'
2
+
3
+ s = StringValues.string_of_length(5, 'abc')
4
+ p s
@@ -0,0 +1,5 @@
1
+ ##### Base String
2
+
3
+ @[ruby](example.rb)
4
+
5
+ @[:code_block](output.txt)
@@ -0,0 +1,14 @@
1
+ ##### Simple
2
+
3
+ ```example.rb```:
4
+ ```ruby
5
+ require 'test_values'
6
+
7
+ s = StringValues.string_of_length(5)
8
+ p s
9
+ ```
10
+
11
+ ```output.txt```:
12
+ ```
13
+ "xxxxx"
14
+ ```
@@ -0,0 +1,4 @@
1
+ require 'test_values'
2
+
3
+ s = StringValues.string_of_length(5)
4
+ p s
@@ -0,0 +1,5 @@
1
+ ##### Simple
2
+
3
+ @[ruby](example.rb)
4
+
5
+ @[:code_block](output.txt)
@@ -0,0 +1,5 @@
1
+ #### Method ```string_of_length```
2
+
3
+ @[:markdown](simple/template.md)
4
+
5
+ @[:markdown](base_string/template.md)
@@ -0,0 +1,14 @@
1
+ ##### Base String
2
+
3
+ ```example.rb```:
4
+ ```ruby
5
+ require 'test_values'
6
+
7
+ values = StringValues.strings_in_length_range((4..10), 'abc')
8
+ p values
9
+ ```
10
+
11
+ ```output.txt```:
12
+ ```
13
+ {:min_length=>"abca", :max_length=>"abcabcabca"}
14
+ ```
@@ -0,0 +1,4 @@
1
+ require 'test_values'
2
+
3
+ values = StringValues.strings_in_length_range((4..10), 'abc')
4
+ p values
@@ -0,0 +1 @@
1
+ {:min_length=>"abca", :max_length=>"abcabcabca"}
@@ -0,0 +1,5 @@
1
+ ##### Base String
2
+
3
+ @[ruby](example.rb)
4
+
5
+ @[:code_block](output.txt)
@@ -0,0 +1,14 @@
1
+ ##### Simple
2
+
3
+ ```example.rb```:
4
+ ```ruby
5
+ require 'test_values'
6
+
7
+ values = StringValues.strings_in_length_range((4..10))
8
+ p values
9
+ ```
10
+
11
+ ```output.txt```:
12
+ ```
13
+ {:min_length=>"xxxx", :max_length=>"xxxxxxxxxx"}
14
+ ```
@@ -0,0 +1,4 @@
1
+ require 'test_values'
2
+
3
+ values = StringValues.strings_in_length_range((4..10))
4
+ p values
@@ -0,0 +1 @@
1
+ {:min_length=>"xxxx", :max_length=>"xxxxxxxxxx"}
@@ -0,0 +1,5 @@
1
+ ##### Simple
2
+
3
+ @[ruby](example.rb)
4
+
5
+ @[:code_block](output.txt)
@@ -0,0 +1,5 @@
1
+ #### Method ```strings_in_length_range```
2
+
3
+ @[:markdown](simple/template.md)
4
+
5
+ @[:markdown](base_string/template.md)
@@ -0,0 +1,14 @@
1
+ ##### Base String
2
+
3
+ ```example.rb```:
4
+ ```ruby
5
+ require 'test_values'
6
+
7
+ values = StringValues.strings_not_in_length_range((4..10), 'abc')
8
+ p values
9
+ ```
10
+
11
+ ```output.txt```:
12
+ ```
13
+ {:too_short=>"abc", :too_long=>"abcabcabcab"}
14
+ ```
@@ -0,0 +1,4 @@
1
+ require 'test_values'
2
+
3
+ values = StringValues.strings_not_in_length_range((4..10), 'abc')
4
+ p values
@@ -0,0 +1 @@
1
+ {:too_short=>"abc", :too_long=>"abcabcabcab"}
@@ -0,0 +1,5 @@
1
+ ##### Base String
2
+
3
+ @[ruby](example.rb)
4
+
5
+ @[:code_block](output.txt)
@@ -0,0 +1,14 @@
1
+ ##### Simple
2
+
3
+ ```example.rb```:
4
+ ```ruby
5
+ require 'test_values'
6
+
7
+ values = StringValues.strings_not_in_length_range((4..10))
8
+ p values
9
+ ```
10
+
11
+ ```output.txt```:
12
+ ```
13
+ {:too_short=>"xxx", :too_long=>"xxxxxxxxxxx"}
14
+ ```
@@ -0,0 +1,4 @@
1
+ require 'test_values'
2
+
3
+ values = StringValues.strings_not_in_length_range((4..10))
4
+ p values
@@ -0,0 +1 @@
1
+ {:too_short=>"xxx", :too_long=>"xxxxxxxxxxx"}
@@ -0,0 +1,5 @@
1
+ ##### Simple
2
+
3
+ @[ruby](example.rb)
4
+
5
+ @[:code_block](output.txt)
@@ -0,0 +1,5 @@
1
+ #### Method ```strings_not_in_length_range```
2
+
3
+ @[:markdown](simple/template.md)
4
+
5
+ @[:markdown](base_string/template.md)
@@ -0,0 +1,13 @@
1
+ ### Class ```StringValues```
2
+
3
+ #### Methods
4
+
5
+ - [strings_in_length_range](#method-strings_in_length_range)
6
+ - [strings_not_in_length_range](#method-strings_not_in_length_range)
7
+ - [string_of_length](#method-string_of_length)
8
+
9
+ @[:markdown](strings_in_length_range/template.md)
10
+
11
+ @[:markdown](strings_not_in_length_range/template.md)
12
+
13
+ @[:markdown](string_of_length/template.md)
@@ -0,0 +1,66 @@
1
+ ## Named Values
2
+
3
+ Generally speaking, a values method whose name is plural returns a hash of named values.
4
+
5
+ The calling test can iterate over the hash, using the names as labels and the values as test data:
6
+
7
+ ```example.rb```:
8
+ ```ruby
9
+ require 'minitest/autorun'
10
+
11
+ require 'test_values'
12
+
13
+ class MyTest < Minitest::Test
14
+
15
+ def test_bad_item_length
16
+ items = MyItems.new
17
+ values = StringValues.strings_not_in_length_range((4..8))
18
+ puts "Testing with values #{values.inspect}"
19
+ values.each_pair do |name, value|
20
+ message = "Value #{value.inspect} should raise an exception because it is #{name}."
21
+ puts "\n#{message}"
22
+ e = assert_raises(ArgumentError, message) do
23
+ items.add_item(value)
24
+ end
25
+ puts "Got exception #{e.inspect}"
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+
32
+ class MyItems
33
+
34
+ attr_accessor :items
35
+
36
+ def initialize
37
+ self.items = []
38
+ end
39
+
40
+ def add_item(item)
41
+ raise ArgumentError.new(item) unless (4..8).include?(item.length)
42
+ items.push(item)
43
+ end
44
+
45
+ end
46
+ ```
47
+
48
+ ```output.txt```:
49
+ ```
50
+ Run options: --seed 24259
51
+
52
+ # Running:
53
+
54
+ Testing with values {:too_short=>"xxx", :too_long=>"xxxxxxxxx"}
55
+
56
+ Value "xxx" should raise an exception because it is too_short.
57
+ Got exception #<ArgumentError: xxx>
58
+
59
+ Value "xxxxxxxxx" should raise an exception because it is too_long.
60
+ Got exception #<ArgumentError: xxxxxxxxx>
61
+ .
62
+
63
+ Finished in 0.001529s, 653.9277 runs/s, 1307.8554 assertions/s.
64
+
65
+ 1 runs, 2 assertions, 0 failures, 0 errors, 0 skips
66
+ ```
@@ -0,0 +1,37 @@
1
+ require 'minitest/autorun'
2
+
3
+ require 'test_values'
4
+
5
+ class MyTest < Minitest::Test
6
+
7
+ def test_bad_item_length
8
+ items = MyItems.new
9
+ values = StringValues.strings_not_in_length_range((4..8))
10
+ puts "Testing with values #{values.inspect}"
11
+ values.each_pair do |name, value|
12
+ message = "Value #{value.inspect} should raise an exception because it is #{name}."
13
+ puts "\n#{message}"
14
+ e = assert_raises(ArgumentError, message) do
15
+ items.add_item(value)
16
+ end
17
+ puts "Got exception #{e.inspect}"
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+
24
+ class MyItems
25
+
26
+ attr_accessor :items
27
+
28
+ def initialize
29
+ self.items = []
30
+ end
31
+
32
+ def add_item(item)
33
+ raise ArgumentError.new(item) unless (4..8).include?(item.length)
34
+ items.push(item)
35
+ end
36
+
37
+ end
@@ -0,0 +1,16 @@
1
+ Run options: --seed 24259
2
+
3
+ # Running:
4
+
5
+ Testing with values {:too_short=>"xxx", :too_long=>"xxxxxxxxx"}
6
+
7
+ Value "xxx" should raise an exception because it is too_short.
8
+ Got exception #<ArgumentError: xxx>
9
+
10
+ Value "xxxxxxxxx" should raise an exception because it is too_long.
11
+ Got exception #<ArgumentError: xxxxxxxxx>
12
+ .
13
+
14
+ Finished in 0.001529s, 653.9277 runs/s, 1307.8554 assertions/s.
15
+
16
+ 1 runs, 2 assertions, 0 failures, 0 errors, 0 skips
@@ -0,0 +1,9 @@
1
+ ## Named Values
2
+
3
+ Generally speaking, a values method whose name is plural returns a hash of named values.
4
+
5
+ The calling test can iterate over the hash, using the names as labels and the values as test data:
6
+
7
+ @[ruby](example.rb)
8
+
9
+ @[:code_block](output.txt)
@@ -0,0 +1,13 @@
1
+ # Test Values
2
+
3
+ [![Gem](https://img.shields.io/gem/v/test_values.svg?style=flat)](http://rubygems.org/gems/test_values "View this project in Rubygems")
4
+
5
+ This project makes it easy to generate _and utilize_ certain kinds of values for testing software.
6
+
7
+ @[:markdown](named_values/template.md)
8
+
9
+ ## Classes
10
+
11
+ - [StringValues](#class-stringvalues)
12
+
13
+ @[:markdown](classes/string_values/template.md)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_values
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - burdettelamar
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-14 00:00:00.000000000 Z
11
+ date: 2018-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,6 +73,40 @@ files:
73
73
  - lib/test_values/string_values.rb
74
74
  - lib/test_values/values_base.rb
75
75
  - lib/test_values/version.rb
76
+ - markdown/readme/Rakefile
77
+ - markdown/readme/classes/string_values/string_of_length/base_string/example.md
78
+ - markdown/readme/classes/string_values/string_of_length/base_string/example.rb
79
+ - markdown/readme/classes/string_values/string_of_length/base_string/output.txt
80
+ - markdown/readme/classes/string_values/string_of_length/base_string/template.md
81
+ - markdown/readme/classes/string_values/string_of_length/simple/example.md
82
+ - markdown/readme/classes/string_values/string_of_length/simple/example.rb
83
+ - markdown/readme/classes/string_values/string_of_length/simple/output.txt
84
+ - markdown/readme/classes/string_values/string_of_length/simple/template.md
85
+ - markdown/readme/classes/string_values/string_of_length/template.md
86
+ - markdown/readme/classes/string_values/strings_in_length_range/base_string/example.md
87
+ - markdown/readme/classes/string_values/strings_in_length_range/base_string/example.rb
88
+ - markdown/readme/classes/string_values/strings_in_length_range/base_string/output.txt
89
+ - markdown/readme/classes/string_values/strings_in_length_range/base_string/template.md
90
+ - markdown/readme/classes/string_values/strings_in_length_range/simple/example.md
91
+ - markdown/readme/classes/string_values/strings_in_length_range/simple/example.rb
92
+ - markdown/readme/classes/string_values/strings_in_length_range/simple/output.txt
93
+ - markdown/readme/classes/string_values/strings_in_length_range/simple/template.md
94
+ - markdown/readme/classes/string_values/strings_in_length_range/template.md
95
+ - markdown/readme/classes/string_values/strings_not_in_length_range/base_string/example.md
96
+ - markdown/readme/classes/string_values/strings_not_in_length_range/base_string/example.rb
97
+ - markdown/readme/classes/string_values/strings_not_in_length_range/base_string/output.txt
98
+ - markdown/readme/classes/string_values/strings_not_in_length_range/base_string/template.md
99
+ - markdown/readme/classes/string_values/strings_not_in_length_range/simple/example.md
100
+ - markdown/readme/classes/string_values/strings_not_in_length_range/simple/example.rb
101
+ - markdown/readme/classes/string_values/strings_not_in_length_range/simple/output.txt
102
+ - markdown/readme/classes/string_values/strings_not_in_length_range/simple/template.md
103
+ - markdown/readme/classes/string_values/strings_not_in_length_range/template.md
104
+ - markdown/readme/classes/string_values/template.md
105
+ - markdown/readme/named_values/example.md
106
+ - markdown/readme/named_values/example.rb
107
+ - markdown/readme/named_values/output.txt
108
+ - markdown/readme/named_values/template.md
109
+ - markdown/readme/template.md
76
110
  - test_values.gemspec
77
111
  homepage: https://github.com/BurdetteLamar/test_values
78
112
  licenses: