carlosbrando-remarkable 2.2.1 → 2.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +0 -83
- data/Rakefile +8 -1
- data/lib/remarkable.rb +1 -1
- data/lib/remarkable/active_record/macros/database/column_matcher.rb +6 -53
- data/lib/remarkable/active_record/macros/validations/allow_mass_assignment_of_matcher.rb +2 -2
- data/lib/remarkable/active_record/macros/validations/protect_attributes_matcher.rb +1 -1
- data/remarkable.gemspec +6 -5
- metadata +6 -87
- data/spec/controllers/posts_controller_spec.rb +0 -220
- data/spec/controllers/users_controller_spec.rb +0 -15
- data/spec/fixtures/addresses.yml +0 -3
- data/spec/fixtures/fleas.yml +0 -10
- data/spec/fixtures/friendships.yml +0 -0
- data/spec/fixtures/posts.yml +0 -5
- data/spec/fixtures/products.yml +0 -0
- data/spec/fixtures/taggings.yml +0 -0
- data/spec/fixtures/tags.yml +0 -9
- data/spec/fixtures/users.yml +0 -13
- data/spec/models/address_spec.rb +0 -65
- data/spec/models/dog_spec.rb +0 -78
- data/spec/models/flea_spec.rb +0 -39
- data/spec/models/friendship_spec.rb +0 -13
- data/spec/models/post_spec.rb +0 -69
- data/spec/models/product_spec.rb +0 -122
- data/spec/models/tag_spec.rb +0 -21
- data/spec/models/tagging_spec.rb +0 -37
- data/spec/models/user_spec.rb +0 -292
- data/spec/other/custom_macros_spec.rb +0 -27
- data/spec/other/my_own_matcher_spec.rb +0 -11
- data/spec/other/private_helpers_spec.rb +0 -31
- data/spec/rails_root/app/controllers/application.rb +0 -25
- data/spec/rails_root/app/controllers/posts_controller.rb +0 -87
- data/spec/rails_root/app/controllers/users_controller.rb +0 -84
- data/spec/rails_root/app/helpers/application_helper.rb +0 -3
- data/spec/rails_root/app/helpers/posts_helper.rb +0 -2
- data/spec/rails_root/app/helpers/users_helper.rb +0 -2
- data/spec/rails_root/app/models/address.rb +0 -7
- data/spec/rails_root/app/models/flea.rb +0 -7
- data/spec/rails_root/app/models/friendship.rb +0 -4
- data/spec/rails_root/app/models/pets/dog.rb +0 -12
- data/spec/rails_root/app/models/post.rb +0 -12
- data/spec/rails_root/app/models/product.rb +0 -14
- data/spec/rails_root/app/models/tag.rb +0 -8
- data/spec/rails_root/app/models/tagging.rb +0 -6
- data/spec/rails_root/app/models/user.rb +0 -43
- data/spec/rails_root/app/views/layouts/posts.rhtml +0 -19
- data/spec/rails_root/app/views/layouts/users.rhtml +0 -17
- data/spec/rails_root/app/views/layouts/wide.html.erb +0 -1
- data/spec/rails_root/app/views/posts/edit.rhtml +0 -27
- data/spec/rails_root/app/views/posts/index.rhtml +0 -25
- data/spec/rails_root/app/views/posts/new.rhtml +0 -26
- data/spec/rails_root/app/views/posts/show.rhtml +0 -18
- data/spec/rails_root/app/views/users/edit.rhtml +0 -22
- data/spec/rails_root/app/views/users/index.rhtml +0 -22
- data/spec/rails_root/app/views/users/new.rhtml +0 -21
- data/spec/rails_root/app/views/users/show.rhtml +0 -13
- data/spec/rails_root/config/boot.rb +0 -109
- data/spec/rails_root/config/database.yml +0 -3
- data/spec/rails_root/config/environment.rb +0 -16
- data/spec/rails_root/config/environments/test.rb +0 -0
- data/spec/rails_root/config/initializers/new_rails_defaults.rb +0 -15
- data/spec/rails_root/config/initializers/shoulda.rb +0 -8
- data/spec/rails_root/config/locales/en.yml +0 -8
- data/spec/rails_root/config/routes.rb +0 -6
- data/spec/rails_root/db/migrate/001_create_users.rb +0 -18
- data/spec/rails_root/db/migrate/002_create_posts.rb +0 -13
- data/spec/rails_root/db/migrate/003_create_taggings.rb +0 -12
- data/spec/rails_root/db/migrate/004_create_tags.rb +0 -11
- data/spec/rails_root/db/migrate/005_create_dogs.rb +0 -13
- data/spec/rails_root/db/migrate/006_create_addresses.rb +0 -14
- data/spec/rails_root/db/migrate/007_create_fleas.rb +0 -11
- data/spec/rails_root/db/migrate/008_create_dogs_fleas.rb +0 -12
- data/spec/rails_root/db/migrate/009_create_products.rb +0 -17
- data/spec/rails_root/db/migrate/010_create_friendships.rb +0 -14
- data/spec/rails_root/db/migrate/011_add_fleas_color.rb +0 -10
- data/spec/rails_root/db/migrate/012_add_fleas_address.rb +0 -10
- data/spec/rails_root/db/schema.rb +0 -0
- data/spec/rails_root/log/.keep +0 -0
- data/spec/rails_root/public/.htaccess +0 -40
- data/spec/rails_root/public/404.html +0 -30
- data/spec/rails_root/public/422.html +0 -30
- data/spec/rails_root/public/500.html +0 -30
- data/spec/rails_root/script/console +0 -3
- data/spec/rails_root/script/generate +0 -3
- data/spec/rails_root/spec/remarkable_macros/.keep +0 -0
- data/spec/rails_root/vendor/plugins/.keep +0 -0
- data/spec/rails_root/vendor/plugins/my_plugin/remarkable_macros/.keep +0 -0
- data/spec/rcov.opts +0 -2
- data/spec/spec.opts +0 -4
- data/spec/spec_helper.rb +0 -56
@@ -1,15 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe UsersController do
|
4
|
-
fixtures :all
|
5
|
-
|
6
|
-
should_filter_params :ssn
|
7
|
-
should_not_filter_params :email
|
8
|
-
end
|
9
|
-
|
10
|
-
describe UsersController do
|
11
|
-
fixtures :all
|
12
|
-
|
13
|
-
it { should filter_params(:ssn) }
|
14
|
-
it { should_not filter_params(:email) }
|
15
|
-
end
|
data/spec/fixtures/addresses.yml
DELETED
data/spec/fixtures/fleas.yml
DELETED
File without changes
|
data/spec/fixtures/posts.yml
DELETED
data/spec/fixtures/products.yml
DELETED
File without changes
|
data/spec/fixtures/taggings.yml
DELETED
File without changes
|
data/spec/fixtures/tags.yml
DELETED
data/spec/fixtures/users.yml
DELETED
data/spec/models/address_spec.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe Address do
|
4
|
-
fixtures :all
|
5
|
-
|
6
|
-
it { should belong_to(:addressable) }
|
7
|
-
|
8
|
-
it { should require_unique_attributes(:title, :scoped_to => [:addressable_id, :addressable_type]) }
|
9
|
-
it { should require_unique_attributes(:title).scoped_to([:addressable_id, :addressable_type]) }
|
10
|
-
it { should_not require_unique_attributes(:title, :scoped_to => [:addressable_id]) }
|
11
|
-
it { should_not require_unique_attributes(:zip) }
|
12
|
-
|
13
|
-
it { should ensure_length_at_least(:zip, 5) }
|
14
|
-
it { should_not ensure_length_at_least(:zip, 4) }
|
15
|
-
it { should_not ensure_length_at_least(:zip, 6) }
|
16
|
-
|
17
|
-
it { should validate_length_of(:zip, :minimum => 5) }
|
18
|
-
it { should validate_length_of(:zip, :minimum => 5).allow_nil }
|
19
|
-
it { should_not validate_length_of(:zip, :is => 5) }
|
20
|
-
it { should_not validate_length_of(:zip, :minimum => 5, :allow_nil => false) }
|
21
|
-
it { should_not validate_length_of(:zip, :minimum => 4) }
|
22
|
-
it { should_not validate_length_of(:zip, :minimum => 6) }
|
23
|
-
|
24
|
-
it { proc{ should validate_length_of(:zip) }.should raise_error }
|
25
|
-
|
26
|
-
it { should only_allow_numeric_values_for(:zip) }
|
27
|
-
it { should validate_numericality_of(:zip).less_than(20) }
|
28
|
-
it { should validate_numericality_of(:zip).greater_than(10) }
|
29
|
-
it { should validate_numericality_of(:zip).less_than(20).greater_than(10) }
|
30
|
-
it { should_not validate_numericality_of(:zip, :less_than => 10) }
|
31
|
-
it { should_not validate_numericality_of(:zip, :greater_than => 20) }
|
32
|
-
|
33
|
-
it { should_not only_allow_numeric_values_for(:title) }
|
34
|
-
it { should_not only_allow_numeric_or_blank_values_for(:zip) }
|
35
|
-
end
|
36
|
-
|
37
|
-
describe Address do
|
38
|
-
fixtures :all
|
39
|
-
|
40
|
-
should_belong_to :addressable
|
41
|
-
|
42
|
-
should_require_unique_attributes :title, :scoped_to => [:addressable_id, :addressable_type]
|
43
|
-
should_not_require_unique_attributes :zip
|
44
|
-
|
45
|
-
should_ensure_length_at_least :zip, 5
|
46
|
-
should_not_ensure_length_at_least :zip, 4
|
47
|
-
should_not_ensure_length_at_least :zip, 6
|
48
|
-
|
49
|
-
should_validate_length_of :zip, :minimum => 5
|
50
|
-
should_validate_length_of :zip, :minimum => 5, :allow_nil => true
|
51
|
-
should_not_validate_length_of :zip, :minimum => 5, :allow_nil => false
|
52
|
-
should_not_validate_length_of :zip, :is => 5
|
53
|
-
should_not_validate_length_of :zip, :minimum => 4
|
54
|
-
should_not_validate_length_of :zip, :minimum => 6
|
55
|
-
|
56
|
-
should_only_allow_numeric_values_for :zip
|
57
|
-
should_validate_numericality_of :zip, :less_than => 20
|
58
|
-
should_validate_numericality_of :zip, :greater_than => 10
|
59
|
-
should_validate_numericality_of :zip, :less_than => 20, :greater_than => 10
|
60
|
-
should_not_validate_numericality_of :zip, :less_than => 10
|
61
|
-
should_not_validate_numericality_of :zip, :greater_than => 20
|
62
|
-
|
63
|
-
should_not_only_allow_numeric_values_for :title
|
64
|
-
should_not_only_allow_numeric_or_blank_values_for :zip
|
65
|
-
end
|
data/spec/models/dog_spec.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe Pets::Dog do
|
4
|
-
it { should belong_to(:user) }
|
5
|
-
it { should belong_to(:address) }
|
6
|
-
it { should belong_to(:user, :address) }
|
7
|
-
it { should_not belong_to(:foo, :bar) }
|
8
|
-
|
9
|
-
it { should have_and_belong_to_many(:fleas) }
|
10
|
-
|
11
|
-
it { should only_allow_numeric_values_for(:age).allow_blank }
|
12
|
-
it { should only_allow_numeric_values_for(:age).allow_blank(true) }
|
13
|
-
it { should only_allow_numeric_values_for(:age, :allow_blank => true) }
|
14
|
-
|
15
|
-
it { should_not only_allow_numeric_values_for(:age).allow_blank(false) }
|
16
|
-
it { should_not only_allow_numeric_values_for(:age, :allow_blank => false) }
|
17
|
-
|
18
|
-
it { should only_allow_numeric_or_blank_values_for(:age) }
|
19
|
-
|
20
|
-
it { should require_attributes(:owner_id) }
|
21
|
-
|
22
|
-
it { should validate_numericality_of(:age) }
|
23
|
-
it { should validate_numericality_of(:age).only_integer }
|
24
|
-
it { should validate_numericality_of(:age).allow_blank(true) }
|
25
|
-
it { should validate_numericality_of(:age).odd }
|
26
|
-
it { should validate_numericality_of(:age).even(false) }
|
27
|
-
it { should validate_numericality_of(:age).greater_than_or_equal_to(10) }
|
28
|
-
|
29
|
-
it { should_not validate_numericality_of(:age, :greater_than_or_equal_to => 9) }
|
30
|
-
it { should_not validate_numericality_of(:age, :only_integer => false) }
|
31
|
-
it { should_not validate_numericality_of(:age, :allow_blank => false) }
|
32
|
-
it { should_not validate_numericality_of(:age).odd(false) }
|
33
|
-
it { should_not validate_numericality_of(:age).even }
|
34
|
-
|
35
|
-
it { should validate_numericality_of(:owner_id) }
|
36
|
-
it { should validate_numericality_of(:owner_id).only_integer(false) }
|
37
|
-
it { should validate_numericality_of(:owner_id).allow_nil }
|
38
|
-
it { should validate_numericality_of(:owner_id).odd(false) }
|
39
|
-
it { should validate_numericality_of(:owner_id).even }
|
40
|
-
it { should validate_numericality_of(:owner_id).less_than_or_equal_to(10) }
|
41
|
-
|
42
|
-
it { should_not validate_numericality_of(:owner_id, :less_than_or_equal_to => 11) }
|
43
|
-
it { should_not validate_numericality_of(:owner_id, :only_integer => true) }
|
44
|
-
it { should_not validate_numericality_of(:owner_id, :allow_nil => false) }
|
45
|
-
it { should_not validate_numericality_of(:owner_id).odd }
|
46
|
-
it { should_not validate_numericality_of(:owner_id).even(false) }
|
47
|
-
end
|
48
|
-
|
49
|
-
describe Pets::Dog do
|
50
|
-
should_belong_to :user
|
51
|
-
should_belong_to :address
|
52
|
-
should_belong_to :user, :address
|
53
|
-
should_not_belong_to :foo, :bar
|
54
|
-
|
55
|
-
should_have_and_belong_to_many :fleas
|
56
|
-
|
57
|
-
should_only_allow_numeric_or_blank_values_for :age
|
58
|
-
should_only_allow_numeric_values_for :age, :allow_blank => true
|
59
|
-
should_not_only_allow_numeric_values_for :age, :allow_blank => false
|
60
|
-
|
61
|
-
should_require_attributes :owner_id
|
62
|
-
|
63
|
-
should_validate_numericality_of :owner_id
|
64
|
-
should_validate_numericality_of :owner_id, :allow_nil => true
|
65
|
-
should_validate_numericality_of :owner_id, :even => true
|
66
|
-
should_validate_numericality_of :owner_id, :less_than_or_equal_to => 10
|
67
|
-
should_not_validate_numericality_of :owner_id, :less_than_or_equal_to => 11
|
68
|
-
should_not_validate_numericality_of :owner_id, :odd => true
|
69
|
-
should_not_validate_numericality_of :owner_id, :allow_nil => false
|
70
|
-
|
71
|
-
should_validate_numericality_of :age
|
72
|
-
should_validate_numericality_of :age, :allow_blank => true
|
73
|
-
should_validate_numericality_of :age, :odd => true
|
74
|
-
should_validate_numericality_of :age, :greater_than_or_equal_to => 10
|
75
|
-
should_not_validate_numericality_of :age, :greater_than_or_equal_to => 9
|
76
|
-
should_not_validate_numericality_of :age, :even => true
|
77
|
-
should_not_validate_numericality_of :age, :allow_blank => false
|
78
|
-
end
|
data/spec/models/flea_spec.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe Flea do
|
4
|
-
fixtures :fleas
|
5
|
-
|
6
|
-
it { should have_and_belong_to_many(:dogs) }
|
7
|
-
|
8
|
-
describe "with valid attributes" do
|
9
|
-
subject { Flea.new(:name => 'Mike') }
|
10
|
-
it { should be_valid }
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "without a name" do
|
14
|
-
subject { Flea.new(:name => '') }
|
15
|
-
it { should_not be_valid }
|
16
|
-
end
|
17
|
-
|
18
|
-
it { should validate_uniqueness_of :name, :case_sensitive => false }
|
19
|
-
it { should validate_uniqueness_of :color, :allow_nil => true }
|
20
|
-
it { should validate_uniqueness_of :address, :allow_blank => true }
|
21
|
-
|
22
|
-
it { should_not validate_uniqueness_of :name, :case_sensitive => true }
|
23
|
-
it { should_not validate_uniqueness_of :color, :allow_nil => false }
|
24
|
-
it { should_not validate_uniqueness_of :address, :allow_blank => false }
|
25
|
-
end
|
26
|
-
|
27
|
-
describe Flea do
|
28
|
-
fixtures :fleas
|
29
|
-
|
30
|
-
should_have_and_belong_to_many :dogs
|
31
|
-
|
32
|
-
should_validate_uniqueness_of :name, :case_sensitive => false
|
33
|
-
should_validate_uniqueness_of :color, :allow_nil => true
|
34
|
-
should_validate_uniqueness_of :address, :allow_blank => true
|
35
|
-
|
36
|
-
should_not_validate_uniqueness_of :name, :case_sensitive => true
|
37
|
-
should_not_validate_uniqueness_of :color, :allow_nil => false
|
38
|
-
should_not_validate_uniqueness_of :address, :allow_blank => false
|
39
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe Friendship do
|
4
|
-
it { should belong_to(:user) }
|
5
|
-
it { should belong_to(:friend) }
|
6
|
-
it { should belong_to(:user, :friend) }
|
7
|
-
end
|
8
|
-
|
9
|
-
describe Friendship do
|
10
|
-
should_belong_to :user
|
11
|
-
should_belong_to :friend
|
12
|
-
should_belong_to :user, :friend
|
13
|
-
end
|
data/spec/models/post_spec.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe Post do
|
4
|
-
fixtures :all
|
5
|
-
|
6
|
-
it { should belong_to(:user) }
|
7
|
-
it { should belong_to(:owner) }
|
8
|
-
it { should belong_to(:user, :owner) }
|
9
|
-
|
10
|
-
it { should have_many(:tags).through(:taggings) }
|
11
|
-
it { should have_many(:tags, :through => :taggings) }
|
12
|
-
|
13
|
-
it { should have_many(:through_tags).through(:taggings) }
|
14
|
-
it { should have_many(:through_tags, :through => :taggings) }
|
15
|
-
|
16
|
-
it { should have_many(:tags, :through_tags).through(:taggings) }
|
17
|
-
it { should have_many(:tags, :through_tags, :through => :taggings) }
|
18
|
-
|
19
|
-
it { should require_unique_attributes(:title) }
|
20
|
-
it { should_not require_unique_attributes(:body) }
|
21
|
-
it { should_not require_unique_attributes(:title).scoped_to(:user_id) }
|
22
|
-
it { should_not require_unique_attributes(:title, :scoped_to => :user_id) }
|
23
|
-
|
24
|
-
it { should require_attributes(:body, :message => /wtf/) }
|
25
|
-
it { should require_attributes(:body).message(/wtf/) }
|
26
|
-
it { should_not require_attributes(:body) }
|
27
|
-
it { should require_attributes(:title) }
|
28
|
-
it { should_not require_attributes(:user_id) }
|
29
|
-
|
30
|
-
it { should only_allow_numeric_values_for(:user_id) }
|
31
|
-
|
32
|
-
it { should validate_numericality_of(:user_id) }
|
33
|
-
it { should validate_numericality_of(:user_id).allow_nil(false) }
|
34
|
-
it { should validate_numericality_of(:user_id).allow_blank(false) }
|
35
|
-
|
36
|
-
it { should_not validate_numericality_of(:user_id, :allow_nil => true) }
|
37
|
-
it { should_not validate_numericality_of(:user_id, :allow_blank => true) }
|
38
|
-
|
39
|
-
it { should_not validate_numericality_of(:title) }
|
40
|
-
it { should_not only_allow_numeric_values_for(:title) }
|
41
|
-
end
|
42
|
-
|
43
|
-
describe Post do
|
44
|
-
fixtures :all
|
45
|
-
|
46
|
-
should_belong_to :user
|
47
|
-
should_belong_to :owner
|
48
|
-
should_belong_to :user, :owner
|
49
|
-
|
50
|
-
should_have_many :tags, :through => :taggings
|
51
|
-
should_have_many :through_tags, :through => :taggings
|
52
|
-
should_have_many :tags, :through_tags, :through => :taggings
|
53
|
-
|
54
|
-
should_require_unique_attributes :title
|
55
|
-
should_require_attributes :body, :message => /wtf/
|
56
|
-
should_require_attributes :title
|
57
|
-
|
58
|
-
should_only_allow_numeric_values_for :user_id
|
59
|
-
|
60
|
-
should_validate_numericality_of :user_id
|
61
|
-
should_validate_numericality_of :user_id, :allow_nil => false
|
62
|
-
should_validate_numericality_of :user_id, :allow_blank => false
|
63
|
-
|
64
|
-
should_not_validate_numericality_of :user_id, :allow_nil => true
|
65
|
-
should_not_validate_numericality_of :user_id, :allow_blank => true
|
66
|
-
|
67
|
-
should_not_validate_numericality_of :title
|
68
|
-
should_not_only_allow_numeric_values_for :title
|
69
|
-
end
|
data/spec/models/product_spec.rb
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe Product do
|
4
|
-
it { should require_attributes(:title) }
|
5
|
-
it { should_not require_attributes(:price) }
|
6
|
-
|
7
|
-
describe "An intangible product" do
|
8
|
-
before(:all) do
|
9
|
-
@product = Product.new(:tangible => false)
|
10
|
-
end
|
11
|
-
|
12
|
-
it { @product.should_not allow_values_for(:size, "22") }
|
13
|
-
it { @product.should allow_values_for(:size, "22kb") }
|
14
|
-
|
15
|
-
it { @product.should_not validate_format_of(:size, "22") }
|
16
|
-
it { @product.should validate_format_of(:size, "22kb") }
|
17
|
-
|
18
|
-
it { @product.should validate_exclusion_of(:weight, 10..100) }
|
19
|
-
it { @product.should_not validate_exclusion_of(:weight, 1..9) }
|
20
|
-
|
21
|
-
it { @product.should require_attributes(:title) }
|
22
|
-
it { @product.should_not require_attributes(:price) }
|
23
|
-
|
24
|
-
it { @product.should validate_presence_of(:title) }
|
25
|
-
it { @product.should_not validate_presence_of(:price) }
|
26
|
-
|
27
|
-
it { @product.should ensure_value_in_range(:price, 0..99) }
|
28
|
-
it { @product.should validate_inclusion_of(:price, 0..99) }
|
29
|
-
it { @product.should validate_inclusion_of(:price, 0..99).allow_nil(false) }
|
30
|
-
it { @product.should validate_inclusion_of(:price, 0..99).allow_blank(false) }
|
31
|
-
|
32
|
-
it { @product.should_not ensure_value_in_range(:price, 2..80) }
|
33
|
-
it { @product.should_not validate_inclusion_of(:price, 2..80) }
|
34
|
-
it { @product.should_not validate_inclusion_of(:price, 0..99, :allow_nil => true) }
|
35
|
-
it { @product.should_not validate_inclusion_of(:price, 0..99, :allow_blank => true) }
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "A tangible product" do
|
39
|
-
before(:all) do
|
40
|
-
@product = Product.new(:tangible => true)
|
41
|
-
end
|
42
|
-
|
43
|
-
it { @product.should validate_inclusion_of(:size, "S", "M", "L", "XL") }
|
44
|
-
it { @product.should validate_inclusion_of(:size, "S", "M", "L", "XL").allow_blank }
|
45
|
-
it { @product.should_not validate_inclusion_of(:size, "XXXL", "XXL") }
|
46
|
-
it { @product.should_not validate_inclusion_of(:size, "S", "M", "L", "XL", :allow_blank => false) }
|
47
|
-
|
48
|
-
it { @product.should validate_exclusion_of(:size, "XS", "XM") }
|
49
|
-
it { @product.should_not validate_exclusion_of(:size, "S", "M", "L", "XL") }
|
50
|
-
|
51
|
-
it { @product.should require_attributes(:price, :title) }
|
52
|
-
it { @product.should validate_presence_of(:price, :title) }
|
53
|
-
|
54
|
-
it { @product.should ensure_value_in_range(:price, 1..9999) }
|
55
|
-
it { @product.should ensure_value_in_range(:weight, 1..100) }
|
56
|
-
|
57
|
-
it { @product.should validate_inclusion_of(:price, 1..9999) }
|
58
|
-
it { @product.should validate_inclusion_of(:price, 1..9999).allow_nil }
|
59
|
-
it { @product.should_not validate_inclusion_of(:price, 1..9999, :allow_nil => false) }
|
60
|
-
|
61
|
-
it { @product.should validate_inclusion_of(:weight, 1..100) }
|
62
|
-
it { @product.should validate_inclusion_of(:weight, 1..100).allow_blank(true) }
|
63
|
-
it { @product.should_not validate_inclusion_of(:weight, 1..100, :allow_blank => false) }
|
64
|
-
|
65
|
-
it { @product.should ensure_length_in_range(:size, 5..20) }
|
66
|
-
it { @product.should validate_length_of(:size, :in => 5..20).allow_blank }
|
67
|
-
it { @product.should_not validate_length_of(:size, :in => 1..10) }
|
68
|
-
it { @product.should_not validate_length_of(:size, :within => 5..20, :allow_blank => false) }
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe Product do
|
73
|
-
describe "An intangible product" do
|
74
|
-
before(:all) do
|
75
|
-
@product = Product.new(:tangible => false)
|
76
|
-
end
|
77
|
-
|
78
|
-
should_not_allow_values_for :size, "22"
|
79
|
-
should_allow_values_for :size, "22kb"
|
80
|
-
|
81
|
-
should_ensure_value_in_range :price, 0..99
|
82
|
-
|
83
|
-
should_require_attributes(:title)
|
84
|
-
should_not_require_attributes(:price)
|
85
|
-
|
86
|
-
should_validate_presence_of(:title)
|
87
|
-
should_not_validate_presence_of(:price)
|
88
|
-
end
|
89
|
-
|
90
|
-
describe "A tangible product" do
|
91
|
-
before(:all) do
|
92
|
-
@product = Product.new(:tangible => true)
|
93
|
-
end
|
94
|
-
|
95
|
-
should_validate_inclusion_of :size, "S", "M", "L", "XL"
|
96
|
-
should_validate_inclusion_of :size, :allow_blank => true
|
97
|
-
should_not_validate_inclusion_of :size, "XXXL", "XXL"
|
98
|
-
should_not_validate_inclusion_of :size, "S", "M", "L", "XL", :allow_blank => false
|
99
|
-
|
100
|
-
should_validate_exclusion_of :size, "XS", "XM"
|
101
|
-
should_not_validate_exclusion_of :size, "S", "M", "L", "XL"
|
102
|
-
|
103
|
-
should_require_attributes :price, :title
|
104
|
-
should_validate_presence_of :price, :title
|
105
|
-
|
106
|
-
should_ensure_value_in_range :price, 1..9999
|
107
|
-
should_ensure_value_in_range :weight, 1..100
|
108
|
-
|
109
|
-
should_validate_inclusion_of :price, 1..9999
|
110
|
-
should_validate_inclusion_of :price, 1..9999, :allow_nil => true
|
111
|
-
should_not_validate_inclusion_of :price, 1..9999, :allow_nil => false
|
112
|
-
|
113
|
-
should_validate_inclusion_of :weight, 1..100
|
114
|
-
should_validate_inclusion_of :weight, 1..100, :allow_blank => true
|
115
|
-
should_not_validate_inclusion_of :weight, 1..100, :allow_blank => false
|
116
|
-
|
117
|
-
should_ensure_length_in_range :size, 5..20
|
118
|
-
should_validate_length_of :size, :in => 5..20, :allow_blank => true
|
119
|
-
should_not_validate_length_of :size, :in => 1..10
|
120
|
-
should_not_validate_length_of :size, :within =>5..20, :allow_blank => false
|
121
|
-
end
|
122
|
-
end
|