joost/phony_rails — pull request #46 by TalkativeTree (2014-02-07 07:43:39+00:00)
Title: Add Validates uniqueness to #validates_plausible_phone

Using rails 4.0 and ruby 2.1 I am using phony_rails to validate cellphone numbers. I want to ensure that phone numbers are unique, but in my spec it's causing a conflict with validates_uniqueness and it's not receiving the error.

```ruby
1) User should require case sensitive unique value for cellphone
Failure/Error: it { should validate_uniqueness_of :cellphone }
Expected errors to include "has already been taken" when cellphone is set to "a", got errors: ["email can't be blank (\"\")", "email can't be blank (\"\")", "email has already been taken (\"\")", "password can't be blank (nil)", "cellphone can't be blank (nil)"]
```

##Spec using shoulda-matches

```ruby
it { should validate_presence_of :cellphone }
it { should validate_uniqueness_of :cellphone }
```

#User model

```ruby
phony_normalized_method :cellphone
phony_normalize :cellphone, default_country_code: 'US'

validates_uniqueness_of :cellphone
validates :cellphone, phony_plausible: true, presence: true
```

and migration:
```ruby
t.string :cellphone, null: false, default: ""
```

The spec for this pull request isn't passing, because the
`Failure/Error: copy_home.should_not be_valid
expected valid? to return false, got true`

I wanted to check to see if this was something you'd be interested in adding before I spent any more time figuring out why the spec isn't passing. Also, it would help to get another set of eyes on it.