Module: SpecAssist
- Defined in:
- lib/spec_assist.rb
Constant Summary collapse
- LORUM =
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummynibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummynibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummynibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummynibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi."
Instance Method Summary collapse
- #check_max_length(fields, length) ⇒ Object
- #check_min_length(fields, length) ⇒ Object
- #check_nullness(fields) ⇒ Object
- #check_unique_field(a, b, field) ⇒ Object
- #get_string(length = 255) ⇒ Object
- #varchar100 ⇒ Object
- #varchar255 ⇒ Object
- #varchar32 ⇒ Object
Instance Method Details
#check_max_length(fields, length) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/spec_assist.rb', line 24 def check_max_length(fields, length) fields.each do |method| it "should require #{method} to be #{length.to_s} chars or less." do max = length.to_i + 1 @obj.send( method.to_s + '=', get_string(max) ) @obj.should_not be_valid end end end |
#check_min_length(fields, length) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/spec_assist.rb', line 13 def check_min_length(fields, length) fields.each do |method| it "should require #{method} to be at least #{length.to_s} chars." do min = length.to_i - 1 @obj.send( method.to_s + '=', get_string(min) ) @obj.should_not be_valid end end end |
#check_nullness(fields) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/spec_assist.rb', line 4 def check_nullness(fields) fields.each do |method| it "should not allow #{method} to be nil" do @obj.send( method.to_s + '=', nil ) @obj.should_not be_valid end end end |
#check_unique_field(a, b, field) ⇒ Object
35 36 37 38 |
# File 'lib/spec_assist.rb', line 35 def check_unique_field(a, b, field) b.send( field.to_s + '=', a.send( field ) ) b.should_not be_valid end |
#get_string(length = 255) ⇒ Object
40 41 42 43 |
# File 'lib/spec_assist.rb', line 40 def get_string(length=255) str = LORUM[0, length.to_i] return str end |
#varchar100 ⇒ Object
49 50 51 |
# File 'lib/spec_assist.rb', line 49 def varchar100 return get_string(103) end |
#varchar255 ⇒ Object
53 54 55 |
# File 'lib/spec_assist.rb', line 53 def varchar255 return get_string(260) end |
#varchar32 ⇒ Object
45 46 47 |
# File 'lib/spec_assist.rb', line 45 def varchar32 return get_string(33) end |