ratnikov-shoulda 2.0.6.3 → 2.9.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 (60) hide show
  1. data/README.rdoc +3 -2
  2. data/Rakefile +1 -1
  3. data/lib/shoulda/active_record/assertions.rb +10 -31
  4. data/lib/shoulda/active_record/helpers.rb +40 -0
  5. data/lib/shoulda/active_record/macros.rb +171 -325
  6. data/lib/shoulda/active_record/matchers/allow_mass_assignment_of_matcher.rb +83 -0
  7. data/lib/shoulda/active_record/matchers/allow_value_matcher.rb +102 -0
  8. data/lib/shoulda/active_record/matchers/association_matcher.rb +226 -0
  9. data/lib/shoulda/active_record/matchers/ensure_inclusion_of_matcher.rb +87 -0
  10. data/lib/shoulda/active_record/matchers/ensure_length_of_matcher.rb +141 -0
  11. data/lib/shoulda/active_record/matchers/have_db_column_matcher.rb +169 -0
  12. data/lib/shoulda/active_record/matchers/have_index_matcher.rb +105 -0
  13. data/lib/shoulda/active_record/matchers/have_named_scope_matcher.rb +125 -0
  14. data/lib/shoulda/active_record/matchers/have_readonly_attribute_matcher.rb +59 -0
  15. data/lib/shoulda/active_record/matchers/validate_acceptance_of_matcher.rb +41 -0
  16. data/lib/shoulda/active_record/matchers/validate_numericality_of_matcher.rb +39 -0
  17. data/lib/shoulda/active_record/matchers/validate_presence_of_matcher.rb +60 -0
  18. data/lib/shoulda/active_record/matchers/validate_uniqueness_of_matcher.rb +148 -0
  19. data/lib/shoulda/active_record/matchers/validation_matcher.rb +56 -0
  20. data/lib/shoulda/active_record/matchers.rb +42 -0
  21. data/lib/shoulda/active_record.rb +4 -0
  22. data/lib/shoulda/assertions.rb +12 -0
  23. data/lib/shoulda/autoload_macros.rb +46 -0
  24. data/lib/shoulda/rails.rb +1 -8
  25. data/lib/shoulda/rspec.rb +5 -0
  26. data/lib/shoulda/tasks/list_tests.rake +6 -1
  27. data/lib/shoulda/test_unit.rb +19 -0
  28. data/lib/shoulda.rb +5 -17
  29. data/rails/init.rb +1 -1
  30. data/test/README +2 -2
  31. data/test/fail_macros.rb +2 -2
  32. data/test/matchers/allow_mass_assignment_of_matcher_test.rb +68 -0
  33. data/test/matchers/allow_value_matcher_test.rb +41 -0
  34. data/test/matchers/association_matcher_test.rb +258 -0
  35. data/test/matchers/ensure_inclusion_of_matcher_test.rb +80 -0
  36. data/test/matchers/ensure_length_of_matcher_test.rb +158 -0
  37. data/test/matchers/have_db_column_matcher_test.rb +169 -0
  38. data/test/matchers/have_index_matcher_test.rb +74 -0
  39. data/test/matchers/have_named_scope_matcher_test.rb +65 -0
  40. data/test/matchers/have_readonly_attributes_matcher_test.rb +29 -0
  41. data/test/matchers/validate_acceptance_of_matcher_test.rb +44 -0
  42. data/test/matchers/validate_numericality_of_matcher_test.rb +52 -0
  43. data/test/matchers/validate_presence_of_matcher_test.rb +86 -0
  44. data/test/matchers/validate_uniqueness_of_matcher_test.rb +141 -0
  45. data/test/model_builder.rb +61 -0
  46. data/test/other/autoload_macro_test.rb +18 -0
  47. data/test/other/helpers_test.rb +58 -0
  48. data/test/rails_root/config/database.yml +1 -1
  49. data/test/rails_root/config/environments/{sqlite3.rb → test.rb} +0 -0
  50. data/test/rails_root/test/shoulda_macros/custom_macro.rb +6 -0
  51. data/test/rails_root/vendor/gems/gem_with_macro-0.0.1/shoulda_macros/gem_macro.rb +6 -0
  52. data/test/rails_root/vendor/plugins/plugin_with_macro/shoulda_macros/plugin_macro.rb +6 -0
  53. data/test/test_helper.rb +3 -1
  54. data/test/unit/address_test.rb +1 -1
  55. data/test/unit/dog_test.rb +1 -1
  56. data/test/unit/post_test.rb +4 -4
  57. data/test/unit/product_test.rb +2 -2
  58. data/test/unit/tag_test.rb +2 -1
  59. data/test/unit/user_test.rb +8 -7
  60. metadata +49 -3
@@ -6,5 +6,5 @@ class Pets::DogTest < Test::Unit::TestCase
6
6
  should_have_many :treats
7
7
  should_have_and_belong_to_many :fleas
8
8
  should_require_attributes :treats, :fleas
9
- should_require_attributes :owner_id
9
+ should_validate_presence_of :owner_id
10
10
  end
@@ -9,11 +9,11 @@ class PostTest < Test::Unit::TestCase
9
9
  should_have_many :through_tags, :through => :taggings
10
10
 
11
11
  should_require_unique_attributes :title
12
- should_require_attributes :body, :message => /wtf/
13
- should_require_attributes :title
14
- should_only_allow_numeric_values_for :user_id
12
+ should_validate_presence_of :body, :message => /wtf/
13
+ should_validate_presence_of :title
14
+ should_validate_numericality_of :user_id
15
15
 
16
16
  should_fail do
17
- should_require_unique_attributes :title, :case_sensitive => false
17
+ should_validate_uniqueness_of :title, :case_sensitive => false
18
18
  end
19
19
  end
@@ -6,7 +6,7 @@ class ProductTest < ActiveSupport::TestCase
6
6
  @product = Product.new(:tangible => false)
7
7
  end
8
8
 
9
- should_require_attributes :title
9
+ should_validate_presence_of :title
10
10
  should_not_allow_values_for :size, "22"
11
11
  should_allow_values_for :size, "22kb"
12
12
  should_ensure_value_in_range :price, 0..99
@@ -17,7 +17,7 @@ class ProductTest < ActiveSupport::TestCase
17
17
  @product = Product.new(:tangible => true)
18
18
  end
19
19
 
20
- should_require_attributes :price
20
+ should_validate_presence_of :price
21
21
  should_ensure_value_in_range :price, 1..9999
22
22
  should_ensure_value_in_range :weight, 1..100
23
23
  should_not_allow_values_for :size, "22", "10x15"
@@ -7,8 +7,9 @@ class TagTest < Test::Unit::TestCase
7
7
  should_ensure_length_at_least :name, 2
8
8
 
9
9
  should_protect_attributes :secret
10
+ should_allow_mass_assignment_of :name
10
11
 
11
12
  should_fail do
12
- should_protect_attributes :name
13
+ should_not_allow_mass_assignment_of :name
13
14
  end
14
15
  end
@@ -39,22 +39,23 @@ class UserTest < Test::Unit::TestCase
39
39
  should_allow_values_for :email, "a@b.com", "asdf@asdf.com"
40
40
  should_ensure_length_in_range :email, 1..100
41
41
  should_ensure_value_in_range :age, 1..100
42
- should_protect_attributes :password
42
+ should_not_allow_mass_assignment_of :password
43
43
  should_have_class_methods :find, :destroy
44
44
  should_have_instance_methods :email, :age, :email=, :valid?
45
45
  should_have_db_columns :name, :email, :age
46
- should_have_db_column :id, :type => "integer", :primary => true
47
- should_have_db_column :email, :type => "string", :default => nil, :precision => nil, :limit => 255,
48
- :null => true, :primary => false, :scale => nil, :sql_type => 'varchar(255)'
46
+ should_have_db_column :id, :type => "integer"
47
+ should_have_db_column :email, :type => "string", :default => nil, :precision => nil, :limit => 255,
48
+ :null => true, :scale => nil
49
+ should_validate_acceptance_of :eula
49
50
  should_require_acceptance_of :eula
50
- should_require_unique_attributes :email, :scoped_to => :name, :case_sensitive => false
51
+ should_validate_uniqueness_of :email, :scoped_to => :name, :case_sensitive => false
51
52
 
52
53
  should_ensure_length_is :ssn, 9, :message => "Social Security Number is not the right length"
53
- should_only_allow_numeric_values_for :ssn
54
+ should_validate_numericality_of :ssn
54
55
 
55
56
  should_have_readonly_attributes :name
56
57
 
57
58
  should_fail do
58
- should_protect_attributes :name, :age
59
+ should_not_allow_mass_assignment_of :name, :age
59
60
  end
60
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ratnikov-shoulda
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6.3
4
+ version: 2.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tammer Saleh
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-01-21 00:00:00 -08:00
13
+ date: 2009-02-04 00:00:00 -08:00
14
14
  default_executable: convert_to_should_syntax
15
15
  dependencies: []
16
16
 
@@ -48,21 +48,59 @@ files:
48
48
  - lib/shoulda/rails.rb
49
49
  - lib/shoulda/private_helpers.rb
50
50
  - lib/shoulda/multiple_contexts.rb
51
+ - lib/shoulda/autoload_macros.rb
51
52
  - lib/shoulda/proc_extensions.rb
52
53
  - lib/shoulda/tasks
53
54
  - lib/shoulda/tasks/yaml_to_shoulda.rake
54
55
  - lib/shoulda/tasks/list_tests.rake
56
+ - lib/shoulda/rspec.rb
55
57
  - lib/shoulda/active_record
58
+ - lib/shoulda/active_record/matchers
59
+ - lib/shoulda/active_record/matchers/validate_presence_of_matcher.rb
60
+ - lib/shoulda/active_record/matchers/have_named_scope_matcher.rb
61
+ - lib/shoulda/active_record/matchers/have_readonly_attribute_matcher.rb
62
+ - lib/shoulda/active_record/matchers/validate_numericality_of_matcher.rb
63
+ - lib/shoulda/active_record/matchers/allow_value_matcher.rb
64
+ - lib/shoulda/active_record/matchers/association_matcher.rb
65
+ - lib/shoulda/active_record/matchers/have_index_matcher.rb
66
+ - lib/shoulda/active_record/matchers/ensure_inclusion_of_matcher.rb
67
+ - lib/shoulda/active_record/matchers/have_db_column_matcher.rb
68
+ - lib/shoulda/active_record/matchers/validate_uniqueness_of_matcher.rb
69
+ - lib/shoulda/active_record/matchers/validate_acceptance_of_matcher.rb
70
+ - lib/shoulda/active_record/matchers/allow_mass_assignment_of_matcher.rb
71
+ - lib/shoulda/active_record/matchers/ensure_length_of_matcher.rb
72
+ - lib/shoulda/active_record/matchers/validation_matcher.rb
56
73
  - lib/shoulda/active_record/assertions.rb
74
+ - lib/shoulda/active_record/helpers.rb
75
+ - lib/shoulda/active_record/matchers.rb
57
76
  - lib/shoulda/active_record/macros.rb
58
77
  - lib/shoulda/context.rb
78
+ - lib/shoulda/test_unit.rb
59
79
  - lib/shoulda/macros.rb
60
80
  - lib/shoulda.rb
61
81
  - rails/init.rb
82
+ - test/matchers
83
+ - test/matchers/have_readonly_attributes_matcher_test.rb
84
+ - test/matchers/validate_presence_of_matcher_test.rb
85
+ - test/matchers/ensure_inclusion_of_matcher_test.rb
86
+ - test/matchers/ensure_length_of_matcher_test.rb
87
+ - test/matchers/have_db_column_matcher_test.rb
88
+ - test/matchers/validate_uniqueness_of_matcher_test.rb
89
+ - test/matchers/allow_mass_assignment_of_matcher_test.rb
90
+ - test/matchers/validate_acceptance_of_matcher_test.rb
91
+ - test/matchers/association_matcher_test.rb
92
+ - test/matchers/have_named_scope_matcher_test.rb
93
+ - test/matchers/have_index_matcher_test.rb
94
+ - test/matchers/allow_value_matcher_test.rb
95
+ - test/matchers/validate_numericality_of_matcher_test.rb
96
+ - test/model_builder.rb
62
97
  - test/test_helper.rb
63
98
  - test/README
64
99
  - test/fail_macros.rb
65
100
  - test/rails_root
101
+ - test/rails_root/test
102
+ - test/rails_root/test/shoulda_macros
103
+ - test/rails_root/test/shoulda_macros/custom_macro.rb
66
104
  - test/rails_root/app
67
105
  - test/rails_root/app/helpers
68
106
  - test/rails_root/app/helpers/users_helper.rb
@@ -127,19 +165,27 @@ files:
127
165
  - test/rails_root/config/boot.rb
128
166
  - test/rails_root/config/environment.rb
129
167
  - test/rails_root/config/environments
130
- - test/rails_root/config/environments/sqlite3.rb
168
+ - test/rails_root/config/environments/test.rb
131
169
  - test/rails_root/config/initializers
132
170
  - test/rails_root/config/initializers/shoulda.rb
133
171
  - test/rails_root/config/initializers/new_rails_defaults.rb
134
172
  - test/rails_root/config/routes.rb
135
173
  - test/rails_root/vendor
136
174
  - test/rails_root/vendor/plugins
175
+ - test/rails_root/vendor/plugins/plugin_with_macro
176
+ - test/rails_root/vendor/plugins/plugin_with_macro/shoulda_macros
177
+ - test/rails_root/vendor/plugins/plugin_with_macro/shoulda_macros/plugin_macro.rb
178
+ - test/rails_root/vendor/gems
179
+ - test/rails_root/vendor/gems/gem_with_macro-0.0.1
180
+ - test/rails_root/vendor/gems/gem_with_macro-0.0.1/shoulda_macros
181
+ - test/rails_root/vendor/gems/gem_with_macro-0.0.1/shoulda_macros/gem_macro.rb
137
182
  - test/other
138
183
  - test/other/context_test.rb
139
184
  - test/other/should_test.rb
140
185
  - test/other/helpers_test.rb
141
186
  - test/other/convert_to_should_syntax_test.rb
142
187
  - test/other/multiple_contexts_test.rb
188
+ - test/other/autoload_macro_test.rb
143
189
  - test/other/private_helpers_test.rb
144
190
  - test/unit
145
191
  - test/unit/friendship_test.rb