Skip to content

Instantly share code, notes, and snippets.

@jimsynz
Created December 19, 2011 22:44
Show Gist options
  • Save jimsynz/1499258 to your computer and use it in GitHub Desktop.
Save jimsynz/1499258 to your computer and use it in GitHub Desktop.
WTF!
class User
include Mongoid::Document
field :email
validates_format_of :email, :with => /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$/i, :message => "is not a valid email adress."
end
describe User do
it { should validate_format_of(:email).to_allow('bot@kimonoapp.com').not_to_allow('b!o^t@kimonoapp.com') }
end
3) User
Failure/Error: it { should validate_format_of(:email).to_allow('bot@kimonoapp.com').not_to_allow('b!o^t@kimonoapp.com') }
Expected User to validate format of "email" allowing the value "bot@kimonoapp.com" and not allowing the value "b!o^t@kimonoapp.com"; instead got "format" validator on "email" with "b!o^t@kimonoapp.com" as a valid value
# ./spec/models/user_spec.rb:15:in `__script__'
# kernel/common/eval18.rb:43:in `instance_eval'
# kernel/bootstrap/array18.rb:16:in `map'
# kernel/bootstrap/array18.rb:16:in `map'
# kernel/loader.rb:686:in `run_at_exits'
# kernel/loader.rb:706:in `epilogue'
# kernel/loader.rb:837:in `main'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment