test/matchers/validations_test.rb in mongoid-minitest-0.0.1 vs test/matchers/validations_test.rb in mongoid-minitest-0.0.2

- old
+ new

@@ -1,29 +1,28 @@ require "test_helper" -describe Mongoid::Matchers::Validations do - subject { Person } +describe "Validations" do + describe Person do + subject { Person } - it { must validate_presence_of(:name) } - it { wont validate_presence_of(:age) } + it { must validate_presence_of(:name) } + it { must validate_presence_of(:role).with_message("no role") } - it { must validate_uniqueness_of(:login).case_insensitive } - it { wont validate_uniqueness_of(:email).case_insensitive } + it { must validate_uniqueness_of(:login).case_insensitive } + it { must validate_uniqueness_of(:login).scoped_to(:site) } - it { must validate_length_of(:password).with_min(8) } - it { wont validate_length_of(:password).with_min(0) } - it { must validate_length_of(:password).with_minimum(8) } - it { wont validate_length_of(:password).with_minimum(0) } - it { must validate_length_of(:password).with_max(16) } - it { wont validate_length_of(:password).with_max(8) } - it { must validate_length_of(:password).with_maximum(16) } - it { wont validate_length_of(:password).with_maximum(8) } + it { must validate_length_of(:login).in(5..12) } + it { must validate_length_of(:login).within(5..12) } - it { must validate_format_of(:email).to_allow("foo@bar.com") } - it { wont validate_format_of(:email).to_allow("foo_bar_com") } - it { must validate_format_of(:email).to_not_allow("foo_bar_com") } - it { wont validate_format_of(:email).to_not_allow("foo@bar.com") } + it { must validate_length_of(:password).with_min(8) } + it { must validate_length_of(:password).with_minimum(8) } - it { must validate_exclusion_of(:email).to_not_allow("foo@bar.com") } - it { must validate_exclusion_of(:email).to_not_allow("foo@bar.com", "fizz@buzz.com") } - it { wont validate_exclusion_of(:email).to_not_allow("foo_bar.com") } + it { must validate_length_of(:password).with_max(16) } + it { must validate_length_of(:password).with_maximum(16) } + + it { must validate_format_of(:email).to_allow("foo@bar.com") } + it { must validate_format_of(:email).to_not_allow("foo_bar_com") } + + it { must validate_inclusion_of(:role).to_allow("user", "admin") } + it { must validate_exclusion_of(:email).to_not_allow("foo@bar.com", "fizz@buzz.com") } + end end