-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from joecorcoran/ruby-regex-fix-2
Change \A and \z to ^ and $ in regex (with tests)
- Loading branch information
Showing
2 changed files
with
21 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -407,6 +407,26 @@ describe('judge', function() { | |
el.value = 'AbC'; | ||
expect(validator({ 'with': '(?-mix:[A-Za-z]+)' }, {})).toBeValid(); | ||
}); | ||
|
||
it('converts devise\'s Ruby email regex and returns invalid with invalid email', function() { | ||
el.value = 'not an email'; | ||
expect(validator({ 'with': '(?-mix:\\A[^@\\s]+@([^@\\s]+\\.)+[^@\\s]+\\z)' }, { invalid: 'is invalid' })).toBeInvalidWith(['is invalid']); | ||
}); | ||
|
||
it('converts devise\'s Ruby email regex and returns valid with valid email', function() { | ||
el.value = '[email protected]'; | ||
expect(validator({ 'with': '(?-mix:\\A[^@\\s]+@([^@\\s]+\\.)+[^@\\s]+\\z)' }, {})).toBeValid(); | ||
}); | ||
|
||
it('converts a Ruby slug regex and returns invalid with invalid slug', function() { | ||
el.value = 'not an slug.'; | ||
expect(validator({ 'with': '(?-mix:\\A[-a-zA-Z0-9]+\\z)' }, { invalid: 'is invalid' })).toBeInvalidWith(['is invalid']); | ||
}); | ||
|
||
it('converts a Ruby slug regex and returns valid with valid slug', function() { | ||
el.value = 'this-is-a-slug'; | ||
expect(validator({ 'with': '(?-mix:\\A[-a-zA-Z0-9]+\\z)' }, {})).toBeValid(); | ||
}); | ||
}); | ||
|
||
describe('without', function() { | ||
|