ohm-contrib 0.0.31 → 0.0.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/LICENSE +2 -1
  2. data/README.markdown +2 -1
  3. data/Rakefile +4 -53
  4. data/lib/ohm/contrib.rb +2 -2
  5. data/lib/ohm/contrib/boundaries.rb +1 -0
  6. data/lib/ohm/contrib/callbacks.rb +5 -4
  7. data/lib/ohm/contrib/date_validations.rb +2 -1
  8. data/lib/ohm/contrib/extra_validations.rb +1 -0
  9. data/lib/ohm/contrib/length_validations.rb +1 -0
  10. data/lib/ohm/contrib/locking.rb +2 -1
  11. data/lib/ohm/contrib/lunar_macros.rb +5 -4
  12. data/lib/ohm/contrib/number_validations.rb +1 -0
  13. data/lib/ohm/contrib/slug.rb +1 -0
  14. data/lib/ohm/contrib/timestamping.rb +1 -0
  15. data/lib/ohm/contrib/typecast.rb +1 -0
  16. data/lib/ohm/contrib/web_validations.rb +2 -1
  17. data/test/autoload_test.rb +19 -0
  18. data/test/boundaries_test.rb +45 -0
  19. data/test/callbacks_lint.rb +105 -0
  20. data/test/date_validations_test.rb +29 -0
  21. data/test/helper.rb +19 -10
  22. data/test/instance_callbacks_test.rb +45 -0
  23. data/test/length_validations_test.rb +31 -0
  24. data/test/lunar_macros_test.rb +146 -0
  25. data/test/macro_callbacks_test.rb +57 -0
  26. data/test/membership_validation_test.rb +31 -0
  27. data/test/number_validations_test.rb +37 -0
  28. data/test/slug_test.rb +30 -0
  29. data/test/timestamping_test.rb +32 -0
  30. data/test/typecast_array_test.rb +154 -0
  31. data/test/typecast_boolean_test.rb +43 -0
  32. data/test/typecast_date_test.rb +77 -0
  33. data/test/typecast_decimal_test.rb +77 -0
  34. data/test/typecast_float_test.rb +52 -0
  35. data/test/typecast_hash_test.rb +117 -0
  36. data/test/typecast_integer_test.rb +66 -0
  37. data/test/typecast_string_test.rb +38 -0
  38. data/test/typecast_time_test.rb +67 -0
  39. data/test/typecast_timezone_test.rb +37 -0
  40. data/test/web_validations_test.rb +79 -0
  41. metadata +47 -56
  42. data/.document +0 -5
  43. data/.gitignore +0 -25
  44. data/VERSION +0 -1
  45. data/lib/ohm/contrib/to_hash.rb +0 -39
  46. data/ohm-contrib.gemspec +0 -103
  47. data/test/test_ohm_boundaries.rb +0 -74
  48. data/test/test_ohm_contrib.rb +0 -70
  49. data/test/test_ohm_contrib_callbacks.rb +0 -375
  50. data/test/test_ohm_date_validations.rb +0 -30
  51. data/test/test_ohm_extra_validations.rb +0 -32
  52. data/test/test_ohm_length_validations.rb +0 -32
  53. data/test/test_ohm_lunar_macros.rb +0 -165
  54. data/test/test_ohm_number_validations.rb +0 -59
  55. data/test/test_ohm_slug.rb +0 -29
  56. data/test/test_ohm_timestamping.rb +0 -64
  57. data/test/test_ohm_to_hash.rb +0 -67
  58. data/test/test_ohm_typecast.rb +0 -707
  59. data/test/test_ohm_web_validations.rb +0 -114
@@ -1,114 +0,0 @@
1
- require "helper"
2
-
3
- class TestOhmWebValidations < Test::Unit::TestCase
4
- class BlogPost < Ohm::Model
5
- include Ohm::WebValidations
6
-
7
- attribute :slug
8
-
9
- index :slug
10
-
11
- def validate
12
- assert_slug :slug
13
- end
14
- end
15
-
16
- class Comment < Ohm::Model
17
- include Ohm::WebValidations
18
-
19
- attribute :ip_address
20
- attribute :homepage
21
- attribute :email
22
-
23
- def validate
24
- assert_ipaddr :ip_address
25
- assert_url :homepage
26
- assert_email :email
27
- end
28
- end
29
-
30
- context "The slug should be valid" do
31
- def setup
32
- Ohm.flush
33
- @blog_post_01 = BlogPost.new
34
- @blog_post_02 = BlogPost.new
35
- end
36
-
37
- should "fail if the slug is not valid" do
38
- @blog_post_01.slug = "This is a title, not a SLUG"
39
- @blog_post_01.create
40
-
41
- assert @blog_post_01.new?
42
- assert_equal [[:slug, :not_slug]], @blog_post_01.errors
43
- end
44
-
45
- should "succeed if the slug is valid" do
46
- @blog_post_02.slug = "this-is-a-valid-slug"
47
- @blog_post_02.create
48
- assert_not_nil @blog_post_02.id
49
- end
50
-
51
- should "fail if the slug is not unique" do
52
-
53
- @blog_post_01.slug = "this-is-a-valid-slug"
54
- @blog_post_01.create
55
-
56
- @blog_post_02.slug = "this-is-a-valid-slug"
57
- @blog_post_02.create
58
-
59
- assert @blog_post_02.new?
60
- assert_equal [[:slug, :not_unique]], @blog_post_02.errors
61
- end
62
- end
63
-
64
- context "the ip address should be valid" do
65
- def setup
66
- @comment = Comment.new
67
- end
68
-
69
- should "fail if the ip address is not valid" do
70
- @comment.ip_address = "400.500.600.700"
71
- @comment.create
72
-
73
- assert @comment.new?
74
- assert @comment.errors.include? [:ip_address, :not_ipaddr]
75
- end
76
- end
77
-
78
- context "the email address should be valid" do
79
- def setup
80
- @comment = Comment.new
81
- end
82
-
83
- should "fail if the email address is not valid" do
84
- @comment.email = "something.com"
85
- @comment.create
86
-
87
- assert @comment.new?
88
- assert @comment.errors.include? [:email, :not_email]
89
- end
90
- end
91
-
92
- context "the homepage URL should be valid" do
93
- def setup
94
- @comment = Comment.new
95
- end
96
-
97
- should "fail if the homepage URL is not valid" do
98
- @comment.homepage = "something"
99
- @comment.create
100
-
101
- assert @comment.new?
102
- assert @comment.errors.include? [:homepage, :not_url]
103
- end
104
-
105
- should "fail if the homepage URL protocol is not http or https" do
106
- @comment.homepage = "irc://irc.freenode.net/something"
107
- @comment.create
108
-
109
- assert @comment.new?
110
- assert @comment.errors.include? [:homepage, :not_url]
111
- end
112
-
113
- end
114
- end